vs2017 development of ActiveX (Speaker OCX) (vii), method

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

method

Article Directory


ActiveX control triggering event for communication between itself and its control container. Container can also communicate with the control methods and properties. The method is also called a function.

Methods and properties that provide export interfaces for other applications, such as ActiveX controls and automation client container. For more information about ActiveX control properties, see the article MFC ActiveX Controls: Properties.

The method is similar to the class member functions in C ++ and using object. You control method can achieve two types: Standard and Custom. Common events with similar, commonly used method is to provide a method to achieve their COleControl. For more information about commonly used methods, see the article MFC ActiveX Controls: Add a common method. Custom method defined by the developer controls allow for additional customization. For more information, see the article MFC ActiveX Controls: Adding custom methods.

Microsoft Foundation Class Library (MFC) implements a mechanism that allows you to control popular support and custom methods. The first part is COleControl class. COleControl member functions derived from CWnd, supports all common methods of common ActiveX controls. The second mechanism is part of the dispatch map. Dispatch map similar to the message map; however, not scheduling mapping function to map the Windows message ID, but mapping the virtual member function to IDispatch IDS.

For proper support various methods of control, that class must declare a dispatch map. This is accomplished by the following lines of code in the files located in the control class header (.H):

DECLARE_DISPATCH_MAP()

The main purpose is to establish a schedule mapped external caller method name (such as containers) used in the realization of the relationship between the control class member function of these methods. After declaring the dispatch map, it needs to be defined in the implementation (.CPP) of the control file. The following code defines the line dispatch map:

BEGIN_DISPATCH_MAP(CCreateOcxDemoCtrl, COleControl)

END_DISPATCH_MAP()

If you are using the MFC ActiveX Control Wizard to create a project, it will automatically add these lines. If you are not using the MFC ActiveX Control Wizard, you must manually add these lines.

The following article discusses the method:

MFC ActiveX Controls: Adding common method

MFC ActiveX Controls: Adding custom methods

MFC ActiveX control: from the method returns an error code

Guess you like

Origin blog.csdn.net/y601500359/article/details/92830292