之前一直没学mfc,今天有点无聊,就看了一点。
本质就是对win32的封装。
通常的配置是静态编译mfc,会方便一些。
在msdn里搜Hierarchy Chart。
基于CWinApp的应用程序对象,程序本体,有且只能有一个。
必须要覆盖CWinApp的虚函数InitInstance在里面创建chuangko9u并把窗口对象保存在它里面的成员变量m.pMainWnd。
类似于窗口过程函数-消息处理函数。
创建窗口是通过派生这个类。
BOOL Create(xxxxxxxxxx);
其中如果类名为NULL,则以MFC内奸的窗口类产生一个标准的外框窗口。
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