wxAutomationObject
generated from ../src/mod_gui/misc/autoobj.cppThe wxAutomationObject class represents an OLE automation object containing a single data member, an IDispatch pointer. It contains a number of functions that make it easy to perform automation operations, and set and get properties. The wxVariant class will not be ported, because wxJS translates every type to the corresponding JavaScript type. This class is only available on a Windows platform.
Constants
Constructor
wxAutomationObject
wxAutomationObject()
Constructs a new wxAutomationObject object. Unlike wxWidgets, this constructor can't take an IDispatch pointer because this type can't be used in JavaScript.
Methods
callMethod
callMethod(Method,
Arg1) : Any
| Name | Type | Default | Description |
|---|---|---|---|
| Method | String | The name of the method to call. | |
| Arg1 | ... | A variable list of arguments passed to the method. |
Calls an automation method for this object. When the method
returns a value it is not returned as a wxVariant but it is converted
to its corresponding JavaScript type.
The following example opens a workbook into Microsoft Excel:
var objExcel = new wxAutomationObject();
if ( objExcel.createInstance("Excel.Application") )
{
objExcel.putProperty("visible", true);
var objBooks = new wxAutomationObject();
objExcel.getObject(objBooks, "workbooks");
objBooks.callMethod("open", "c:\\temp\\wxjs.xls");
}
The name of the method can contain dot-separated property names,
to save the application needing to call getProperty
several times using several temporary objects.
For example:
objExcel.callMethod("workbooks.open", "c:\\temp\\wxjs.xls");
createInstance
createInstance(classId) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| classId | String |
Creates a new object based on the class id, returning true if the
object was successfully created, or false if not.
The following example starts Microsoft Excel:
var obj = new wxAutomationObject();
if ( obj.createInstance("Excel.Application") )
{
// Excel object is created
}
getInstance
getInstance(classId) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| classId | String |
Retrieves the current object associated with a class id, and attaches the IDispatch pointer to this object. Returns true if a pointer was successfully retrieved, false otherwise.
getObject
getObject(Object,
Property,
Arg1) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| Object | wxAutomationObject | The automation object that receives the property. | |
| Property | String | The name of the property. | |
| Arg1 | ... |
Gets a property from this object. The type of the property is also an object. The following example retrieves the object Workbooks from an Excel application:
var objExcel = new wxAutomationObject();
if ( objExcel.createInstance("Excel.Application") )
{
objExcel.putProperty("visible", true);
var objBooks = new wxAutomationObject();
objExcel.getObject(objBooks, "workbooks");
}
The name of the method can contain dot-separated property names,
to save the application needing to call getProperty
several times using several temporary objects.
getProperty
getProperty(Property,
Arg1) : Any
| Name | Type | Default | Description |
|---|---|---|---|
| Property | String | The name of the property. | |
| Arg1 | ... |
Gets a property from this object. The return type depends on the type of the property. Use getObject when the property is an object. The name of the method can contain dot-separated property names, to save the application needing to call getProperty several times using several temporary objects.
putProperty
putProperty(Property,
Arg1) : Boolean
| Name | Type | Default | Description |
|---|---|---|---|
| Property | String | The name of the property. | |
| Arg1 | ... |
Puts a property value into this object. The following example starts Microsoft Excel and makes it visible.
var obj = new wxAutomationObject();
if ( obj.createInstance("Excel.Application") )
{
obj.putProperty("visible", true);
}
The name of the property can contain dot-separated property names,
to save the application needing to call getProperty
several times using several temporary objects.
© 2002 - 2007 Franky Braem.