hello MFC
刚学MFC很多问题不明白:
我看了《MFC Windows程序设计》这本书,有个hello MFC的例子,光盘上有,双击就能运行,界面很简单,没有菜单栏,没有工具栏,也没有状态栏,所以我也想自己做一个,因为选择MFC Application后界面复杂了,不想要,就选择了,Visual C++ 的Empty Project,在Solution Explorer面板中加入 Header Files--Hello.h和Source Files--Hello.cpp的文件,内容是:
//hello.h/////////////////////
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance ();
};
class CMainWindow : public CFrameWnd
{
public:
CMainWindow ();
protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP ()
};
//hello.cpp/////////////////////////
#include <afxwin.h>
#include "Hello.h"
CMyApp myApp;
/////////////////////////////////////////////////////////////////////////
// CMyApp member functions
BOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functions
BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()
CMainWindow::CMainWindow ()
{
Create (NULL, _T ("The Hello Application"));
}
void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
CRect rect;
GetClientRect (&rect);
dc.DrawText (_T ("Hello, MFC"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
编译时候出错:Error 1 fatal error LNK1561: entry point must be defined
请教各位大侠该怎么办,是不是不能用Empty Project来弄?
如果是这样的,那么怎么在MFC中建立像光盘中只有.cpp .h .dsp .dsw(没有编译之前)四个文件就能使用的程序?