0% found this document useful (0 votes)
63 views12 pages

Use and Understanding of MESSAGE - MAP Along With Message

This document discusses the use of MESSAGE_MAP in MFC for message-driven programming. MESSAGE_MAP allows class member functions to execute in response to messages by mapping messages to handlers. It has three main components - a DECLARE_MESSAGE_MAP declaration, a BEGIN_MESSAGE_MAP statement specifying the class, and an END_MESSAGE_MAP termination statement. Message handlers start with "On" followed by the message name and are used to respond to specific messages.

Uploaded by

Shraddha Sheth
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views12 pages

Use and Understanding of MESSAGE - MAP Along With Message

This document discusses the use of MESSAGE_MAP in MFC for message-driven programming. MESSAGE_MAP allows class member functions to execute in response to messages by mapping messages to handlers. It has three main components - a DECLARE_MESSAGE_MAP declaration, a BEGIN_MESSAGE_MAP statement specifying the class, and an END_MESSAGE_MAP termination statement. Message handlers start with "On" followed by the message name and are used to respond to specific messages.

Uploaded by

Shraddha Sheth
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 12

Use and Understanding Of

MESSAGE_MAP along with Message


Handlers

Presented By :
Sheth Shraddha(50)
Tamhane Vaidehi(54)
Use of MESSAGE_MAP

 Windows Operating Systems – A Message


Driven System
 Example : Mouse click, Printer signal
 MESSAGE_MAP supports Message Driven
Programming in MFC.
 Class Member Functions are used.
Role Of Class Member Functions

 To execute commands
 Messages are directed to class member
functions by the use of macros in MFC.
 Convenience
Components Of MESSAGE_MAP

 Declaration
 Beginning
 Termination
Declaration

 DECLARE_MESSAGE_MAP
– Declared in the class which allows to respond to messages.
– A class is eligible to execute a message map if it is derived
from CCmdTarget or a class which is derived from
CCmdTarget. 
– A class can have only one message map.
– It should be the last member declared within a class.
– If not then next member should be preceded by an access
specifier.
BEGINNING

 BEGIN_MESSAGE_MAP
– Parameters
 Class name which implements the message map.
 Base class
– Succeeded by macros which represent
messages.
Termination

 END_MESSAGE_MAP
– Messages macros are succeeded by
END_MESSAGE_MAP
Message Handlers

 To respond to a message one must add a


message handler.
 Members of CWnd class.
 Can be overridden.
Naming Pattern Of Message Handlers

 Start with “On”.


 Succeeded by message name.
 Should be in camel case.
 Ex:
– Macro: WM_SIZE
– Handler: OnSize()
Example
References
Thank You!!

You might also like