OnCreate - cComActiveXControl

Sent right after a COM object is created

Type: Event

Parameters: None

Syntax
Procedure OnCreate 

Description

The OnCreate event is always sent right after a COM object is created. You should write an OnCreate event handler to initialize the properties of a COM object when it is created.

It is important to understand the difference between when a COM object is created and when its DataFlex wrapper object is created. This is discussed in detail in the topic COM Object Life Span.

It is always safe to set the properties of a COM object inside of the OnCreate event handler. It is also good practice to always Forward Send OnCreate when augmenting this event handler.

Below is an example of setting the calendar ActiveX control's properties inside the OnCreate event.

Object oCalendar1 is a cComCalendar
    Set Size to 104 223
    Set Location to 3 5

    Embed_ActiveX_Resource
    // The ActiveX properties will be embedded in the control's source code here in binary format.
    End_Embed_ActiveX_Resource

    Procedure OnCreate
        Forward Send OnCreate
        // Set the calendar's date to today's date
        Send ComToday
        // don't show the calendar's title
        Set ComShowTitle To False
    End_Procedure

End_Object    // oCalendar1