Onwndmsg function processing process

Source: Internet
Author: User

In MFC, The onwndmsg function is processed as follows:

1) First, determine whether a message has a message response function. For example, onlbuttondown () processes the message "left-click.

2) the judgment method is to find the desired message Response Function in the corresponding window class. Here, we take the project draw of MFC as an example. onwndmsg will search for it in cdrawtest. h to see on declare_message_map,

Whether there is a prototype Declaration of the corresponding message response function between two afx_msg comment macros, as follows:

//CDrawTest.h
Protected: // {afx_msg (cdrawview) afx_msg void onlbuttondown (uint nflags, cpoint point); // prototype declaration of the onlbuttondown () function //} afx_msgdeclare_message_map ()

Next, go to cdrawview. cpp and check whether there is a message ing macro between in_message_map () and end_message_map (), as shown below:

// Cdrawview. cppimplement_dyncreate (cdrawview, cview) begin_message_map (cdrawview, cview) // {afx_msg_map (cdrawview) on_wm_lbuttondown () // function onlbuttondown () in the message ing macro, //} afx_msg_map // standard printing commandson_command (id_file_print, cview: onfileprint) on_command (id_file_print_direct, cview: onfileprint) on_command (outputs, cview :: onfileprintpreview) end_message_map ()

3) if the message response function is found through steps 1) and 2, the response function is called to process the message.

If the message response function is not found in the subclass, the base class is processed.

4) through the above steps, MFC implements message ing to respond to messages.

5) implementation of the onlbuttondown () function:



 

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.