// CDrawApp消息处理程序
// 用于应用程序“关于”菜单项的CAboutDlg对话框 classCAboutDlg : public CDialogEx { public:
CAboutDlg(); // 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); 持
// 实现 protected: DECLARE_MESSAGE_MAP()
public:
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) { }
voidCAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
ON_WM_MOUSEMOVE() END_MESSAGE_MAP()
// 用于运行对话框的应用程序命令 voidCDrawApp::OnAppAbout() { CAboutDlgaboutDlg; aboutDlg.DoModal();
}
21
// DDX/DDV 支
MainFrm.cpp代码
// MainFrm.cpp : CMainFrame类的实现 #ifdef _DEBUG
#define new DEBUG_NEW #endif // CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) constintiMaxUserToolbars = 10;
const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40; const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1; BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_CREATE() END_MESSAGE_MAP() static UINT indicators[] = {
ID_SEPARATOR, // 状态行指示器 ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, };
// CMainFrame构造/析构 CMainFrame::CMainFrame() {
// TODO: 在此添加成员初始化代码 }
CMainFrame::~CMainFrame() { }
intCMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
22
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |
WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || { }
if (!m_wndStatusBar.Create(this)) { }
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // TODO: 如果不需要可停靠工具栏,则删除这三行 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return 0; }
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT&cs) {
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE; // TODO: 在此处通过修改
// CREATESTRUCT cs来修改窗口类或样式 return TRUE; }
// CMainFrame诊断 #ifdef _DEBUG
voidCMainFrame::AssertValid() const {
CFrameWnd::AssertValid();
23
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) TRACE0(\未能创建工具栏\\n\return -1; // 未能创建
TRACE0(\未能创建状态栏\\n\return -1; // 未能创建
}
voidCMainFrame::Dump(CDumpContext& dc) const {
CFrameWnd::Dump(dc); }
#endif //_DEBUG
// CMainFrame消息处理程序
Graph.h代码
// Graph.cpp : 实现文件 //
#include \#include \#include \// CGraph
IMPLEMENT_DYNAMIC(CGraph, CWnd)
CGraph::CGraph(intm_nDrawType, intm_nxiankuan, COLORREF m_clr, CPointm_ptOrign, CPointm_ptEnd)
{ }
CGraph::CGraph() { }
CGraph::~CGraph() { }
BEGIN_MESSAGE_MAP(CGraph, CWnd) END_MESSAGE_MAP()
24
this->m_nDrawType = m_nDrawType; this->m_ptOrign = m_ptOrign; this->m_ptEnd = m_ptEnd; this->m_nxiankuan = m_nxiankuan; this->m_clr = m_clr;
// CGraph消息处理程序
DrawDoc.cpp代码
// DrawDoc.cpp : CDrawDoc类的实现
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的 // ATL 项目中进行定义,并允许与该项目共享文档代码。 #ifndef SHARED_HANDLERS #include \#endif
#include \#include
#define new DEBUG_NEW #endif // CDrawDoc
IMPLEMENT_DYNCREATE(CDrawDoc, CDocument) BEGIN_MESSAGE_MAP(CDrawDoc, CDocument) END_MESSAGE_MAP() // CDrawDoc构造/析构 CDrawDoc::CDrawDoc() { }
CDrawDoc::~CDrawDoc() { }
BOOL CDrawDoc::OnNewDocument() {
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: 在此添加重新初始化代码 // (SDI 文档将重用该文档) return TRUE;
25
// TODO: 在此添加一次性构造代码