zoukankan      html  css  js  c++  java
  • C++实例 单文件创建

    /*
     MENUITEM "Exit2",                        ID_APP_EXIT(执行退出命令)
    */
    
    #include <afxwin.h>
    #include "resource.h"
    
    
    class MyDocument:public CDocument
    {
        DECLARE_DYNCREATE(MyDocument) //声明run-time类别
    };
    
    IMPLEMENT_DYNCREATE(MyDocument, CDocument) //声明MyDocument为run-time类别
    
    class MyView:public CView
    {
    public:
        void OnDraw(CDC *aDC)
        {}
        
        DECLARE_DYNCREATE(MyView)
    };
    
    IMPLEMENT_DYNCREATE(MyView, CView)
    
    class MyFrame:public CFrameWnd
    {
        DECLARE_DYNCREATE(MyFrame)
    };
    
    IMPLEMENT_DYNCREATE(MyFrame, CFrameWnd)
    
    
    class MyApp:public CWinApp
    {
    public:
        BOOL InitInstance() //程序进入点
        {
            CDocument *doc; //声明指向文件的指针
            CSingleDocTemplate* DocTemplate; //声明指向单文件样版控件的指针
            DocTemplate = new CSingleDocTemplate( //建立具有单文件样版控件
                IDR_MENU1, //用于单文件框架的识别符
                RUNTIME_CLASS(MyDocument), //单文件视察的Document
                RUNTIME_CLASS(MyFrame), //单文件视窗的视窗框架
                RUNTIME_CLASS(MyView) //单文件视窗的View
                );
    
            AddDocTemplate(DocTemplate); //单文件样版控件设定给MyApp
            doc = DocTemplate->CreateNewDocument(); //建立新的文件
    
            m_pMainWnd = DocTemplate->CreateNewFrame(doc, NULL); //建立一个窗框架
    
            DocTemplate->InitialUpdateFrame((CFrameWnd*)m_pMainWnd, doc); //起始化视窗框架控件,并连结View控件
    
            m_pMainWnd->ShowWindow(SW_SHOW); //显示视窗
    
            return true;
        }
    };
    
    MyApp a_app; //建立应用程序
    学习笔记转摘于: 丝酷网 http://www.pythonschool.com/
  • 相关阅读:
    [BZOJ4034][HAOI2015]树上操作
    [BZOJ1030][JSOI2007]文本生成器
    [BZOJ2763][JLOI2011]飞行路线
    [POJ3667]Hotel
    [codevs1566]染色
    [codevs2460]树的统计
    [BZOJ2667][cqoi2012][kcoj]模拟工厂
    [NOI2009][codevs1846]KCOJ0191]植物大战僵尸
    [POJ1087]A Plug for UNIX
    Educational Round 66 题解
  • 原文地址:https://www.cnblogs.com/pythonschool/p/2956149.html
Copyright © 2011-2022 走看看