Class: cComStdFont

Properties  Events  Methods    Index of Classes

OLE conventions implement fonts as Automation objects that contain the properties of the font

Hierarchy

cObject
---DfComAutomationObject
------cComAutomationObject
---------cComStdFont

Library: Common (Windows and Web Application) Class Library

Package: StdFont.pkg

Mixins: cComFont cComFontEvents

Description

OLE conventions implement fonts as Automation objects that contain the properties of the font. An object of this class is a wrapper object around a Windows font object, and all the common functionality for dealing with Windows fonts is provided in this class.

In many cases a COM object provides some way of changing a component's font. In this case you can access the font by creating an instance of the cComStdFont wrapper class and connect it to the OLE Font.

Typically, the COM object that you are dealing with will provide access to the OLE font by providing a function that returns an IDispatch* value that points to that font. You would then set the cComStdFont object's pvComObject property to the IDispatch* value to connect it with the OLE font.

For example the cComCalendar class used in the COM Sample application uses font objects to access the font attributes of the calendar's Day, Grid, and Title.

You can create a new OLE font object by sending CreateComObject to an instance of cComStdFont.

Example

Below is an example of how you would manipulate the calendar object's title font in the COM sample application. The procedure shown is the OnChange method of a checkbox object.

Procedure OnChange
    // click this checkbox to underline the Calendar Object's title.
    Handle  hoFont
    Variant vFont
    Boolean bIsComObjectCreated
    Boolean bChecked
 
    // test If the calendar COM Object is active. You
    // cannot access any COM interface methods unless
    // this is True!
    Get IsComObjectCreated of oCalendar1 to bIsComObjectCreated

    If (bIsComObjectCreated) Begin
        // Get the checkbox's current checked state...
        Get Checked_State to bChecked
        // create an instance of OLE Font wrapper class...
        Get Create U_cComStdFont to hoFont
        // Get an IDispatch* to the calendar's Title font
        Get ComTitleFont of oCalendar1 to vFont
        // bind our wrapper Object to the title font.....
        Set pvComObject of hoFont to vFont
        // now we can change the title font...
        Set ComUnderline of hoFont To bChecked
        // destroy the OLE Font wrapper now that we are
        // finished with it...
        Send Destroy of hoFont
    End
End_Procedure

See Also

cComAutomationObject | cComStdPicture