The use of fonts is an integral part of the process of making ActiveX controls. This article will explain in profound detail how fonts are used in the process of making ActiveX controls. The production of ActiveX controls mentioned in this article refers to the use of vc++6.0 MFC ActiveX ControlWizard tools to make ActiveX controls in other ways this article is not discussed.
This article specifically sets up routines that you can better master. These routines are complete source code for ActiveX controls. In order to highlight the focus, this article only on the font using the relevant parts of the source code for a more detailed introduction, the rest of the code in this article is not discussed too much. Fonts are used in ActiveX controls as a property, not unlike other properties, as well as inventory attributes and custom attributes, which are described in four sections.
- The first part uses the Inventory Font property in the control
- The second section uses custom font properties in controls
- The third part uses a variety of fonts
- Part four optimize the code and use a variety of fonts reasonably
The first part uses the Inventory Font property in the control
To add a font inventory property by using ClassWizard:
- Open the control project and click ClassWizard on the View menu to open ClassWizard;
- Click the Automation tab;
- In the Class Name box, select your control class name;
- Click Add Property;
- In the External name box, click Font;
- Click OK;
- Click OK to confirm your selection and close ClassWizard;
ClassWizard will include the following line in the dispatch mapping table of the execution file for the control class:
DISP_STOCKPROP_FONT()
In addition, ClassWizard adds the following lines to the. ODL file:
[id(DISPID_FONT), bindable] IFontDisp* Font;
Routine 1:label.ocx
Below, we give a concrete example detailing how to add a font inventory property to a control. You can download the routine to compile the build. OCX control, and test the control.
The control we are going to make is named Label.ocx, mimicking the label control in the VB Toolbox. This control enhances the limited functionality of the static text control in the VC + + toolbox, which you can easily use in your project. The project name for the routine is also named label.
Create label Project
Open Visual C + + 6.0, click New in the File menu, and pop Up the new dialog box. Select MFC ActiveX ControlWizard in the dialog box and enter the project name label, click the OK button, close the dialog box and eject the MFC ActiveX Controlwizard-step 1 of 2 dialog box. As shown in Figure 1-1.
Figure 1-1