Add custom Response Message in VC ++

Source: Internet
Author: User

1. First define the message (such as DebugApp. h)

 

# Define WM_DEBUG WM_USER + 1

 

 

 

2. Add the header file in the window (for example, MainFrame. h)

 

Class CMainFrame: public CFrameWnd
{
// Generated message map functions
//} AFX_MSG
Afx_msg LRESULT OnDebug (WPARAM wParam, LPARAM lParam );

...
}

 

 

 

3. Add in the cpp file of the window (for example, MainFrame. cpp)

 

BEGIN_MESSAGE_MAP (CMainFrame, CFrameWnd)
...
ON_MESSAGE (WM_DEBUG, OnDebug)

END_MESSAGE_MAP ()

 

...
LRESULT CMainFrame
: OnDebug (WPARAM wParam, LPARAM lParam)
{


Return 0;

}

 

 

 

4. messages can be sent elsewhere (for example, add a message to the event with the left mouse of DebugView. cpp)

 

Void CDebugView: OnLButtonDown (UINT nFlags, CPoint point)
{
CFrameWnd * pFrame;

// Obtain the main window pointer
PFrame = (CFrameWnd *) AfxGetApp ()-> m_pMainWnd;
PFrame-> SendMessage (WM_DEBUG, 0, 0 );

CView: OnLButtonDown (nFlags, point );
}

 


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.