On_message and on_notity

Source: Internet
Author: User

On_notify is the macro used by the control to send messages to its parent window. on_command is the macro used by the menu and toolbar to process messages. on_message is the macro used to process custom messages.




To understand these messages, you must first understand the background of the window message.
In windows3.1, the control notifies its parent window of messages such as mouse and keybord. Only wm_command is used, and the event type and Control ID are included in wparam, the control handle is included in lparam. Since wparam and lparam are full, when the control wants to send other special messages to the parent window with a lot of information, there is no place to store them. Therefore, many other message types are defined in windows3.1, such as wm_vscroll and wm_ctlcolor. The information contained in wparam and lparam is different.
When Win32 is reached, there are more and more types of controls. Of course, you cannot define a set of messages for each control, which is not conducive to system expansion. So the only powerful message wm_notify is defined in Win32. Of course, wm_policy also complies with the original message rules, with only the wparam and lparam parameters. The only difference is that the lparam transmits an nmhdr pointer. Different controls can expand nmhdr according to the rules. Therefore, the amount of information transmitted by wm_notify messages can be quite large. For details, see the Related Description in msdn. There are many such messages in treecontrol.


Now we can know why there is on_message, on_command, and on_policy.
On_message processes all Windows messages, because all messages are transmitted in the same format, that is, ID, wparam, lparam.
On_command is used to process wm_command messages, so that we do not need to unbind the control IDs and event types transmitted in wm_command and lparam ..., All of them are solved in the MFC: :), of course, convenient.
On_policy doesn't need to be said. Check whether the nmhdr function has been solved.


In this way, we can see at a glance that on_command and on_notify can both be processed using on_message, but we have to do a lot of things on our own. On_command and on_policy should be replaced!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.