VS2010下面Empty Project使用:
1,添加代码HelloApp
#include <afxwin.h>
class CHelloApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};
CHelloApp HelloApp;
class CHelloWindow:public CFrameWnd
{
CStatic * m_CStatic;
public:
CHelloWindow();
};
BOOL CHelloApp::InitInstance()
{
m_pMainWnd=new CHelloWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return true;
}
CHelloWindow::CHelloWindow()
{
Create(NULL,
"Hello World!",
WS_OVERLAPPEDWINDOW,
CRect(0,0,200,200)
);
m_CStatic=new CStatic();
m_CStatic->Create("Hello world",
WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(50,80,150,150),
this
);
}
2,编译出错:
unresolved external symbol _main referenced in function ___tmainCRTStartup
处理办法:
对于正常的标准的c或者c++main那么Project->properties->linker->system->subsystem 里面的设置是console;
但是非标准的main则应该该成相应的,比如windows,wince等等
一般的先尝试windows,全名是:Windows (/SUBSYSTEM:WINDOWS)