分类:
2008-10-13 16:09:09
MainFrm.cpp //////////////////////////////////////////////////////////////// // Set tabsize = 3 in your editor. // #include "StdAfx.h" #include "MainFrm.h" #include "Resource.h" BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_CREATE() END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; CMainFrame::CMainFrame() { } CMainFrame::~CMainFrame() { } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { cs.style |= WS_CLIPCHILDREN; return CFrameWnd::PreCreateWindow(cs); } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { VERIFY(CFrameWnd::OnCreate(lpCreateStruct)==0); //创建并加载工具栏 // VERIFY(m_wndToolBar.Create(this)); VERIFY(m_wndToolBar.LoadToolBar(IDR_MAINFRAME)); // 加载工具栏位图 - 必须使用::LoadImage映射颜色 // 将(192,192,192) 映射到 COLOR_3DFACE. // HBITMAP hbm = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_BITMAP, 0,0, // cx,cy LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS ); CBitmap bm; bm.Attach(hbm); // 创建图像清单并设置工具栏 // 256色图像必须使用ILC_COLOR8! // m_ilToolBar.Create(20,20, ILC_COLOR8, 4, 4); m_ilToolBar.Add(&bm,(CBitmap*)NULL); m_wndToolBar.GetToolBarCtrl().SetImageList(&m_ilToolBar); VERIFY(m_wndStatusBar.Create(this)); VERIFY(m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))); VERIFY(m_wndView.Create(_T("Press a button, any button."), WS_VISIBLE|WS_CHILD|SS_CENTERIMAGE|SS_CENTER, CRect(0,0,0,0), this, AFX_IDW_PANE_FIRST)); return 0; }