MainFrm.cpp
上传用户:shangwu01
上传日期:2013-04-22
资源大小:707k
文件大小:9k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "CAD.h"
- #include "MainFrm.h"
- #include "CADDoc.h"
- #include "DLG_LineWSet.h"
- #include "Splash.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
- ON_CBN_SELCHANGE(IDC_COMBO3, OnSelchangeCombo3)
- ON_COMMAND(IDM_VIEW_DRAWBAR, OnViewDrawbar)
- ON_UPDATE_COMMAND_UI(IDM_VIEW_DRAWBAR, OnUpdateViewDrawbar)
- ON_COMMAND(IDM_VIEW_CATCHBAR, OnViewCatchbar)
- ON_UPDATE_COMMAND_UI(IDM_VIEW_CATCHBAR, OnUpdateViewCatchbar)
- ON_WM_TIMER()
- ON_WM_PAINT()
- ON_WM_SHOWWINDOW()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
-
-
-
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- CSplashWnd::ShowSplashScreen(this);
-
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.CreateEx(this) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndDrawTool.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |CBRS_ALIGN_LEFT
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndDrawTool.LoadToolBar(IDR_TOOLBAR1))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndCatchTool.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |CBRS_ALIGN_BOTTOM
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndCatchTool.LoadToolBar(IDR_TOOLBAR2))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndDlgBar.Create(this, IDR_MAINFRAME,
- CBRS_ALIGN_RIGHT, AFX_IDW_DIALOGBAR))
- {
- TRACE0("Failed to create dialogbarn");
- return -1; // fail to create
- }
- if (!m_wndReBar.Create(this) ||
- !m_wndReBar.AddBar(&m_wndToolBar) ||
- !m_wndReBar.AddBar(&m_wndDlgBar))
- {
- TRACE0("Failed to create rebarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- // TODO: Remove this if you don't want tool tips
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY);
- m_wndDrawTool.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_LEFT);
- DockControlBar(&m_wndDrawTool);
-
- m_wndCatchTool.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_BOTTOM);
- DockControlBar(&m_wndCatchTool);
-
- // this->ShowWindow(SW_SHOWMAXIMIZED);
- SetTimer(1,1000,NULL);
-
- /////////////////////// combobox /////////////////////////////////////////
- // ((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->AddString("");
- ((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO1))->SetCurSel(0);
- ((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO2))->SetCurSel(0);
- ((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->SetCurSel(0);
- ///
- /* CComboBoxEx *pCombo=(CComboBoxEx *)(m_wndDlgBar.GetDlgItem(IDC_COMBOBOXEX2));
- m_imageList.Create(32,16,ILC_MASK,8,4);
- CBitmap bitmap;
- bitmap.LoadBitmap(IDB_BITMAP1);
- m_imageList.Add(&bitmap,RGB(0,0,255));
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_BITMAP2);
- m_imageList.Add(&bitmap,RGB(0,0,255));
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_BITMAP3);
- m_imageList.Add(&bitmap,RGB(0,0,255));
- bitmap.DeleteObject();
- bitmap.LoadBitmap(IDB_BITMAP4);
- m_imageList.Add(&bitmap,RGB(0,0,255));
- bitmap.DeleteObject();
-
- pCombo->SetImageList(&m_imageList);
- COMBOBOXEXITEM cbi;
- cbi.mask=CBEIF_IMAGE|CBEIF_SELECTEDIMAGE|CBEIF_INDENT;
- CString strTemp;
- int nBitmapCount=0;
- for(int nCount=0;nCount<4;nCount++)
- {
- cbi.iItem=nCount;
- cbi.pszText=(LPTSTR)(LPCTSTR)strTemp;
- cbi.cchTextMax=256;
- pCombo->GetItem(&cbi);
- cbi.iImage=nBitmapCount;
- cbi.iSelectedImage=nBitmapCount++;
- cbi.iIndent=(nCount&0x03);
- pCombo->SetItem(&cbi);
- }
- */
- //////////////////////////////////////////////////////////////////////////
- // CG: The following line was added by the Splash Screen component.
- 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
- cs.cy = ::GetSystemMetrics(SM_CYSCREEN);
- cs.cx = ::GetSystemMetrics(SM_CXSCREEN);
- cs.y = ::GetSystemMetrics(SM_CYSCREEN);
- cs.x = ::GetSystemMetrics(SM_CYSCREEN);
- cs.lpszClass=AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,0,0,AfxGetApp()->LoadIcon(IDI_ICON1));
- 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
- void CMainFrame::OnSelchangeCombo2()
- {
- CCADDoc* pDoc = (CCADDoc*)GetActiveDocument();
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO2))->GetCurSel()==0)
- pDoc->m_line_width=1;
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO2))->GetCurSel()==1)
- pDoc->m_line_width=2;
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO2))->GetCurSel()==2)
- pDoc->m_line_width=3;
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO2))->GetCurSel()==3)
- pDoc->m_line_width=4;
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO2))->GetCurSel()==4)
- {
- CDLG_LineWSet dlg;
- if(dlg.DoModal()==IDOK)
- pDoc->m_line_width=dlg.m_LineSet;
- }
-
-
- }
- //DEL void CMainFrame::OnSelchangeComboboxex1()
- //DEL {
- //DEL // this->MessageBox("");
- //DEL
- //DEL
- //DEL }
- //DEL void CMainFrame::OnSelchangeComboboxex2()
- //DEL {
- //DEL /* COMBOBOXEXITEM cbi;
- //DEL CString str;
- //DEL CComboBoxEx *pCombo=(CComboBoxEx *)(m_wndDlgBar.GetDlgItem(IDC_COMBOBOXEX2));
- //DEL int nSel=pCombo->GetCurSel();
- //DEL cbi.iItem=nSel;
- //DEL cbi.pszText=(LPTSTR)(LPCTSTR)str;
- //DEL cbi.mask=CBEIF_TEXT;
- //DEL cbi.cchTextMax=str.GetLength();
- //DEL pCombo->GetItem(&cbi);
- //DEL return;*/
- //DEL
- //DEL }
- void CMainFrame::OnSelchangeCombo1()
- {
- CCADDoc* pDoc = (CCADDoc*)GetActiveDocument();
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO1))->GetCurSel()==0)
- pDoc->m_line_style=PS_SOLID;
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO1))->GetCurSel()==1)
- pDoc->m_line_style=PS_DASH;
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO1))->GetCurSel()==2)
- pDoc->m_line_style=PS_DASHDOT;
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO1))->GetCurSel()==3)
- pDoc->m_line_style=PS_DASHDOTDOT;
- }
- void CMainFrame::OnSelchangeCombo3()
- {
- CCADDoc* pDoc = (CCADDoc*)GetActiveDocument();
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->GetCurSel()==0)
- pDoc->m_line_color=RGB(0,0,0);
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->GetCurSel()==1)
- pDoc->m_line_color=RGB(255,0,0);
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->GetCurSel()==2)
- pDoc->m_line_color=RGB(0,255,0);
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->GetCurSel()==3)
- pDoc->m_line_color=RGB(0,0,255);
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->GetCurSel()==4)
- pDoc->m_line_color=RGB(255,255,255);
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->GetCurSel()==5)
- pDoc->m_line_color=RGB(255,255,0);
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->GetCurSel()==6)
- pDoc->m_line_color=RGB(0,255,255);
- if(((CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO3))->GetCurSel()==7)
- {
- CColorDialog dlg;
- if(dlg.DoModal()==IDOK)
- pDoc->m_line_color=dlg.GetColor();
- }
-
- }
- void CMainFrame::OnViewDrawbar()
- {
- ShowControlBar(&m_wndDrawTool,!m_wndDrawTool.IsWindowVisible(),false);
-
- }
- void CMainFrame::OnUpdateViewDrawbar(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_wndDrawTool.IsWindowVisible());
- }
- void CMainFrame::OnViewCatchbar()
- {
- ShowControlBar(&m_wndCatchTool,!m_wndCatchTool.IsWindowVisible(),false);
-
- }
- void CMainFrame::OnUpdateViewCatchbar(CCmdUI* pCmdUI)
- {
-
- pCmdUI->SetCheck(m_wndCatchTool.IsWindowVisible());
-
- }
- void CMainFrame::OnTimer(UINT nIDEvent)
- {
- static BOOL show=true;
- if(show)
- {
- int cscy = ::GetSystemMetrics(SM_CYSCREEN) / 5*4;
- int cscx = ::GetSystemMetrics(SM_CXSCREEN) / 5*4;
- int csy = cscy/7;
- int csx = cscx/7;
-
- this->MoveWindow(csx,csy,cscx,cscy);
- this->ShowWindow(SW_SHOWMAXIMIZED);
- show=false;
- }
-
-
- // CFrameWnd::OnTimer(nIDEvent);
- }
- void CMainFrame::OnPaint()
- {
- CPaintDC dc(this);
- //this->ShowWindow(SW_SHOWMINIMIZED);
-
-
- }
- void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- /* static bool show=true;
- if(show)
- {
- this->ShowWindow(SW_SHOWMINIMIZED);
- }
- */
-
-
-
- }