Using a custom message in OCX

Source: Internet
Author: User

Custom messages cannot be defined in ATL as in MFC, because there is no concept of MSG map in standard ATL, and if you are doing ActiveX, you can msg to window,

ATL provides macros of the BEGIN_MESSAGE_MAP category:

First, define the message ID: #define WM_MYMSG wm_user+100//This step is the same as in MFC

To declare a message response function:

LRESULT OnMyMessage (UINT nmsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled); This particular note, which is the biggest difference from MFC, requires four parameters.

Add into message queue to:

Message_handler (wm_mymsg, OnMyMessage)//This is also different from MFC, it uses MESSAGE_HANDLER macros, while MFC uses On_message

Finally define a function entity:

LRESULT cfileimportctrl::onmyfilefinish (UINT nmsg, WPARAM WPARAM, LPARAM LPARAM, bool& bhandled)//Note, LRESULT that identifies a value that needs to be returned.

{

return 0;

}

Send this message:

SendMessage (m_hwnd,wm_mymsg,0,0);

OK, as to what needs to implement what function you added, wparam and lparam Here I have to take as 0, if you need to pass parameters, then through this even a row parameter added;


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.