www.pudn.com > GandyDraw_MFC.rar > MainFrm.cpp, change:2006-11-11,size:3060b


// MainFrm.cpp : CMainFrame 类的实现 
// 
 
#include "stdafx.h" 
#include "GandyDraw.h" 
 
#include "MainFrm.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#endif 
 
 
// CMainFrame 
 
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) 
 
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) 
	ON_WM_CREATE() 
END_MESSAGE_MAP() 
 
static UINT indicators[] = 
{ 
	ID_SEPARATOR,   // 状态行指示器 
	ID_SEPARATOR, 
	ID_SEPARATOR, 
	ID_SEPARATOR, 
	ID_SEPARATOR, 
	ID_SEPARATOR, 
	ID_SEPARATOR, 
	ID_SEPARATOR, 
	ID_SEPARATOR, 
}; 
 
 
// CMainFrame 构造/析构 
 
CMainFrame::CMainFrame() 
{ 
	// TODO: 在此添加成员初始化代码 
} 
 
CMainFrame::~CMainFrame() 
{ 
} 
 
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	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("未能创建工具栏\n"); 
		return -1;      // 未能创建 
	} 
	// TODO 绘图风格工具栏的创建 
	if (!m_ToolBar_ds.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |  
	CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY |  
	CBRS_SIZE_DYNAMIC) || !m_ToolBar_ds.LoadToolBar(IDR_DRAWSTYLE)) 
	{ 
		TRACE0("未能创建工具栏\n"); 
		return -1;      // 未能创建 
	} 
 
 
 
	if (!m_wndStatusBar.Create(this) || 
		!m_wndStatusBar.SetIndicators(indicators, 
		  sizeof(indicators)/sizeof(UINT))) 
	{ 
		TRACE0("未能创建状态栏\n"); 
		return -1;      // 未能创建 
	} 
 
	// TODO: 如果不需要工具栏可停靠,则删除这三行 
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 
	EnableDocking(CBRS_ALIGN_ANY); 
	DockControlBar(&m_wndToolBar); 
 
	m_ToolBar_ds.EnableDocking(CBRS_ALIGN_ANY); 
	EnableDocking(CBRS_ALIGN_ANY); 
	DockControlBar(&m_ToolBar_ds); 
 
 
	m_wndStatusBar.SetPaneInfo(0, prompt, SBPS_STRETCH,0); // 提示 
 
	m_wndStatusBar.SetPaneInfo(1, xName, SBPS_NOBORDERS, 8); // "x:"	 
	m_wndStatusBar.SetPaneText(xName, L"x:"); 
	m_wndStatusBar.SetPaneInfo(2, xVal, SBPS_NORMAL, 24); // x值 
	m_wndStatusBar.SetPaneInfo(3, yName, SBPS_NOBORDERS, 8); // "y:" 
	m_wndStatusBar.SetPaneText(yName, L"y:"); 
	m_wndStatusBar.SetPaneInfo(4, yVal, SBPS_NORMAL, 24); // y值 
 
	m_wndStatusBar.SetPaneInfo(5, dxName, SBPS_NOBORDERS, 8); // "dx:" 
	m_wndStatusBar.SetPaneText(dxName, L"dx:"); 
	m_wndStatusBar.SetPaneInfo(6, dxVal, SBPS_NORMAL, 24); // dx值 
	m_wndStatusBar.SetPaneInfo(7, dyName, SBPS_NOBORDERS, 8); // "dy:" 
	m_wndStatusBar.SetPaneText(dyName, L"dy:"); 
	m_wndStatusBar.SetPaneInfo(8, dyVal, SBPS_NORMAL, 24); // dy值 
 
 
 
	return 0; 
} 
 
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	if( !CFrameWnd::PreCreateWindow(cs) ) 
		return FALSE; 
	// TODO: 在此处通过修改 
	//  CREATESTRUCT cs 来修改窗口类或样式 
 
	return TRUE; 
} 
 
 
// CMainFrame 诊断 
 
#ifdef _DEBUG 
void CMainFrame::AssertValid() const 
{ 
	CFrameWnd::AssertValid(); 
} 
 
void CMainFrame::Dump(CDumpContext& dc) const 
{ 
	CFrameWnd::Dump(dc); 
} 
 
#endif //_DEBUG 
 
 
// CMainFrame 消息处理程序