Message Maps

Message Maps is the Microsoft Foundation Class Library message map facility.

Microsoft Windows implements polymorphism 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 into 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

This article is issued from Wikipedia - version of the 9/30/2014. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.