zoukankan      html  css  js  c++  java
  • mfc | 初识mfc

    之前一直没学mfc,今天有点无聊,就看了一点。

    MFC

    本质就是对win32的封装。

    通常的配置是静态编译mfc,会方便一些。

    mfc的层次结构图

    在msdn里搜Hierarchy Chart。

    CWinApp类

    基于CWinApp的应用程序对象,程序本体,有且只能有一个。

    必须要覆盖CWinApp的虚函数InitInstance在里面创建chuangko9u并把窗口对象保存在它里面的成员变量m.pMainWnd。

    CFrameWnd类

    类似于窗口过程函数-消息处理函数。

    创建窗口是通过派生这个类。

    CFrameWnd::Create

    BOOL Create(xxxxxxxxxx);

    其中如果类名为NULL,则以MFC内奸的窗口类产生一个标准的外框窗口。

    手动编写mfc程序的几个注意事项

    1. 使用win32 application去创建工程
    2. 包含MFC运行库,设置静态编译就可以了
    3. 、使用头文件afxwin.h
    基本代码实现

    hello.cpp:

    #include <afxwin.h>
    #include "hello.h"
    
    CMyApp theApp;
    
    BOOL CMyApp::InitInstance()
    {
    	m_pMainWnd = new CMainWindow;
    	m_pMainWnd->ShowWindow(m_nCmdShow);
    	m_pMainWnd->UpdateWindow();
    	return TRUE;
    }
    
    CMainWindow::CMainWindow()
    {
    	Create(NULL,"helloMFC");
    }
    

    hello.h:

    #ifndef __HELLO_H__
    #define __HELLO_H__
    
    class CMyApp:public CWinApp
    {
    public:
    	virtual BOOL InitInstance();
    };
    
    class CMainWindow:public CFrameWnd
    {
    public:
    	CMainWindow();
    };
    
    
    #endif
    
  • 相关阅读:
    第五周总结
    第四周总结
    关于“模仿"和”创新“
    第三周总结
    第九周总结
    第八周总结
    第六周总结
    中国历史上成功的两人合作
    第五周总结
    第四周总结
  • 原文地址:https://www.cnblogs.com/Mz1-rc/p/14392615.html
Copyright © 2011-2022 走看看