VC implements a method to add events to a button on the form

  • 2020-04-02 03:03:02
  • OfStack

This article illustrates how the VC implementation adds an event to a button on a form. Share with you for your reference. The specific implementation method is as follows:

1. In MainFrm. H

// Generated message map functions

Add:
afx_msg void OnSelectRed(); // Declare event name 

2. MainFrm. CPP

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
The following
Add:
ON_COMMAND_(ID_SELECT_RED,OnSelectRed) // Make an association (map) 

3. MainFrm. CPP

// CMainFrame message handlers

Add function body
void CMainFrame::OnSelectRed() 
{ }

Hope that this article described the VC programming for you to help.


Related articles: