新建一个win32空工程,然后使用MFC创建程序

Step1:新建一个win32 空工程

Step2:新建资源脚本文件resource,并在resource.rc上右击,点resource includes。在弹出的对话框中直接点OK

 

Step3:view/classwizard,在弹出的对话框中点OK即可

Step4:Project/settings,在弹出的对话框中选General标签,选中Use MFC in Static Library

将默认选项not use mfc改为使用mfc

Step5:插入自建窗口类CMyFrameWnd;

并将其构造函数和虚析构函数的保护属性改为public

 

Step 6:插入自建应用程序类CMyWinApp

Step 7:新建stdafx.h,内容如下:

#if !defined(LUO_STDAFX)

#define LUO_STDAFX

#include <afxwin.h>

#endif

Step 8:相关要改动的代码如下:

// MyWinApp.cpp: implementation of the CMyWinApp class.

//

//

 

#include "resource.h"

#include "MyWinApp.h"

#include "MyFrameWnd.h"

#ifdef _DEBUG

#undef THIS_FILE

static char THIS_FILE[]=__FILE__;

#define new DEBUG_NEW

#endif

 

//

// Construction/Destruction

//

CMyWinApp gApp;

CMyWinApp::CMyWinApp()

{

 

}

 

CMyWinApp::~CMyWinApp()

{

 

}

 

BOOL CMyWinApp::InitInstance()

{

       m_pMainWnd=new CMyFrameWnd;

       m_pMainWnd->ShowWindow(SW_NORMAL);

       m_pMainWnd->UpdateWindow();

       return TRUE;

 

}

 

// MyFrameWnd.cpp : implementation file

//

 

#include "stdafx.h"

#include "resource.h"

#include "MyFrameWnd.h"

 

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

 

/

// CMyFrameWnd

 

IMPLEMENT_DYNCREATE(CMyFrameWnd, CFrameWnd)

 

CMyFrameWnd::CMyFrameWnd()

{

       Create(NULL,"MFC WINDOW");

}

 

CMyFrameWnd::~CMyFrameWnd()

{

}

 

 

BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd)

       //{{AFX_MSG_MAP(CMyFrameWnd)

              // NOTE - the ClassWizard will add and remove mapping macros here.

       //}}AFX_MSG_MAP

END_MESSAGE_MAP()

 

/

// CMyFrameWnd message handlers

 

程序结果如下

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值