When the user clicks the left mouse button and the insertion point is outside the control circle, the ClickOut event should fire. The ClickOut event is simpler than the ClickIn event in that it defines no arguments.
To add the ClickOut event
The Add Event dialog box appears.
ClickOut
.This returns you to the ActiveX Events tab. Notice that the implementation of the ClickOut event appears as:
Implementation:
void FireClickOut();
As with the ClickIn event, ClassWizard creates the code to add the ClickOut event, modifying the files CIRC.ODL, CIRCCTL.H, and CIRCCTL.CPP.
ClassWizard modifies the CCircCtrl
class’s event map in CIRCCTL.CPP to add a macro entry for the ClickOut event:
BEGIN_EVENT_MAP(CCircCtrl, COleControl)
//{{AFX_EVENT_MAP(CCircCtrl)
EVENT_CUSTOM("ClickIn", FireClickIn, VTS_XPOS_PIXELS VTS_YPOS_PIXELS)
EVENT_CUSTOM("ClickOut", FireClickOut, VTS_NONE)
//}}AFX_EVENT_MAP
END_EVENT_MAP()
The macro EVENT_CUSTOM associates the ClickOut event name with the member function FireClickOut
and with its argument type definition. The ClickOut argument type definition is set to VTS_NONE, which indicates that the ClickOut event passes no arguments.
ClassWizard adds an inline function to the CCircCtrl
class declaration. The FireClickOut
function provides a type-safe call to fire the event:
class CCircCtrl : public COleControl
{
...
//{{AFX_EVENT(CCircCtrl)
void FireClickIn(OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y)
{FireEvent(eventidClickIn,EVENT_PARAM(VTS_XPOS_PIXELS VTS_YPOS_PIXELS),
x, y);}
void FireClickOut()
{FireEvent(eventidClickOut,EVENT_PARAM(VTS_NONE));}
//}}AFX_EVENT
...
}