www.pudn.com > zcColor.rar > MainFrm.cpp, change:2001-07-27,size:1942b


//////////////////////////////////////////////////////////////// 
// VCDKBASE Online Journal -- July 2001 
// Compiles with Visual C++ 6.0. Runs on Win 98 and probably Win 2000 too. 
// Set tabsize = 3 in your editor. 
// 
#include "StdAfx.h" 
#include "MainFrm.h" 
#include "Resource.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
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); 
	 
	// Create and load toolbar 
	// 
	VERIFY(m_wndToolBar.CreateEx(this)); 
	VERIFY(m_wndToolBar.LoadToolBar(IDR_MAINFRAME)); 
 
	// Load tollbar bitmap -- must use ::LoadImage to map colors 
	// This will map (192,192,192) to 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); 
 
	// Create image list and set in toolbar. 
	// Must use ILC_COLOR8 for 256-color images! 
	// 
	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; 
}