学MFC就是难,书上的例子一个都运行不了.......请看......

xiangxinyu 2008-01-02 07:30:23
//书上的例子程序

#include <afxwin.h>

class MyFrameWindow : public CFrameWnd
{
public:
afx_msg void OnPaint()
{
CPaintDC paintDC( this );
paintDC.TextOut( 0, 0, "这是我的第一个窗口" );
}
DECLARE_MESSAGE_MAP()
};

DEGIN_MESSAGE_MAP( MyFrameWindow, CFrameWnd )
ON_WM_PAINT()
END_MESSAGE_MAP( )


class HelloApp : public CWinApp
{
public:
HelloApp() : CWinApp("Hello World!")
{}

BOOL InitInstance()
{
CFrameWnd * MyFrame = new MyFrameWindow;
m_pMainWnd = MyFrame;
MyFrame->Create(NULL,(LPCTSTR) "Hello");
MyFrame->ShowWindow(SW_SHOW);
return TRUE;
}

} HelloWorld;

//在VS2005中就是错.......高手帮忙改改,要不就学不了其它的了.
...全文
133 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lockhall 2008-01-02
  • 打赏
  • 举报
回复
看看孙鑫的MFC视频,还是不错的。
xiangxinyu 2008-01-02
  • 打赏
  • 举报
回复
感谢楼上的,可以运行了
cmdlang 2008-01-02
  • 打赏
  • 举报
回复
MFC代码是要写对地方的
你可以先学学Windows程序运行机制。明白了程序是怎么运行的再写就明白了。
sunjw8888 2008-01-02
  • 打赏
  • 举报
回复
mfc 不光只是打代码。
qiyefei19830303 2008-01-02
  • 打赏
  • 举报
回复
帮 你调整好了
#include <afxwin.h>

class MyFrameWindow : public CFrameWnd
{
public:
afx_msg void OnPaint()
{
CPaintDC paintDC(this);
paintDC.TextOut( 0, 0, "这是我的第一个窗口" );
}

DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(MyFrameWindow, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()


class HelloApp : public CWinApp
{
public:
HelloApp() : CWinApp("Hello World!")
{}
~HelloApp(){} ;

BOOL InitInstance()
{
CFrameWnd * MyFrame = new MyFrameWindow;
m_pMainWnd = MyFrame;

MyFrame-> Create(NULL,(LPCTSTR) "Hello");
MyFrame-> ShowWindow(SW_SHOW);
return TRUE;
}

} ;

HelloApp MyApp;
qiyefei19830303 2008-01-02
  • 打赏
  • 举报
回复
这个是能运行得,
xiaop1987 2008-01-02
  • 打赏
  • 举报
回复
MFC不是把所有代码写上去就能运行的。。
xuanwenchao 2008-01-02
  • 打赏
  • 举报
回复
什么错误?

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧