Use and understanding of message-map along with message
Transcript of Use and understanding of message-map along with message
![Page 1: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/1.jpg)
Use and Understanding Of MESSAGE_MAP along with Message
Handlers
Presented By : Sheth Shraddha(50)
Tamhane Vaidehi(54)
![Page 2: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/2.jpg)
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.
![Page 3: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/3.jpg)
Role Of Class Member Functions
To execute commands Messages are directed to class member
functions by the use of macros in MFC. Convenience
![Page 4: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/4.jpg)
Components Of MESSAGE_MAP
Declaration Beginning Termination
![Page 5: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/5.jpg)
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.
![Page 6: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/6.jpg)
BEGINNING
BEGIN_MESSAGE_MAP– Parameters
Class name which implements the message map. Base class
– Succeeded by macros which represent messages.
![Page 7: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/7.jpg)
Termination
END_MESSAGE_MAP– Messages macros are succeeded by
END_MESSAGE_MAP
![Page 8: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/8.jpg)
Message Handlers
To respond to a message one must add a message handler.
Members of CWnd class. Can be overridden.
![Page 9: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/9.jpg)
Naming Pattern Of Message Handlers
Start with “On”. Succeeded by message name. Should be in camel case. Ex:
– Macro: WM_SIZE– Handler: OnSize()
![Page 10: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/10.jpg)
ExampleExample
![Page 11: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/11.jpg)
References
![Page 12: Use and understanding of message-map along with message](https://reader035.fdocuments.us/reader035/viewer/2022071815/55a954f91a28ab626d8b4614/html5/thumbnails/12.jpg)
Thank You!!