VC生成窗体的基础问题
#include "afxwin.h"
class CMainFrame:public CFrameWnd //定义主窗体
{
public:
CMainFrame();
};
CMainFrame::CMainFrame() //构造函数
{
Create(NULL,"Windows");
}
class DemoApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};
BOOL DemoApp::InitInstance()
{
CMainFrame *m_pMainWnd=new CMainFrame;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
DemoApp theApp;
=====================================
设置成use MFC in a Shared DLL 或 use MFC in a static Library都试过,编译能够通过,但是运行时提示:
---------------Configuration: Sample - Win32 Debug--------------------
Linking...
msvcrtd.lib(crtexe.obj) : error LNK2001: unresolved external symbol _main
Debug/Sample.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Sample.exe - 2 error(s), 0 warning(s)
=====================================
为什么会这样?CWinApp和CFrameWnd类不是完成了winMain()的工作嘛?