- Message Maps
-
Message Maps - the Microsoft Foundation Class Library message map facility.
Microsoft Windows implements what are essentially virtual functions in window classes using its messaging facility. Due to the large number of messages involved, providing a separate virtual function for each Windows message results in a prohibitively large vtable.
MFC provides an alternative to the switch statement used in traditional Windows programs to handle messages sent to a window. A mapping from messages to member-functions may be defined so that when a message is to be handled by a window, the appropriate member function is called automatically. This message-map facility is designed to be similar to virtual functions but has additional benefits not possible with C++ virtual functions.
Message Maps, maps the user action in to the appropriate MFC class functions to handle it. The MFC Class which can handle message should be member of CCmdTarget, (i.e) it should be hierarchically derived from CCmdTarget.
The advantage of Message Map is the same action can be mapped to more than one MFC class function.
It is similar to handling the messages in SDK application using WndProc callback functions, but in MFC with the help OOPS concepts
References
Categories:- Microsoft application programming interfaces
- Microsoft Windows stubs
Wikimedia Foundation. 2010.