- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
MainFrm.cpp
资源名称:CAD2006.rar [点击查看]
上传用户:ckg1000
上传日期:2013-01-26
资源大小:630k
文件大小:15k
源码类别:
CAD
开发平台:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "CAD2006.h"
- #include "MainFrm.h"
- #include "NewDialogBar.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- IMPLEMENT_MENUXP(CMainFrame, CFrameWnd);
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_WM_TIMER()
- ON_WM_CLOSE()
- ON_COMMAND(ID_REALLINE, OnRealline)
- ON_COMMAND(ID_BROKENLINE, OnBrokenline)
- ON_COMMAND(ID_TRIGON, OnTrigon)
- ON_COMMAND(ID_RECT, OnRect)
- ON_COMMAND(ID_POLYGON, OnPolygon)
- ON_COMMAND(ID_ROUND, OnRound)
- ON_COMMAND(ID_ELLIPSE, OnEllipse)
- ON_COMMAND(ID_ARC, OnArc)
- ON_COMMAND(IDD_LINE, OnLine)
- ON_COMMAND(IDD_FOLD_LINE, OnFoldLine)
- ON_COMMAND(IDD_ANGLE_LINE, OnAngleLine)
- ON_COMMAND(ID_COLORFOR, OnColorfor)
- ON_COMMAND(ID_COLORBACK, OnColorback)
- ON_UPDATE_COMMAND_UI(ID_REALLINE, OnUpdateRealline)
- ON_UPDATE_COMMAND_UI(ID_BROKENLINE, OnUpdateBrokenline)
- ON_UPDATE_COMMAND_UI(IDD_LINE, OnUpdateLine)
- ON_UPDATE_COMMAND_UI(IDD_FOLD_LINE, OnUpdateFoldLine)
- ON_UPDATE_COMMAND_UI(IDD_ANGLE_LINE, OnUpdateAngleLine)
- ON_COMMAND(ID_DOTLINE, OnDotline)
- ON_UPDATE_COMMAND_UI(ID_DOTLINE, OnUpdateDotline)
- ON_COMMAND(ID_TWOLINE, OnTwoline)
- ON_UPDATE_COMMAND_UI(ID_TWOLINE, OnUpdateTwoline)
- ON_UPDATE_COMMAND_UI(ID_ROUND, OnUpdateRound)
- ON_UPDATE_COMMAND_UI(ID_ELLIPSE, OnUpdateEllipse)
- ON_UPDATE_COMMAND_UI(ID_ARC, OnUpdateArc)
- ON_COMMAND(ID_NUM1, OnNum1)
- ON_UPDATE_COMMAND_UI(ID_NUM1, OnUpdateNum1)
- ON_COMMAND(ID_NUM2, OnNum2)
- ON_UPDATE_COMMAND_UI(ID_NUM2, OnUpdateNum2)
- ON_COMMAND(ID_NUM3, OnNum3)
- ON_UPDATE_COMMAND_UI(ID_NUM3, OnUpdateNum3)
- ON_COMMAND(ID_NUM4, OnNum4)
- ON_UPDATE_COMMAND_UI(ID_NUM4, OnUpdateNum4)
- ON_COMMAND(ID_NUM5, OnNum5)
- ON_UPDATE_COMMAND_UI(ID_NUM5, OnUpdateNum5)
- ON_COMMAND(ID_NUM6, OnNum6)
- ON_UPDATE_COMMAND_UI(ID_NUM6, OnUpdateNum6)
- ON_COMMAND(ID_NUM7, OnNum7)
- ON_UPDATE_COMMAND_UI(ID_NUM7, OnUpdateNum7)
- ON_MENUXP_MESSAGES()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- //ON_MENUXP_MESSAGES()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_SEPARATOR,
- ID_INDICATOR_EXT,
- ID_INDICATOR_CAPS,
- // ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- m_style = realline;
- m_linewidth = one;
- m_shape = new CShape;
- }
- CMainFrame::~CMainFrame()
- {
- delete m_shape;
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- ::AnimateWindow(GetSafeHwnd(),1000,AW_BLEND);
- CMenuXP::UpdateMenuBar(this);
- CMenuXP::SetXPLookNFeel (this);
- CMenu *m_menu = this->GetActiveFrame()->GetMenu();
- int i = m_menu->EnableMenuItem(32775,MF_ENABLED|MF_BYPOSITION);
- m_menu->EnableMenuItem(32776,MF_ENABLED|MF_BYCOMMAND);
- m_menu->EnableMenuItem(32777,MF_DISABLED);
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- if(!m_wndDialogBar.Create(this,IDD_DIALOGBAR,CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY,103))
- {
- ::AfxMessageBox("Failed to create DialogBar!");
- return -1;
- }
- m_wndDialogBar.SetBarStyle(m_wndDialogBar.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY);
- m_wndDialogBar.EnableDocking(CBRS_ALIGN_ANY);
- //EnableDocking(CBRS_ALIGN_ANY);
- //DockControlBar(&m_wndDialogBar);
- m_wndDialogBar.InitDialogBar();
- if(!m_wndTrigon.Create(this,IDD_DIALOGBAR_TRIGON,CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY,104))
- {
- ::AfxMessageBox("Failed to create DialogBar!");
- return -1;
- }
- m_wndTrigon.InitDialogBar();
- if (!m_wndcoolbar.Create(_T("我的控制条"),this,CSize(100,80),TRUE,124))
- {
- TRACE0("Failed to create mybarn");
- return -1;
- }
- m_wndcoolbar.SetBarStyle(m_wndcoolbar.GetBarStyle() | CBRS_TOOLTIPS |
- CBRS_FLYBY | CBRS_SIZE_DYNAMIC|CBRS_BOTTOM);
- m_wndedit.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|
- ES_MULTILINE|ES_WANTRETURN,CRect(0,0,0,0),&m_wndcoolbar,101);
- m_wndedit.ModifyStyleEx(0,WS_EX_CLIENTEDGE);
- m_wndcoolbar.EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndcoolbar, AFX_IDW_DOCKBAR_BOTTOM);
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- m_wndStatusBar.SetBarStyle(m_wndStatusBar.GetBarStyle()|CBRS_BOTTOM);
- m_wndStatusBar.SetPaneInfo(3,ID_SEPARATOR,SBPS_NORMAL,50);
- m_wndStatusBar.SetPaneInfo(2,ID_INDICATOR_EXT,SBPS_NORMAL,30);
- m_wndStatusBar.SetPaneInfo(1,ID_INDICATOR_EXT,SBPS_NORMAL,500);
- m_wndStatusBar.SetPaneInfo(0,ID_SEPARATOR,SBPS_NORMAL,::GetSystemMetrics(SM_CXSCREEN) - 630);
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- /* int index = 0;
- RECT rect;
- while(m_wndToolBar.GetItemID(index) != ID_BUTTON_COMBOBOX)
- {
- index++;
- }
- m_wndToolBar.SetButtonInfo(index,ID_BUTTON_COMBOBOX,TBBS_SEPARATOR,80);
- m_wndToolBar.GetItemRect(index,&rect);
- rect.top += 5;
- rect.bottom += 200;
- if(!m_wndToolBar.m_wndComboBox.Create(WS_CHILD|WS_VISIBLE |CBS_AUTOHSCROLL|CBS_DROPDOWNLIST |
- CBS_HASSTRINGS,rect,&m_wndToolBar,ID_BUTTON_COMBOBOX))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- m_wndToolBar.m_wndComboBox.ShowWindow(SW_SHOW);
- m_wndToolBar.m_wndComboBox.AddString("1sdf");
- m_wndToolBar.m_wndComboBox.AddString("2sdf");
- m_wndToolBar.m_wndComboBox.AddString("3sdf");
- m_wndToolBar.m_wndComboBox.AddString("4sdf");
- m_wndToolBar.m_wndComboBox.SetCurSel(2);*/
- SetTimer(1,1,NULL);
- SetTimer(2,100,NULL);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(m_wndDialogBar.OnCmdMsg(nID,nCode,pExtra,pHandlerInfo))
- return true;
- return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
- }
- void CMainFrame::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- switch( nIDEvent )
- {
- case 1:
- {
- CString Timeinfor;
- CTime Time = CTime::GetCurrentTime();
- Timeinfor.Format("%02d:%02d:%02d",Time.GetHour(),Time.GetMinute(),Time.GetSecond());
- m_wndStatusBar.SetPaneText(3,Timeinfor);
- break;
- }
- case 2:
- {
- static int index = 0;
- if( index > 80 )
- {
- index = 0;
- }
- index += 2;
- CString m_info = " 欢迎使用CAD2006试用版,如有问题,请不吝指教!作者: 汤红波 陆立新 孙永滔 邓萌 徐讷讷";
- m_wndStatusBar.SetPaneText(1,m_info.Left(index));
- }
- }
- CFrameWnd::OnTimer(nIDEvent);
- }
- BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
- {
- // TODO: Add your specialized code here and/or call the base class
- return CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext);
- }
- void CMainFrame::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- if( ::AfxMessageBox("您是否要退出?",MB_OKCANCEL) == IDOK )
- {
- ::AnimateWindow(GetSafeHwnd(),1000,AW_HIDE|AW_BLEND);
- CFrameWnd::OnClose();
- }
- }
- void CMainFrame::OnRealline()
- {
- // TODO: Add your command handler code here
- this->m_style = realline;
- m_shape->SetBorderStyle(PS_SOLID);
- m_wndTrigon.m_ComMode.SetCurSel(2);
- }
- void CMainFrame::OnBrokenline()
- {
- // TODO: Add your command handler code here
- this->m_style = brokenline;
- m_shape->SetBorderStyle(PS_DASH);
- m_wndTrigon.m_ComMode.SetCurSel(3);
- }
- void CMainFrame::OnTrigon()
- {
- // TODO: Add your command handler code here
- m_wndDialogBar.OnButtonTrigon();
- }
- void CMainFrame::OnRect()
- {
- // TODO: Add your command handler code here
- m_wndDialogBar.OnButtonRect();
- }
- void CMainFrame::OnPolygon()
- {
- // TODO: Add your command handler code here
- m_wndDialogBar.OnButtonPolygon();
- }
- void CMainFrame::OnRound()
- {
- // TODO: Add your command handler code here
- //this->m_circle = round;
- m_wndDialogBar.OnButtonCircle();
- }
- void CMainFrame::OnEllipse()
- {
- // TODO: Add your command handler code here
- //this->m_circle = ellips;
- m_wndDialogBar.OnButtonEllipse();
- }
- void CMainFrame::OnArc()
- {
- // TODO: Add your command handler code here
- // this->m_circle = roundmeter;
- m_wndDialogBar.OnButtonCirclemeter();
- }
- void CMainFrame::OnLine()
- {
- // TODO: Add your command handler code here
- // this->m_line = beeline;
- m_wndDialogBar.OnButtonLine();
- }
- void CMainFrame::OnFoldLine()
- {
- // TODO: Add your command handler code here
- // this->m_line = foldline;
- m_wndDialogBar.OnButtonFoldline();
- }
- void CMainFrame::OnAngleLine()
- {
- // TODO: Add your command handler code here
- // this->m_line = angleline;
- m_wndDialogBar.OnButtonAngleline();
- }
- void CMainFrame::OnColorfor()
- {
- // TODO: Add your command handler code here
- this->m_wndDialogBar.OnClickLabelForbk();
- }
- void CMainFrame::OnColorback()
- {
- // TODO: Add your command handler code here
- this->m_wndDialogBar.OnClickLabelBackbk();
- }
- void CMainFrame::OnUpdateRealline(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetLineStyle(pCmdUI,realline);
- }
- void CMainFrame::OnUpdateBrokenline(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetLineStyle(pCmdUI,brokenline);
- }
- void CMainFrame::OnUpdateLine(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetButtonCheck(pCmdUI,line);
- }
- void CMainFrame::OnUpdateFoldLine(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetButtonCheck(pCmdUI,linedown);
- }
- void CMainFrame::OnUpdateAngleLine(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetButtonCheck(pCmdUI,lineangle);
- }
- void CMainFrame::OnDotline()
- {
- // TODO: Add your command handler code here
- this->m_style = dotline;
- m_shape->SetBorderStyle(PS_DOT);
- m_wndTrigon.m_ComMode.SetCurSel(0);
- }
- void CMainFrame::OnUpdateDotline(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetLineStyle(pCmdUI,dotline);
- }
- void CMainFrame::OnTwoline()
- {
- // TODO: Add your command handler code here
- this->m_style = twoline;
- m_shape->SetBorderStyle(PS_DASHDOT);
- m_wndTrigon.m_ComMode.SetCurSel(1);
- }
- void CMainFrame::OnUpdateTwoline(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetLineStyle(pCmdUI,twoline);
- }
- void CMainFrame::OnUpdateRound(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetButtonCheck(pCmdUI,circle);
- }
- void CMainFrame::OnUpdateEllipse(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetButtonCheck(pCmdUI,ellipse);
- }
- void CMainFrame::OnUpdateArc(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetButtonCheck(pCmdUI,circlemater);
- }
- void CMainFrame::OnNum1()
- {
- // TODO: Add your command handler code here
- m_linewidth = one;
- m_shape->SetBorderWidth(1);
- m_wndTrigon.m_ComSize.SetCurSel(0);
- }
- void CMainFrame::OnUpdateNum1(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetNumCheck(pCmdUI,one);
- }
- void CMainFrame::OnNum2()
- {
- // TODO: Add your command handler code here
- m_linewidth = two;
- m_shape->SetBorderWidth(2);
- m_wndTrigon.m_ComSize.SetCurSel(1);
- }
- void CMainFrame::OnUpdateNum2(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetNumCheck(pCmdUI,two);
- }
- void CMainFrame::OnNum3()
- {
- // TODO: Add your command handler code here
- m_linewidth = three;
- m_shape->SetBorderWidth(3);
- m_wndTrigon.m_ComSize.SetCurSel(2);
- }
- void CMainFrame::OnUpdateNum3(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetNumCheck(pCmdUI,three);
- }
- void CMainFrame::OnNum4()
- {
- // TODO: Add your command handler code here
- m_linewidth = four;
- m_shape->SetBorderWidth(4);
- m_wndTrigon.m_ComSize.SetCurSel(3);
- }
- void CMainFrame::OnUpdateNum4(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetNumCheck(pCmdUI,four);
- }
- void CMainFrame::OnNum5()
- {
- // TODO: Add your command handler code here
- m_linewidth = five;
- m_shape->SetBorderWidth(5);
- m_wndTrigon.m_ComSize.SetCurSel(4);
- }
- void CMainFrame::OnUpdateNum5(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetNumCheck(pCmdUI,five);
- }
- void CMainFrame::OnNum6()
- {
- // TODO: Add your command handler code here
- m_linewidth = six;
- m_shape->SetBorderWidth(6);
- m_wndTrigon.m_ComSize.SetCurSel(5);
- }
- void CMainFrame::OnUpdateNum6(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetNumCheck(pCmdUI,six);
- }
- void CMainFrame::OnNum7()
- {
- // TODO: Add your command handler code here
- m_linewidth = seven;
- m_shape->SetBorderWidth(7);
- m_wndTrigon.m_ComSize.SetCurSel(6);
- }
- void CMainFrame::OnUpdateNum7(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- SetNumCheck(pCmdUI,seven);
- }
- void CMainFrame::SetButtonCheck(CCmdUI *pCmdUI, SHAPE shape)
- {
- CCAD2006Doc *m_pDoc = (CCAD2006Doc *)this->GetActiveDocument();
- if( m_pDoc->m_shape == shape )
- {
- pCmdUI->SetCheck(true);
- }
- else
- {
- pCmdUI->SetCheck(false);
- }
- }
- void CMainFrame::SetNumCheck(CCmdUI *pCmdUI, LINEWIDTH width)
- {
- if( m_linewidth == width )
- {
- pCmdUI->SetCheck(true);
- }
- else
- {
- pCmdUI->SetCheck(false);
- }
- }
- void CMainFrame::SetLineStyle(CCmdUI *pCmdUI, LINESTYLE style)
- {
- if( m_style == style )
- {
- pCmdUI->SetCheck(true);
- }
- else
- {
- pCmdUI->SetCheck(false);
- }
- }