TActiveX
Source: source/classes/activex.prg
Inherits from: TControl
TActiveX is FiveWin's ActiveX/COM container control that enables embedding
ActiveX components (such as WebBrowser, Windows Media Player, Adobe Reader,
or any registered COM component) inside FiveWin windows and dialogs. It
provides direct access to the underlying OleObject for invoking
methods, reading and writing properties, and handling events.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
hActiveX | Handle | Window handle of the embedded ActiveX control |
cProgID | Character | ProgID string (e.g. "Shell.Explorer", "WMPlayer.OCX") |
aProperties | Array | List of property names browsable via OLE |
aMethods | Array | List of method names browsable via OLE |
aEvents | Array | List of event names provided by the control |
bOnEvent | Block | Code block executed on each fired event |
oOleAuto | Object | Underlying OLE automation object |
Methods
| Method | Description |
|---|---|
New( oWnd, cProgID, nRow, nCol, nW, nH ) | Create a new ActiveX control instance |
ReDefine( nId, oWnd, cProgID ) | Redefine from a dialog resource placeholder |
Do( cMethod, ... ) | Invoke a method of the underlying OLE object |
GetProp( cName ) | Read a property value from the OLE object |
SetProp( cName, uVal ) | Write a property value to the OLE object |
OnEvent( nEvent, aParams ) | Event handler called on each ActiveX event |
Example: Embedding a WebBrowser Control
#include "FiveWin.ch"
function Main()
local oWnd, oActiveX
DEFINE WINDOW oWnd TITLE "WebBrowser Embedded" SIZE 800, 600
oActiveX := TActiveX():New( oWnd, "Shell.Explorer", 10, 10, 780, 550 )
// Navigate to a URL using the OLE object
oActiveX:Do( "Navigate2", "https://fivetechsoft.com" )
oWnd:oClient := oActiveX
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The ActiveX control is registered on the local system. Use
cProgIDto specify the COM ProgID (e.g."Shell.Explorer","WMPlayer.OCX"). - Use
oOleAutofor direct COM automation calls when more flexibility is needed thanDo()/GetProp()/SetProp()provide. - Set
bOnEventto a code block with one or two parameters to intercept events. The block receives the event number and an optional array of parameters. - The control can also be placed via resource editor by inserting a custom control and then calling
ReDefine()at runtime. - TActiveX supports event sink dispatching; declare
aEventsto enumerate supported events at runtime.