Class

Control


Warning

This item was deprecated in version 2021r3. Please use DesktopControl as a replacement.

Description

The base class for all controls. The RectControl class is subclassed from the Control class.

Properties

Name

Type

Read-Only

Shared

Handle

Integer

Index

Integer

MouseX

Integer

MouseY

Integer

Name

String

PanelIndex

Integer

Scope

Integer

Window

Window

Methods

Name

Parameters

Returns

Shared

Close

Events

Name

Parameters

Returns

Close

Open

Property descriptions


Control.Handle

Handle As Integer

Returns a handle to the Control.

This property is read-only.

For interfacing with Mac APIs using Declare).

On Windows returns the HWND of the Control.

On Linux it returns a GtkWidget.

The following gets a handle to the Control.

Var i As Integer = Me.Handle

Control.Index

Index As Integer

If the Control is used in a Control set, this specifies the Control's index in the set.

This property is read-only.

The control set is often used to manage a group of RadioButtons since a single RadioButton in a window doesn't make much sense. Most typically, you create an instance of the RadioButton, assign 0 to its Index property, and then duplicate it. This increments the value of Index for each new instance but retain the original Control's name.

To determine which RadioButton the user clicked, use the Action event handler of the Control set. The parameter Index contains the value of Index for the RadioButton that was clicked. The event handler is this:

Sub Action(Index As Integer)
  Label1.Text = "You chose radio button " + index.ToString + "."
End Sub

To set a RadioButton in a Control set, you use its Index property to refer to the RadioButton whose value you want to set. For example, the following line selects the second RadioButton from code:

RadioButton1(1).Value = True ' 0-based

Control.MouseX

MouseX As Integer

The X coordinate of the mouse (points). Measured from the top-left corner of the Control.

This property is read-only.

This code is in the MouseDown event of a TextField and displays the X-coordinate at the point of the MouseDown event.

Me.Value = Str(Me.MouseX)

Control.MouseY

MouseY As Integer

The Y coordinate of the mouse (points). Measured from the top-left corner of the Control.

This property is read-only.

This code is in the MouseDown event of a TextField and displays the Y-coordinate at the point of the MouseDown event.

Me.Value = Str(Me.MouseY)

Control.Name

Name As String

The name of the Control. Set the name of the Control in the Inspector.

This property is read-only.


Control.PanelIndex

PanelIndex As Integer

If the Control has been placed on a TabPanel or PagePanel Control, this is the panel (page/tab) that the Control is on. If the Control is not on a panel, it returns -1.

The first panel is numbered zero. If the Control has been placed on a panel of a TabPanel or PagePanel Control, it returns the panel number. If the Control is not on a PagePanel or TabPanel, it returns -1. If you change the PanelIndex to a nonexistent panel, the Control will disappear until you give it a PanelIndex value that corresponds to a panel that exists.

If you are looking to change the currently selected panel (page/tab), use PagePanel.SelectedPanelIndex.

This code displays the panel index of the Control that is on the page.

Label3.Value = Str(Me.PanelIndex)

Control.Scope

Scope As Integer

Used to determine whether access to the Control is Public (0) or Private (2). The default is Public.

This property is read-only.

If the Scope of a Control is set to Private, it cannot be accessed from outside its parent window.


Control.Window

Window As Window

The Control's parent window.

This property is read-only.

This code gets the parent window's Title property.

TextField1.Text = Me.Window.Title

Method descriptions


Control.Close

Close

Closes a Control.

Closing a Control permanently removes the Control from memory, making it impossible to access. You can close both non-indexed controls and indexed controls. When you close an indexed Control, the indexes for the remaining controls will shift downward so that the indexes start with zero and are consecutive.

The following code closes the Control. When this is executed from a visible Control, the Control disappears from the window.

Me.Close

Event descriptions


Control.Close

Close

The Control is about to close.


Control.Open

Open

The Control is about to be displayed. Use this event to initialize a Control.

The Open event is called after the Constructor.

Be warned that initializing Control property values using the Constructor instead of the Open event may result in those property values being overwritten by what is set in the Inspector. For best results, use the Open event for Control initialization rather than the Control Constructor.

If the Control is supposed to handle drag and drop, you need to tell it which type of item it needs to be able to handle. The following example informs the Control that pictures and files can be dropped on it. The type of the file it needs to support is specified via the File Types Editor.

Sub Open()
  Me.AcceptPictureDrop
  Me.AcceptFileDrop("JPEG")
End Sub

Compatibility

All project types on all supported operating systems.

See also

Object parent class; NotePlayer control; Object, RectControl, DesktopContainer classes.