您的位置:首页 > 其它

MFC之Hello World

2014-11-07 18:36 281 查看
头文件hello.h

#pragma once
#include <afxwin.h>
class CMyApp :public CWinApp
{
	BOOL InitInstance();
};

class CMainWnd :public CFrameWnd
{
public:
	CMainWnd();
protected:
	afx_msg void OnPaint();
	DECLARE_MESSAGE_MAP()
};
实现文件hello.cpp

#include <afxwin.h>
#include "Hello.h"

CMyApp myApp;
BOOL CMyApp::InitInstance()
{
	m_pMainWnd = new CMainWnd;
	m_pMainWnd->ShowWindow(m_nCmdShow);
	m_pMainWnd->UpdateWindow();
	return TRUE;
}

BEGIN_MESSAGE_MAP(CMainWnd,CFrameWnd)
	ON_WM_PAINT()
END_MESSAGE_MAP()

CMainWnd::CMainWnd()
{
	Create(NULL, _T("Hello, MFC"));
}

void CMainWnd::OnPaint()
{
	CPaintDC dc(this);
	CRect rect;
	GetClientRect(&rect);
	dc.DrawText("Hello World", &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: