Add common method
Article Directory
Foreword
备注:本文所介绍方法,vs2017已经不支持,仅是因教程连贯需要,vs2017以前的版本如vs2015都是支持的,如有需要的同学可以继续往下看。
Common methods and custom methods except that it has been implemented by a class COleControl. For example, COleControl contains a predefined member function, which supports the Refresh method of control. Dispatch map entries in this inventory method is DISP_STOCKFUNC_REFRESH.
COleControl supports two common methods: DoClick and Refresh. User control of invoked Refresh to update the appearance of the control immediately; calls DoClick to trigger the Click event of the control.
method | Dispatch map entry | Note |
---|---|---|
DoClick | DISP_STOCKPROP_DOCLICK( ) | Click event is triggered. |
Refresh | DISP_STOCKPROP_REFRESH( ) | Appearance of the control will be updated immediately. |
Use the "Add Method Wizard" to add a common method
Use the "Add Method Wizard" to add commonly used method is very simple. The following procedure demonstrates how to use the MFC ActiveX Control Wizard to add the Refresh method to control has been created.
Use the "Add Method Wizard" add commonly Refresh method
-
Load your project control.
-
In the "Class View", expand the library node control.
-
Right-click the control interface node (second node database nodes) to open the shortcut menu.
-
From the shortcut menu, click "Add", then click "Add Method."
This will open the "Add Method Wizard."
-
In the "method name" box, click Refresh.
-
Click Finish.
Change the method commonly used functions in the Add Wizard
Since the base class for controls that support inventory Refresh method, therefore the "Add Method Wizard" will not change the class to declare the control in any way. It adds the method's entry to the dispatch map and .IDL file control. Add the following line to the dispatch map controls, located on its implementation (.CPP) file:
DISP_STOCKFUNC_REFRESH()
This method makes use Refresh Refresh method.
Add the following line to .IDL file control:
[id(DISPID_REFRESH), helpstring("method Refresh")] void Refresh(void);
This behavior Refresh method of allocating a specific ID number.