Skip to content

Setting Properties with the OnCreate Event Handler

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.

Example

The following example demonstrates using OnCreate to initialize the default URL of the cComWebBrowser ActiveX control:

Procedure OnCreate
    Forward Send OnCreate
    Send ComNavigate "www.dataaccess.com" 0 0 0 0
End_Procedure

See Also