|Wichtig||Dieses Dokument enthält ggf. nicht die bewährten Methoden für die aktuelle Entwicklung. Außerdem sind Links zu Downloads und anderen Ressourcen u. U. nicht mehr gültig. Die aktuell empfohlene Version finden Sie hier. ArchiveDisclaimer|
MFC ActiveX Controls: Adding Stock Methods
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 that 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|
Fires a Click event.
Immediately updates the control's appearance.
Adding a Stock Method Using the Add Method Wizard
Adding a stock method is simple using the Add Method Wizard. The following procedure demonstrates adding the Refresh method to a control created using the MFC ActiveX Control Wizard.
To add the stock Refresh method using the Add Method Wizard
Load your control's project.
In Class View, expand the library node of your control.
Right-click the interface node for your control (the second node of the library node) to open the shortcut menu.
From the shortcut menu, click Add and then click Add Method.
This opens the Add Method Wizard.
In the Method Name box, click Refresh.
Add Method Wizard Changes for Stock Methods
Because the stock Refresh method is supported by the control's base class, the Add Method Wizard does not change the control's class declaration in any way. It adds an entry for the method to the control's dispatch map and to its .IDL file. The following line is added to the control's dispatch map, located in its implementation (.CPP) file:
This makes the Refresh method available to the control's users.
The following line is added to the control's .IDL file:
[id(DISPID_REFRESH)] void Refresh(void);
This line assigns the Refresh method a specific ID number.