Directives 

DEF OBJECT

Define Windows Object

Formats

1.

Invisible COM Object:

DEF OBJECT com_id,objname$

2.

Visible COM Object:

DEF OBJECT com_id,@(col,ln,wth,ht) { |=}objname$

3.

List Available Objects:

DEF OBJECT com_id, "*"

Where:

"*"

An asterisk displays registered COM controls.

@(col,ln,wth,ht)

Numeric expressions. Column and line coordinates for top left corner, width in number of columns and height in number of lines.

com_ID

Numeric variable to receive a handle (memory pointer to object).

objname$

Name by which the COM object is registered in the Windows system registry sub-key HKEY_CLASSES_ROOT.

Description

The DEF OBJECT directive is used to create a new instance of a specified COM object. Upon successful execution of DEF OBJECT, a reference to the object objname$ will be placed into the supplied numeric variable com_id.

Note:
WindX in PxPlus supports the use of this directive via the [WDX] or [LCL] tags; e.g. DEF OBJECT "[WDX]somefile.ext". Non-PxPlus versions require you to encapsulate the command in an EXECUTE directive with a [WDX] tag (i.e. EXECUTE "[WDX]..."). See [WDX] Direct Action to Client Machine or [LCL] Access to Users Local Machine.

This is a feature of the PxPlus Event Handling Interface and Component Object Model (COM), an industry-standard technology used by applications to expose methods, properties, and events to development tools, macro languages, and other applications. See Automation in PxPlus.

Format 1

Define Invisible COM Object

DEF OBJECT com_id,objname$[,ERR=stmtref]

Use this format to create a link to an invisible OLE/OCX/ActiveX object. This format associates the object with the current window, yet it is hidden from view:

def object this_com_id,"Mabry.SoundX" 

Once the definition is complete, this_com_id will contain a handle to the object. This handle will be used to get and set properties and methods and service events. Note that since the value returned in com_id is a handle (memory pointer) to the object, it should not be changed by the application. 

Format 2

Define Visible COM Object

DEF OBJECT com_id,@(col,ln,wth,ht) {, |=}objname$[,ERR=stmtref]

This format defines a visible object and associates it with a location in the current window:

def object numvar,@(col,row,wide,high),"object_name",err=2000
def object numvar,@(col,row,wide,high)="object_name",err=2000

Format 3

List Available Objects

DEF OBJECT com_id,"*"

Use this format to display a pop-up window listing the COM controls currently installed on the system. 

See Also

DELETE OBJECT Remove Windows Object
ON EVENT Event Processing
Apostrophe Operator
Automation in PxPlus 

Example

def object X,"*"
def object X,"Word.Application",err=*next
def object X,@(1,1,70,20)="Word.Document"
def object X,"[dcom]MyServer;Shell.Explorer"
def object X,@(10,2,20,10)="[file]c:\y documents\test.doc"
def object X,"VCF1.VCF1Ctrl.1;License=8041207972768742028669631967"
def object X,"[running or new]Excel.Application"