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.
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.
Step 2: to have a good look at MFC code.
----------------------------------àbase message map (top)
Step3 :Simulate it .
1. Create an empty console application.
2. Add precious files.
3. The solution Explore is showing as follows. Please add new files like that.
4. Coding :
5 Run and Test it