020-29133788
    资 讯
    您的位置:首页 >> 资 讯 >> 软件应用 >> 编程开发 >> 正文
    MFCmodel对话盒的使用

    点击:   发布日期:2013-01-20

    本文来自 www.020fix.com
    MFCmodel对话盒的使用

    代码:
    #include <afxwin.h>
    #include "resource.h"
    #include <afxtempl.h>
    #include <afxext.h>
    #include <math.h>        //增加math标头档

    class GraphicObject : public CObject
    {        //储存形状物件的类别,衍生自CObject类别以便具备储存(Serialize)功能
    public:
            int shapenum;        //形状代号
            BOOL fill;        //是否填满
            COLORREF FillColor, LineColor;        //填满颜色与外框颜色
            int width;        //外框宽度
            CPoint StartPnt, EndPnt;        //形状的起点与终点

            GraphicObject(){}        //预设建构子
            //一般建构子
            GraphicObject(int shapenum, BOOL fill, COLORREF FillColor,
                    COLORREF LineColor,int width, CPoint StartPnt, CPoint EndPnt)
                    : shapenum(shapenum), fill(fill), FillColor(FillColor)
                    , LineColor(LineColor),width(width), StartPnt(StartPnt),
                    EndPnt(EndPnt) {}
            GraphicObject(GraphicObject & g)        //复制建构子
                    : shapenum(g.shapenum), fill(g.fill), FillColor(g.FillColor),
                    LineColor(g.LineColor),        width(g.width), StartPnt(g.StartPnt),
                    EndPnt(g.EndPnt) {}
            //过载=运算子
            GraphicObject & operator= (GraphicObject & g){
                    shapenum = g.shapenum;
                    fill = g.fill;
                    FillColor = g.FillColor;
                    LineColor = g.LineColor;
                    width = g.width;
                    StartPnt = g.StartPnt;
                    EndPnt = g.EndPnt;
                    return *this;
            }
            //GraphicObejct::Serialize
            void Serialize(CArchive & ar)
            {
                    CObject::Serialize(ar);
                    if(ar.IsStoring())        //判断是否为存档
                    {        //输出至档案
                            ar << shapenum << fill << FillColor << LineColor
                                    << width << StartPnt << EndPnt;       
                    }
                    else
                    {        //从档案输入
                            ar >> shapenum >> fill >> FillColor >> LineColor
                                    >> width >> StartPnt >> EndPnt;
                    }
            }

            DECLARE_SERIAL(GraphicObject)        //宣告为可Serialize的类别
    };
    //宣告GraphicObject为可Serialize的类别
    IMPLEMENT_SERIAL(GraphicObject, CObject, 1)

    class Shape        //形状类别的基础类别
    {
    protected:
            CPoint StartPnt, EndPnt;        //定义形状的终点与起点
            int shapenum;        //形状代号
            friend class MyView;        //将MyView设为friend类别,方便资料存取
    public:
            //建构子
            Shape(CPoint StartPnt, CPoint EndPnt, int shapenum)
                    : StartPnt(StartPnt), EndPnt(EndPnt), shapenum(shapenum) {}
            //复制建构子
            Shape(Shape & s)
                    : StartPnt(s.StartPnt), EndPnt(s.EndPnt), shapenum(s.shapenum) {}
            Shape () {}
            //过载=运算子
            Shape & operator= (Shape & s)
            {
                    StartPnt = s.StartPnt;        //设定起点
                    EndPnt = s.EndPnt;        //设定终点
                    return *this;
            }
            //Shape::draw
            virtual void draw(CDC & aDC, COLORREF color, COLORREF fcolor,
                            int width,BOOL Filled = false) = 0;
            //Shape::GetShapeNum
            int GetShapeNum()        //取得形状代号
            { return shapenum; }
            //Shape::SetPoint
            void SetPoint(CPoint SPnt, CPoint EPnt)        //设定形状的起点、终点
            {
                    StartPnt = SPnt;
                    EndPnt = EPnt;
            }
    };

    class Line : public Shape        //直线类别
    {
    public:
            friend class MyView;
            //预设建构子
            Line () { shapenum = 0;}
            //建构子
            Line(CPoint StartPnt, CPoint EndPnt) : Shape(StartPnt, EndPnt,0){}
            //复制建构子
            Line (Line & l) : Shape(l.StartPnt, l.EndPnt, 0){}
            //过载=运算子
            Line & operator= (Line & l)
            {
                    StartPnt = l.StartPnt;
                    EndPnt = l.EndPnt;
                    return *this;               
            }

            //Line::draw 绘出直线
            void draw(CDC &dc, COLORREF color, COLORREF fcolor,
                     int width, BOOL Filled = false)
            {
                    CPen pen(PS_SOLID, width, color);        //建立画笔物件
                    CPen *oldPen = dc.SelectObject(&pen);        //设定DC物件使用pen物件

                    dc.MoveTo(StartPnt);        //移至直线起点
                    dc.LineTo(EndPnt);        //移至直线终点

                    dc.SelectObject(oldPen);        //还原选取的画笔物件
            }
    };

    class ellipse : public Shape        //椭圆形类别
    {
    public:
            //预设建构子
            ellipse () { shapenum = 1; }
            //建构子
            ellipse(CPoint StartPnt, CPoint EndPnt) : Shape(StartPnt, EndPnt, 1) {}
            //复制建构子
            ellipse (ellipse & e) : Shape(e.StartPnt, e.EndPnt, 1){}
            //过载=运算子
            ellipse & operator= (ellipse & e)
            {
                    StartPnt = e.StartPnt;
                    EndPnt = e.EndPnt;
                    return *this;               
            }
            //ellipse::draw   绘出椭圆
            void draw(CDC & dc, COLORREF color, COLORREF fcolor,
                     int width,BOOL Filled = false)
            {
                    CRect rect(StartPnt, EndPnt);        //建立CRect物件
           
                    CPen pen(PS_SOLID, width, color);        //建立画笔物件
                    CPen *oldPen = dc.SelectObject(&pen);        //设定DC物件使用pen物件

                    dc.SelectStockObject(NULL_BRUSH);        //设定DC物件不使用画笔
                    dc.Ellipse(rect);        //绘出椭圆形

                    dc.SelectObject(oldPen);        //还原画笔物件
            }
    };

    class rectangle : public Shape        //矩形类别
    {
    public:
            rectangle () {shapenum = 2;}//预设建构子
            rectangle(CPoint StartPnt, CPoint EndPnt)        //建构子
                    : Shape(StartPnt, EndPnt, 2) {}
            rectangle (rectangle & r)        //复制建构子
                    : Shape(r.StartPnt, r.EndPnt, 2){}
            //过载=运算子
            rectangle & operator= (rectangle & r)        //过载=运算子
            {
                    StartPnt = r.StartPnt;
                    EndPnt = r.EndPnt;
                    return *this;               
            }
            //rectangle        ::draw                绘出矩形
            void draw(CDC & dc, COLORREF color, COLORREF fcolor,
                     int width, BOOL Filled = false)
            {
                    CRect rect(StartPnt, EndPnt);        //建立CRect物件

                    CPen pen(PS_SOLID, width , color);        //建立画笔物件
                    CPen *oldPen = dc.SelectObject(&pen);        //设定DC物件使用pen物件
                   
                    dc.SelectStockObject(NULL_BRUSH);        //设定DC物件不使用无画刷
                    dc.Rectangle(rect);        //绘出矩形

                    dc.SelectObject(oldPen);        //还原画笔物件
            }
    };

    class MyDocument : public CDocument
    {
    private:
            CArray<GraphicObject , GraphicObject> gArray;
                    //储存GraphicObject物件的CArray容器物件
    public:
            MyDocument() {}
            //MyDocument::AddObject
            void AddObject(GraphicObject & g)        //增加GraphicObject物件
            {
                    SetModifiedFlag(true);        //设定档案已被修改
                    gArray.Add(g);
            }
            //MyDocument::GetObject 取得容器中第i个GraphicObject物件
            GraphicObject & GetObject(int i){ return gArray[i]; }
            //MyDocument::GetSize
            int GetSize()        //取得CArray容器目前储存的元素数目
            { return gArray.GetSize(); }
            //MyDoucment::Serialize
            void Serialize(CArchive & ar)
            {
                    CObject::Serialize(ar);        //呼叫CObject::Serialize
                    gArray.Serialize(ar);        //呼叫CArray::Serialize储存容器中的元素
            }
            //MyDocument::DeleteContents
            void DeleteContents()
            {
                    gArray.RemoveAll();        //删除容器中所有元素
                    CDocument::DeleteContents();        //呼叫CDocument::DeleteContents
            }

            DECLARE_DYNCREATE(MyDocument)
            DECLARE_MESSAGE_MAP()
    };

    IMPLEMENT_DYNCREATE(MyDocument, CDocument)

    BEGIN_MESSAGE_MAP(MyDocument, CDocument)

    END_MESSAGE_MAP()

    class MyFrame : public CFrameWnd        //视窗框架类别
    {
    protected:
            CMenu * menu;
    public:
            CToolBar toolbar;        //视窗框架中的工具列物件
            CStatusBar statusbar;        //视窗框架中的状态列物件
            //建构子与解构子
            MyFrame(){}
            ~MyFrame(){}
            //MyFrame::OnCreate,回应OnCreate的函数
            afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
            {
                    if(CFrameWnd::OnCreate(lpCreateStruct))
                            return 1;

                    toolbar.Create(this);        //建立工具列物件
                    toolbar.LoadToolBar(IDR_MyFrame);        //载入工具列资源
                    toolbar.EnableDocking(CBRS_ALIGN_ANY);
                                    //设定工具列在视窗中可停靠的位置
                    toolbar.SetBarStyle( toolbar.GetBarStyle() | CBRS_TOOLTIPS |
                            CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
                                    //设定工具列的形式
                    EnableDocking(CBRS_ALIGN_ANY);        //设定视窗可让工具列停靠的位置
                    DockControlBar(&toolbar);        //将工具列加入视窗框架

                    //建立与状态列对应之字串资源代号
                    static UINT indicators[] =
                    {
                            ID_SEPARATOR,       
                            IDS_Color,
                            IDS_Shape,
                            IDS_Width        //显示笔宽
                    };

                    statusbar.Create(this);        //在目前的视窗框架里,建立一个状态列
                    statusbar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT));
                                    //连结状态列栏位与字串资源代号
                    return 0;
            }

            DECLARE_DYNCREATE(MyFrame)        //宣告为Run-Time类别
            DECLARE_MESSAGE_MAP()
    };

    IMPLEMENT_DYNCREATE(MyFrame, CFrameWnd)
                    //宣告MyFrame为Run-Time类别
    BEGIN_MESSAGE_MAP(MyFrame, CFrameWnd)
            ON_WM_CREATE()        //回应建立视窗的讯息
    END_MESSAGE_MAP()

    class MyView : public CView
    {
    private:
            COLORREF lcolor, fcolor;
            //lcolor为形状外框的颜色,fcolor为填满形状内部的颜色
            Shape* aShape;        //指向欲绘制之形状类别的物件指标
            Shape* rdShape;        //rdShape为重绘视窗时,从Document中取得形状物件
            int width; //形状的外框宽度
    public:
            //建构子
            MyView()
            {
                    lcolor = RGB(255,0,0);        //设定外框颜色的起始值
                    aShape = new Line;        //设定形状的起始值
                    fcolor = RGB(0,0,0); //设定填满颜色的起始值
                    width = 2; //形状的外框宽度的起始值
            }
            //解构子
            ~MyView() { }
            //MyView::GetWidth
            int GetWidth() { return width;}        //传出MyView物件设定的笔宽
            //MyView::OnSetWidth
            afx_msg void OnSetWidth();        //定义函数的程式片段在SWidthDlg类别后
            //MyView::OnEllipse
            afx_msg void OnEllipse()
            {
                    aShape = new ellipse;        //产生椭圆形物件
                    ((MyFrame *)GetParentFrame())->statusbar.SetPaneText(2,"Ellipse");
                    //设定状态列IDS_Shape栏位的显示文字
            }
            //MyView::OnRect
            afx_msg void OnRect()       
            {
                    aShape = new rectangle;        //产生矩形物件
                    ((MyFrame *)GetParentFrame())->statusbar.SetPaneText(2,"Rectangle");
                    //设定状态列IDS_Shape栏位的显示文字
            }
            //MyView::OnLine
            afx_msg void OnLine()
            {
                    aShape = new Line;        //产生直线物件
                    ((MyFrame *)GetParentFrame())->statusbar.SetPaneText(2,"Line");
                    //取得Document物件,并呼叫CStatusBar::SetPaneText设定状态列
                    //IDS_Shape栏位的显示文字
            }
            //MyView::OnDraw
            afx_msg void OnDraw(CDC * aDC)        //回应重绘视窗讯息的函数
            {       
                    MyDocument *doc = (MyDocument *)GetDocument();
                            //取得目前的Document物件
                    int num = doc->GetSize();        //取得目前Document物件中储存的形状物件个数
                    CView::OnDraw(aDC);        //呼叫CView类别的OnDraw成员函数
                   
                    int i;

                    for(i = 0; i < num; ++i)        //取得储存于Document物件中的形状物件
                    {
                            GraphicObject * object = &(doc->GetObject(i));
                                    //建立指向绘图物件的指标,并指向由Document物件中的形状物件
                            switch(object->shapenum){        //判别从Document物件取得哪种形状物件
                            case 0:                //然后,产生建立适当的形状物件
                                    rdShape = new Line;
                                    break;
                            case 1:
                                    rdShape = new ellipse;
                                    break;
                            case 2:
                                    rdShape = new  rectangle;
                                    break;                       
                            };

                            rdShape->SetPoint(object->StartPnt, object->EndPnt);
                                    //建立形状物件的起点与终点
                            rdShape->draw((*aDC),object->LineColor, object->FillColor,
                                              object->width);        //绘出形状物件

                            delete rdShape;        //删除前面产生的形状物件
                    }       
            }
            //MyView::OnLButtonDown
            afx_msg void OnLButtonDown(UINT, CPoint point)
            {
                    SetCapture();        //取得滑鼠讯息的接收权
                    if (this == GetCapture())        //判断滑鼠游标是否在正在执行的视窗中
                            (*aShape).StartPnt = (*aShape).EndPnt = point;
                            //设定形状物件的起点、终点
            }
            //MyView::OnMouseMove
            afx_msg void OnMouseMove(UINT, CPoint point)
            {
                    if (this == GetCapture())        //判断滑鼠游标是否在正在执行的视窗中
                    {
                            CClientDC aDC(this);        //建立画布
                            aDC.SetROP2(R2_NOT);        //设定绘图模式

                            (*aShape).draw(aDC, lcolor, fcolor, width);        //画出形状物件
                            (*aShape).EndPnt = point;        //设定终点
                            (*aShape).draw(aDC, lcolor, fcolor, width);        //再画出形状物件
                    }
            }
            //MyView::OnLButtonUp
            afx_msg void OnLButtonUp(UINT, CPoint point)
            {
                    if (this == GetCapture())        //判断滑鼠游标是否在正在执行的视窗中
                    {
                            CClientDC aDC(this);        //建立画布

                            (*aShape).EndPnt = point;
                            //设定形状物件的终点
                            (*aShape).draw(aDC, lcolor, fcolor, width);        //画出形状物件
                           
                            GraphicObject object(aShape->GetShapeNum(), true,
                                    fcolor, lcolor, width,aShape->StartPnt,aShape->EndPnt);
                    //建立GraphicObject物件,以储存绘于视窗工作区的形状物件
                            MyDocument *doc = (MyDocument *)GetDocument();
                            //取得目前的Document物件
                            doc->AddObject(object);        //将GraphicObject物件储存进Document物件
                           
                            ReleaseCapture();        //释放滑鼠讯息接收权
                    }                       
            }
            //MyView::OnRed
            afx_msg void OnRed()
            {
                    lcolor = RGB(255, 0, 0);        //设定图形外框为红色
                    ((MyFrame *)GetParentFrame())->statusbar.SetPaneText(1,"Red");
                    //设定状态列IDS_Color栏位的显示文字
            }
            //MyView::OnBlue
            afx_msg void OnBlue()
            {
                    lcolor = RGB(0, 0, 255);        //设定图形外框为蓝色
                    ((MyFrame *)GetParentFrame())->statusbar.SetPaneText(1,"Blue");
                    //设定状态列IDS_Color栏位的显示文字
            }
            //MyView::OnGreen
            afx_msg void OnGreen()
            {
                    lcolor = RGB(0, 255, 0);        //设定图形外框为绿色
                    ((MyFrame *)GetParentFrame())->statusbar.SetPaneText(1,"Green");
                    //设定状态列IDS_Color栏位的显示文字
            }
            //控制设定形状物件的UI元件
            //MyView::OnUpdateEllipse
            afx_msg void OnUpdateEllipse(CCmdUI * aCmdUI)
            { aCmdUI->SetCheck((*aShape).shapenum == 1); }
            //MyView::OnUpdateRect
            afx_msg void OnUpdateRect(CCmdUI * aCmdUI)
            { aCmdUI->SetCheck((*aShape).shapenum == 2); }
            //MyView::OnUpdateLine
            afx_msg void OnUpdateLine(CCmdUI * aCmdUI)
            { aCmdUI->SetCheck((*aShape).shapenum == 0); }

            //控制设定形状物件的UI元件
            //MyView::OnUpdateRed
            afx_msg void OnUpdateRed(CCmdUI * aCmdUI)
            { aCmdUI->SetCheck(lcolor == RGB(255, 0, 0)); }
            //MyView::OnUpdateGreen
            afx_msg void OnUpdateGreen(CCmdUI * aCmdUI)
            { aCmdUI->SetCheck(lcolor == RGB(0, 255, 0)); }
            //MyView::OnUpdateBlue
            afx_msg void OnUpdateBlue(CCmdUI * aCmdUI)
            { aCmdUI->SetCheck(lcolor == RGB(0, 0, 255)); }

            DECLARE_DYNCREATE(MyView)        //宣告Run-Time物件
            DECLARE_MESSAGE_MAP()
    };

    IMPLEMENT_DYNCREATE(MyView, CView)
            //宣告MyView为Run-Time物件

    BEGIN_MESSAGE_MAP(MyView, CView)
            ON_COMMAND(IDM_Width, OnSetWidth)        //设定笔宽
            //回应滑鼠讯息
            ON_WM_LBUTTONDOWN()
            ON_WM_MOUSEMOVE()
            ON_WM_LBUTTONUP()
            //回应颜色控制命令讯息
            ON_COMMAND(IDM_Red, OnRed)
            ON_COMMAND(IDM_Green, OnGreen)
            ON_COMMAND(IDM_Blue, OnBlue)
            //回应形状控制命令讯息
            ON_COMMAND(IDM_Line, OnLine)
            ON_COMMAND(IDM_Ellipse, OnEllipse)
            ON_COMMAND(IDM_Rect, OnRect)
            //回应UI元件状态控制讯息
            ON_UPDATE_COMMAND_UI(IDM_Red, OnUpdateRed)
            ON_UPDATE_COMMAND_UI(IDM_Green, OnUpdateGreen)
            ON_UPDATE_COMMAND_UI(IDM_Blue, OnUpdateBlue)
            ON_UPDATE_COMMAND_UI(IDM_Line, OnUpdateLine)
            ON_UPDATE_COMMAND_UI(IDM_Ellipse, OnUpdateEllipse)
            ON_UPDATE_COMMAND_UI(IDM_Rect, OnUpdateRect)
    END_MESSAGE_MAP()

    class SWidthDlg : public CDialog        //与IDD_SWidthDlg对话盒对应之类别
    {
    private:
            int width;        //笔宽
            CEdit * wEdit;        //编辑控制项物件
    public:
            //建构子
            SWidthDlg(CWnd *parent) : CDialog(IDD_SWidthDlg, parent)
                            //将IDD_SWidthDlg对话盒与SWidthDlg类别连结
            { width = 2; }
            //SWidthDlg::Getwidth 传出使用者设定之栏宽
            int GetWidth() { return width;}
            //SWidthDlg::OnInitDialog IDD_SWidthDlg对话盒起始设定
            BOOL OnInitDialog()
            {
                    char strWidth[5];
           
                    CDialog::OnInitDialog();        //呼叫CDialog::OnInitDialog

                    wEdit = (CEdit *)GetDlgItem(IDC_Width);
                            //将IDD_SWidthDlg对话盒的IDC_Width编辑控制项与wEdit物件连结

                    MyView *view = (MyView *)m_pParentWnd;
                    //取得目前的View物件

                    wsprintf(strWidth, "%d", view->GetWidth());
                            //将目前View物件设定的笔宽输出strWidth字串中

                    wEdit->ReplaceSel(strWidth);
                    //将View物件目前设定的笔宽显示在IDC_Width编辑控制项中
           
                    return TRUE;
            }
            //SWidthDlg::OnOK
            void OnOK()
            {
                    CString strWidth;
                    wEdit->GetWindowText(strWidth);        //取得使用者设定的笔宽

                    try{
                            width = StrToInt(strWidth);        //将目前的笔宽由文字转换为数字

                            if (width > 20)        //如果笔宽大于20则都出例外
                                    throw ("Width is greater than 20.");       
                           
                            CDialog::OnOK();        //呼叫CDialog::OnOK
                    }
                    catch(const char * str)        //如果产生字串例外,则蹦现显示错误讯息的讯息方块
                    { MessageBox(str,"Input Error", MB_OK);        }                               
            }
            //SWidthDlg::StrToInt
            int StrToInt(CString & str)
            {
                    int len = str.GetLength();        //先取得字串长度,做为数字位数
                    int res = 0;        //转换结果

                    for (int i = 0; i < len; ++i)
                    {
                            switch(str[i])        //将字串的每个文字至换成数字
                            {
                            case '0':
                                    break;
                            case '1':       
                                    res += (int) pow(10, (len-i-1)) * 1;
                                                    //将取得的数字,乘以其位数
                                    break;
                            case '2':
                                    res += (int) pow(10, (len-i-1)) * 2;
                                    break;
                            case '3':
                                    res += (int) pow(10, (len-i-1)) * 3;
                                    break;
                            case '4':
                                    res += (int) pow(10, (len-i-1)) * 4;
                                    break;
                            case '5':
                                    res += (int) pow(10, (len-i-1)) * 5;
                                    break;       
                            case '6':
                                    res += (int) pow(10, (len-i-1)) * 6;
                                    break;
                            case '7':
                                    res += (int) pow(10, (len-i-1)) * 7;
                                    break;
                            case '8':
                                    res += (int) pow(10, (len-i-1)) * 8;
                                    break;
                            case '9':
                                    res += (int) pow(10, (len-i-1)) * 9;
                                    break;
                            case'-':        //如果读取到负号,则丢例外
                                    throw ("Don't input a nagtive number.");
                                    break;
                            }
                    }
                    return res;        //传回转换结果
            }
    };
    //MyView::OnSetWidth
    afx_msg void MyView::OnSetWidth()
    {
            SWidthDlg dlg(this);
                    //建立设定笔宽的对话盒物件,并传入父视窗物件
            char str[10];
           
            if (dlg.DoModal() == IDOK)        //使用者若按下确定按钮则传出IDOK
            {
                    width = dlg.GetWidth();        //取得使用者设定的笔宽
                    wsprintf(str, "Width : %d ", width);        //将笔宽输出到str字串
                    ((MyFrame *)GetParentFrame())->statusbar.SetPaneText(3,str);
                            //设定状态列的IDS_Width栏位
            }
    }

    class MyApp : public CWinApp        //应用程式物件
    {
    public:
            BOOL InitInstance()
            {
                    CDocument *aDOC;
                    CSingleDocTemplate *aDocTemplate;
                    aDocTemplate = new CSingleDocTemplate(        //建立单一文件框架
                                    IDR_MyFrame,
                                    RUNTIME_CLASS(MyDocument),
                                    RUNTIME_CLASS(MyFrame),
                                    RUNTIME_CLASS(MyView));
                    AddDocTemplate(aDocTemplate);
                                    //将单一文件框架加入应用程式物件
                    aDOC = aDocTemplate->CreateNewDocument();
                                    //建立Document物件
                    CFrameWnd *Frame = aDocTemplate->CreateNewFrame(aDOC, NULL);
                                    //建立视窗框架物件
                    m_pMainWnd = Frame;        //建立应用程式物件使用之视窗框架                               
                    aDocTemplate->InitialUpdateFrame(Frame, aDOC);
                                    //起始化View物件
                    Frame->ShowWindow(SW_SHOW);
                                    //显示视窗框架
                    return true;
            }

            DECLARE_MESSAGE_MAP()
    } a_app;        //应用程式物件

    BEGIN_MESSAGE_MAP(MyApp, CWinApp)
            ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)        //开启新档
            ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)        //开启旧档
    END_MESSAGE_MAP()