代码如下
文件1:stdafx.cpp
#include "stdafx.h"
文件2:stdafx.h
#include <afxwin.h>
文件3:minMFCwin.cpp
#include "stdafx.h"
class CMfcApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};
CMfcApp theApp;
class CMainFrame : public CFrameWnd
{
public:
CMainFrame();
};
BOOL CMfcApp::InitInstance()
{
m_pMainWnd = new CMainFrame();
m_pMainWnd ->ShowWindow(SW_SHOW);
m_pMainWnd ->UpdateWindow();
return TRUE;
}
CMainFrame::CMainFrame()
{
// 创建窗口
Create(NULL,"最小的MFC窗口",WS_OVERLAPPEDWINDOW,CRect(0,0,200,200));
}
博客给出了创建最小MFC窗口的代码示例,包含stdafx.cpp、stdafx.h和minMFCwin.cpp三个文件。定义了CMfcApp和CMainFrame类,在CMfcApp的InitInstance函数中创建并显示主窗口,CMainFrame类用于创建窗口。

2138

被折叠的 条评论
为什么被折叠?



