How to use fonts in ActiveX controls

Source: Internet
Author: User

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:

    1. Open the control project and click ClassWizard on the View menu to open ClassWizard;
    2. Click the Automation tab;
    3. In the Class Name box, select your control class name;
    4. Click Add Property;
    5. In the External name box, click Font;
    6. Click OK;
    7. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.