MFC学习笔记3引用资源

简介: 代码 #include #include "resource.h"//引用是必须的,不然菜单不会出现class MyFrameWindow:public CFrameWnd{public: afx_msg void OnPaint() { CPaintDC paintDC(this); paintDC.

 

img_1c53668bcee393edac0d7b3b3daff1ae.gif img_405b18b4b6584ae338e0f6ecaf736533.gif 代码
 
  
#include < afxwin.h >
#include
" resource.h " // 引用是必须的,不然菜单不会出现

class MyFrameWindow: public CFrameWnd
{
public :
afx_msg
void OnPaint()
{
CPaintDC paintDC(
this );
paintDC.TextOut(
0 , 0 , " 这是我的第一个窗口程序 " );
}
afx_msg
void OnFileExit()
{
PostMessage(WM_CLOSE);
}
BOOL PreCreateWindow(CREATESTRUCT
& cs)
{
cs.hMenu
= LoadMenu(NULL,MAKEINTRESOURCE(IDR_MAINMENU));
return CFrameWnd::PreCreateWindow(cs);
}
DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(MyFrameWindow,CFrameWnd)
ON_WM_PAINT()
ON_COMMAND(ID_40003,OnFileExit)
END_MESSAGE_MAP()

class HellowApp: public CWinApp
{
public :
HellowApp()
:CWinApp(
" HelloWorld " )
{}

BOOL InitInstance()
{
HICON hIcon;
hIcon
= LoadIcon(IDIGNORE);
CFrameWnd
* MyFrame = new MyFrameWindow;
m_pMainWnd
= MyFrame;
MyFrame
-> Create(NULL,(LPCSTR) " Hellow " );
MyFrame
-> SetIcon(hIcon,FALSE); // 设置窗口的小图标
MyFrame -> SetIcon(hIcon,TRUE); // 设置窗口的大图标
MyFrame -> ShowWindow(SW_SHOW);
return TRUE;
}

}HellowWorld;

程序运行如图:

img_3e3679e9464d0e8b419bb84ab74821fe.jpg

 

目录
相关文章
|
15天前
|
存储 程序员 编译器
c++面向对象概述、内存分析、引用、函数
c++面向对象概述、内存分析、引用、函数
|
10月前
|
XML 开发框架 算法
【C#本质论 十一】合式类型(二)程序集引用、XML注释、垃圾回收和资源清理
【C#本质论 十一】合式类型(二)程序集引用、XML注释、垃圾回收和资源清理
97 0
|
安全 C++
【C++ 语言】智能指针 引入 ( 内存泄漏 | 智能指针简介 | 简单示例 )
【C++ 语言】智能指针 引入 ( 内存泄漏 | 智能指针简介 | 简单示例 )
138 0
【C++ 语言】智能指针 引入 ( 内存泄漏 | 智能指针简介 | 简单示例 )
|
Web App开发 API
引用同一个项目中的类库,如何避免 goToDefinition时不能到达真正的定义类
新建一个解决方案: Api 添加类库 APi.Data APi.Data 新建一个 Entity public class Entity {private int id;public int Id {get { return id; }set { id = value;...
725 0
C#调用非托管的代码
using System; using System.Runtime.InteropServices; namespace 调用非托管项目demo { class Program { static void Main(string[] args) { Win32.MessageBox(0, "Hello I am
1104 0

热门文章

最新文章