设为首页 加入收藏

TOP

MFC基础入门之Hello World(一)
2012-11-04 15:08:05 来源: 作者: 【 】 浏览:403
Tags:MFC 基础 入门 Hello World
  以前对于MFC的了解十分肤浅,只知道MFC = Microsoft Foundation Class,后来还道听途说了很多关于她的风流韵事。有人说她如维纳斯一般美丽,也有人说她和犹大一般丑恶。现在为了手头上的事情,我要从新认识这位也许风华不在的女子了,不管她长得如何,我都得去揭开她那对于我来说神秘的面纱。



  还是从打招呼开始吧,以免把她吓着了。于是,我战战兢兢的跟MFC say hello了。

MyApp.h: class CMyApp : public CWinApp
{
 public:
  virtual BOOL InitInstance();
};
// frame window class
class CMyFrame : public CFrameWnd
{
 public:
  CMyFrame();
 protected:
  // "afx_msg" indicates that the function is part
  // of the MFC library message dispatch system
  afx_msg void OnPaint();
  DECLARE_MESSAGE_MAP()
};
MyApp.cpp:

#include <afxwin.h> // MFC library header file declares base classes
#include "myapp.h"

CMyApp theApp; // the one and only CMyApp object

BOOL CMyApp::InitInstance()
{
 m_pMainWnd = new CMyFrame();
 m_pMainWnd->ShowWindow(m_nCmdShow);

 m_pMainWnd->UpdateWindow();
 return TRUE;
}

BEGIN_MESSAGE_MAP(CMyFrame, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

CMyFrame::CMyFrame()
{
 Create(NULL, "MYAPP Application");
}

void CMyFrame::OnPaint()
{
 CPaintDC dc(this);
 dc.TextOut(0, 0, "Hello, MFC!");
}

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇用VC6.0设计数字视频播放器 下一篇浅议VC程序中进程间信息交换方法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: