• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
MacrosLee's Mind
博客园    首页    新随笔    联系   管理    订阅  订阅
Simulate Message Mapping

Simulate Message Mapping

转载注明:http://www.cnblogs.com/macroslee/archive/2011/10/18/2216339.html

文章有什么不知或错误,恳请指正,谢谢!

Step 1: In SDK application, you handle a message by means of switch/case .

But in MFC , you must use a message map to find the correct handler.

But how to design,

Message1----------------------------handler1

Message2----------------------------handler2

Message3---------------------------handler3

Message5----------------------------handler5

However, in MFC, we should be object –oriented.

So, An object always deals with more than one MSG, we designed an array.

clip_image001

But an object is not isolated.They must have some association with each other.

So if a MSG is not handled by an object. May be it’s not her responsibility. But she must pass it to another object to find if the MSG is it’s (to find a handler) .

So we design a map. Each object has one ,just like a home address.

clip_image003

Step 2: to have a good look at MFC code.

clip_image005

clip_image007

clip_image009

clip_image011

clip_image012----------------------------------àbase message map (top)

clip_image014

Step3 :Simulate it .

1. Create an empty console application.

clip_image016

2. Add precious files.

clip_image018

3. The solution Explore is showing as follows. Please add new files like that.

clip_image019

4. Coding :

clip_image020---

clip_image021

clip_image022---

clip_image024clip_image026

clip_image028

clip_image030

clip_image032

clip_image034

clip_image036

clip_image038

clip_image039---

clip_image041

clip_image042

clip_image044

clip_image045

clip_image047

clip_image049

clip_image050

clip_image051

clip_image052

clip_image053

clip_image054

clip_image055

clip_image056----

clip_image057

clip_image058----

clip_image060

clip_image062

5 Run and Test it

clip_image064

posted on 2011-10-18 12:41  MacrosLee's Mind  阅读(297)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3