Home | Overview | How Do I | FAQ | Tutorial | Sample
A stock method differs from a custom method in that it is already implemented by class COleControl. For example, COleControl contains a predefined member function supports the Refresh method for your control. The dispatch map entry for this stock method is DISP_STOCKFUNC_REFRESH.
COleControl supports two stock methods: DoClick and Refresh. Refresh is invoked by the control’s user to immediately update the control’s appearance; DoClick is invoked to fire the control’s Click event.
Method | Dispatch Map Entry | Comment |
DoClick | DISP_STOCKPROP_DOCLICK( ) | Fires a Click event. |
Refresh | DISP_STOCKPROP_REFRESH( ) | Immediately updates the control’s appearance. |
Adding a stock method is simple using ClassWizard. The following procedure demonstrates adding the Refresh method to a control created using ControlWizard.
To add the stock Refresh method using ClassWizard
The following figure shows the Add Method dialog box of ClassWizard.
The Add Method Dialog Box
Because the stock Refresh method is supported by the control’s base class, ClassWizard does not change the control’s class declaration in any way. It simply adds an entry for the method to the control’s dispatch map and to its .ODL file. The following line is added to the control’s dispatch map, located in its implementation (.CPP) file:
DISP_STOCKFUNC_REFRESH( )
This makes the Refresh method available to the control’s users.
The following line is added to the control’s .ODL file:
[id(DISPID_REFRESH)] void Refresh();
This line assigns the Refresh method a specific ID number.