Using SizerOne in Visual C++ > Step 4: Add an event handler |
To add an event handler to a control, right click on it and select the Events… menu. The AppWizard will show a dialog listing all the controls and events available for each one. For this sample, select the IDC_C1TAB1 control and double-click the Switch event. The AppWizard will suggest a name for the event handler. Click OK to accept the suggestion, then click Edit Existing to go to the handler implementation.
The AppWizard has added a code stub that looks like this:
Example Title |
Copy Code
|
---|---|
void CC1TabTutDlg::OnSwitchC1tab1(short FAR* OldTab, short FAR* NewTab, short FAR* Cancel) { // TODO: Add your control notification handler code here } |
This is similar to the empty Sub/End Sub when you create an event handler in VB. Add the following handler code to the stub:
Example Title |
Copy Code
|
---|---|
void CC1TabTutDlg::OnSwitchC1tab1(short FAR* OldTab, short FAR* NewTab, short FAR* Cancel) { CString str; str.Format("The new tab is %d.", *NewTab); m_C1Elastic.SetCaption(str); } |
This code gets executed whenever the user selects a new tab. It displays the selection in the C1Elastic control using the member variable we added in Step 3.