Implementation of message Map in MFC

Source: Internet
Author: User

Knowledge is read and summed up in a book, the title: MFC Windows Programming (2nd edition). Beauty Jeff Prosise, Beijing Beyondsoft Technology Development Co., Ltd. translation

The procedure for capturing window events and adding event handlers can be implemented in the following two ways (for example, with a mouse click event):

1.

H file Add:

Protectedvoid  OnLButtonDown (UINT nflags, CPoint point);D eclare_message_map ()

CPP file add:

Begin_message_map (subclass name, base class name)   On_wm_lbuttondown () End_message_map ( ) ... void Subclass Name:: OnLButtonDown (UINT nflags, CPoint point) {...}

2.

H file Add:

protected : afx_msg LRESULT onlbuttondown (WPARAM wparam,lparam LPARAM);D eclare_message_map ()

CPP file add

Begin_message_map (subclass name, base class name)   on_message (Wm_lbuttondown, OnLButtonDown) End_message_map () ... LRESULT Subclass Name:: OnLButtonDown (WPARAM wparam,lparam LPARAM) {...}

The effect is the same for both implementations. But they belong to different methods. The second method can also be used in the process of adding custom messages.

Implementation of message Map in MFC

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.