Your DesktopX Documentation Resource Guide

Documentation Home

Quick Start

User's Guide

Developer's Guide

Resources

Tutorials


ActiveX Controls in DXScript

The power of script is enhanced by the ability to display ActiveX controls on the desktop instead of using images or text. You can then manipulate these using scripts.
For example, imagine an Excel spreadsheet, Windows Media Player, Combo box, Web Browser all embedded on your desktop. All are possible and very easy to create.
In the DesktopX Script Editor, the first option on the script menu is 'ActiveX Control' from which there is a 'Select Control' option.
We'll look at how to create one of these controls now.
From the list that appears when you click 'Select Control', choose a control and then click OK. In our examples below we will use the 'Microsoft Web Browser' control.
As you will see below, the Script Editor immediately changes to reflect your choice. On the right of the editor you will see a preview of the object, and below that you will see the properties of that object.

Note that the ActiveX Control menu item now has a 'Properties' option where you can toggle to display of this extra information.
If you close the editor via the close button top right or via 'File ... Exit' you will now see a control on your desktop.
You will see that as you move your mouse over the object the cursor changes. You can move the control or resize it using the black handles at the edge.
If you right click the object, you will notice a new item, 'Script Enabled' at the bottom of the list. This is the place where you can toggle the script between a 'running' and 'not running' state. At the moment it is not running which is why the resize handles are visible. Click 'Script Enabled' to toggle the running state and you will see these disappear.
OK, so at the moment it's a dull white box, not very exciting, but nevertheless it's a control and we're about to ramp up the excitement. Let's go back to the editor.
If you right click the control you will note that nothing happens. This is because you are effectively right clicking the Web Browser control, not a DesktopX object. Hold down CTRL so the resize edges appear and right click. You will see that the script is enabled because of the check mark next to that item. Click the Edit Script item and the dialogue will reappear.

OK, try changing the script you see to the one below:

Sub Object_OnScriptEnter
Control.Navigate2 "www.wincustomize.com"
End Sub

OK, so exit out of here and enabled the script. Caboom - all of a sudden you have a genuine webpage on your desktop!
You will note from this that scripting is basically the same for Controls as it is for regular objects. The only real difference is that when referring to the ActiveX control you use the Control prefix. Note that you can also use Object methods and properties in the script but these refer to the host object. For example Object.Visible in an object containing an ActiveX control would hide that object and hence that control.

Each ActiveX control will expose it's own properties and these are displayed in the autocomplete feature. This makes it really easy to start coding for a control.
In addition to this it is useful to know which events are associated with a control. With this, we are able to react to events occurring in the control. DesktopX provides a tool to do just this. In the Script Editor, go to the Script Menu and select 'Event Wizard'.

Select the event you want to add and click OK to add it to your script. Click 'Done' when you have added all the events you want to.
You can now add script to that event. For example:

Sub Control_DocumentComplete(pDisp, URL)
Msgbox "Finished downloading the page " & URL
End Sub

Now, you will be advised when the page is completely loaded.

One final thing you should know is that DesktopX installs three controls by default. There is an Edit control (to allow you to accept and react to user input), a Push Button control (which acts just like a regular button), and a Check Box control (to give you an on/off switch).
Each of these controls have specific events and properties associated with them.

PushButton Control

The PushButton control allows you to use a regular push button for interaction with your scripts.

Properties

Caption: The text caption of the button.
Enabled: Whether or not the button is disabled.

Events

OnClick: Fired when the button is clicked

CheckBox Control

The CheckBox control allows you to use a regular checkbox for interaction with your scripts.

Properties

Caption: The text caption of the checkbox.
Enabled: Whether or not the checkbox is disabled.
Checked: Whether or not the checkbox is checked.

Events

OnCheck(variant checked): Fired when the checkbox is checked or unchecked

Edit Control

The Edit control allows you to support text-based user input without dependency on 3rd party controls.

Properties

Text: The text of the control
MultiLine: Whether the control is single line or multi, with scrollbars
ClientEdge: Whether the control has a client edge
Border: Whether the control has a border
BGColor: The background color of the box
TextColor: The color of text in the control

Events

OnKeyPress(key): Fired when a key is entered, returns the ASCII value of the key.

Methods

ScrollToEnd(): Scrolls to the bottom of the text.

ComboBox Control

The ComboBox control allows you to create a drop-down list of options from which the user can select.

Properties

BackColor: Sets or queries the color of the control background (as OLE_COLOR)
ForeColor: Sets or queries the color of the control text color (as OLE_COLOR)
SelectionBackColor: Sets or queries the background color of the selected item in the control (as OLE_COLOR)
SelectionForeColor: Sets or queries the text color of the selected item in the Control (as OLE_COLOR)
BorderVisible: Sets or queries whether or not the border of the control is visible (as Boolean)
Enabled: Sets of queries whether an object can respond to user-generated events (as Boolean)
Item(Item As Long): Sets of queries the text of a specific item in the control (as String)
ItemCount: Queries the number of items in the control (as Long)
ListIndex: Sets or queries the currently selected item in the control (as Long)
Text: Queries the text of the currently selected item in the control (as String)
ListVisible: Sets or queries whether the control’s drop-down list is visible (as Boolean)

Events

OnSelect(Item As Long, string As String): Fired when an item in the list is selected
OnCloseUp(): Fired when the drop down menu is closed
OnDropDown(): Fired when the drop down menu is opened

Methods

AddItem (bstrItem As String): Inserts an item into the Control
ResetList(): Clears the Control

ListBox Control

The ListBox control allows you to display a box containing a list of options from which the user can select.

Properties

BackColor: Sets or queries the color of the control background (as OLE_COLOR)
ForeColor: Sets or queries the color of the control text color (as OLE_COLOR)
SelectionBackColor: Sets or queries the background color of the selected item in the control (as OLE_COLOR)
SelectionForeColor: Sets or queries the text color of the selected item in the Control (as OLE_COLOR)
BorderVisible: Sets or queries whether or not the border of the control is visible (as Boolean)
Enabled: Sets of queries whether an object can respond to user-generated events (as Boolean)
Item(Item As Long): Sets of queries the text of a specific item in the control (as String)
ItemCount: Queries the number of items in the control (as Long)
ItemHeight: Sets of queries the height of individual items in the ListBox (as Long)
ListIndex: Sets or queries the currently selected item in the control (as Long)
Text: Queries the text of the currently selected item in the control (as String)

Events

OnSelect(Item As Long, string As String): Fired when an item in the list is selected

Methods

AddItem (bstrItem As String): Inserts an item into the Control
ResetList(): Clears the Control
 


7/29 

SkinStudio 6.2 Released

7/25 

A God Has Fallen - New Demigod Trailer Released

7/24 

Sins of a Solar Empire v1.1 Beta has Arrived

7/23 

Stardock Releases New WindowBlinds 6.2 Update

7/22 

Stardock Releases The Political Machine v1.04 with New Characters

7/22 

Stardock Releases MyColors 2.5

7/17 

DesktopX 3.5 Officially Released

7/11 

Corel WinDVD 9 and Painter X Now Available on Impulse!