Article ID: 183080
Article Last Modified on 11/21/2006
PfnHandler Pointer to a member function that handles the event. This
function should have a BOOL return type, a first parameter of type UINT
(for the control ID), and additional parameter types that match the
event's parameters (see vtsParams). The function should return TRUE to
indicate the event was handled; otherwise FALSE.
VtsParams A sequence of VTS_ constants that specifies the types of the
parameters for the event. The first constant should be of type VTS_I4,
for the control ID. These are the same constants that are used in
dispatch map entries such as DISP_FUNCTION.
The vtsParams argument is a space-separated list of values from the VTS_
constants. One or more of these values separated by spaces (not commas)
specifies the function's parameter list. For example:
VTS_I2 VTS_BOOL specifies a list containing a short integer followed
by a BOOL.
VTS_I4 VTS_I2VTS_I4 and VTS_I2 match the data type of the first and second parameters of TestOnProblem(), respectively.
BOOL CTestDlg::TestOnProblem(UINT CtrlID, short Param)
{
TRACE("control id = %u, Second parameter = %d\n", CtrlID, Param);
return TRUE; // returns TRUE to indicate the event was handled;
}
Then, the event map should look similar to the following:
BEGIN_EVENTSINK_MAP(CTestDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CTestDlg)
//}}AFX_EVENTSINK_MAP
ON_EVENT_RANGE(
CTestDlg, // Class to which this event sink map belongs.
IDC_FIRSTCTRL, // ID of the first control in the range.
IDC_LASTCTRL, // ID of the last control in the range.
1, // Dispatch ID of event fired by the control.
TestOnProblem, // Function for handling events.
VTS_I4 VTS_I2) // VTS_I4 and VTS_I2 are the first and second
// parameters of TestOnProblem() function.
END_EVENTSINK_MAP()
It is important to note that ON_EVENT_RANGE must be added outside of
ClassWizard's comment ("//") lines. Otherwise, ClassWizard will give you an
error message box whenever you open the dialog box resource template. This
is because ClassWizard doesn't recognize the syntax of the ON_EVENT_RANGE
macro.Additional query words: event sink ocx map
Keywords: kbctrl kbhowto KB183080