hello MFC

ch_pf1233 ch_pf1233 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
刚学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(没有编译之前)四个文件就能使用的程序?
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
ch_pf1233
VC/MFC 16,551 成员 421,605 内容