1 新建Win32程序
2 下一步
3 确定
4 右键->项目属性
再修改
5 新建头文件 test.h
代码入下:
#include "afxwin.h" /*必须引用*/
class test:public CWinApp
{
public:
virtual BOOL InitInstance();
};
class TestFrame :public CFrameWnd
{
public:
TestFrame();
};
6 新建源文件 test.cpp
代码:
#include "test.h"
test _test;// 全局应用程序对象,有且仅有一个
BOOL test::InitInstance()
{
//创建窗口
TestFrame* frame = new TestFrame;
//显示
frame->ShowWindow(SW_SHOWNORMAL);
//更新
frame->UpdateWindow();
m_pMainWnd = frame;保存指向应用程序的主窗口的指针
return true;
}
TestFrame::TestFrame()
{
Create(NULL, TEXT("ONE"));
}
运行结果