First MFC

// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__A3DDEB0A_0CE3_44DE_9AD8_B5AD12758B55__INCLUDED_)
#define AFX_STDAFX_H__A3DDEB0A_0CE3_44DE_9AD8_B5AD12758B55__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__A3DDEB0A_0CE3_44DE_9AD8_B5AD12758B55__INCLUDED_)


/************************************************************/
// stdafx.cpp : source file that includes just the standard includes
//	HelloMFC.pch will be the pre-compiled header
//	stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

/************************************************************/
//FileName: hello.h

class CMyApp : public CWinApp
{
public:
	virtual BOOL InitInstance();		
};

class CMainWindow : public CFrameWnd
{
public:
	CMainWindow();
protected:
	afx_msg void OnPaint();
	DECLARE_MESSAGE_MAP()
};


/************************************************************/
//FileName: Hello.cpp

#include "StdAfx.h"
#include "Hello.h"

CMyApp myApp;

//CMyApp
BOOL CMyApp::InitInstance(){
	this->m_pMainWnd = new CMainWindow;
	this->m_pMainWnd->ShowWindow(m_nCmdShow);
	this->m_pMainWnd->UpdateWindow();
	return TRUE;
}

BEGIN_MESSAGE_MAP(CMainWindow,CFrameWnd)
	ON_WM_PAINT()
END_MESSAGE_MAP()

//CMainWindow
CMainWindow::CMainWindow()
{
	Create(NULL,_T("The Hello 程序"));
}

void CMainWindow::OnPaint()
{
	CPaintDC dc(this);
	CRect rect;
	GetClientRect(&rect);
	dc.DrawText(_T("Hello,MFC您好!"),-1,&rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}


/************************************************************/

 

 

 

 

 

posted @ 2013-09-19 23:25  庚武  Views(264)  Comments(0Edit  收藏  举报