다음을 통해 공유


ON_EVENT_RANGE

Use the ON_EVENT_RANGE macro to define an event handler function for an event fired by any OLE control having a control ID within a contiguous range of IDs.

ON_EVENT_RANGE(theClass, idFirst, idLast, dispid, pfnHandler, vtsParams )

Parameters

  • theClass
    The class to which this event sink map belongs.

  • idFirst
    The control ID of the first OLE control in the range.

  • idLast
    The control ID of the last OLE control in the range.

  • dispid
    The dispatch ID of the event fired by the control.

  • 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.

Remarks

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.

For a list of the VTS_ constants, see EVENT_CUSTOM.

Example

The following example demonstrates an event handler, for the MouseDown event, implemented for three controls (IDC_MYCTRL1 through IDC_MYCTRL3). The event handler function, OnRangeMouseDown, is declared in the header file of the dialog class (CMyDlg) as:

BOOL OnRangeMouseDown(UINT CtlID, short MouseButton, short Shift,
   long x, long y);

The code below is defined in the implementation file of the dialog class.

BEGIN_EVENTSINK_MAP(CMyDlg, CDialog)
   ON_EVENT_RANGE(CMyDlg, IDC_MYCTRL1, IDC_MYCTRL3, -605, OnRangeMouseDown,
      VTS_I4 VTS_I2 VTS_I2 VTS_I4 VTS_I4)
END_EVENTSINK_MAP()

Requirements

Header: afxdisp.h

See Also

Concepts

MFC Macros and Globals

ON_EVENT

ON_PROPNOTIFY

ON_PROPNOTIFY_RANGE