Search:     Advanced search

Form and Component Routines

Article ID: 67
Last updated: 22 Sep, 2010
Views: 1915
Posted: 12 Jun, 2008
by Ramsey M.
Updated: 22 Sep, 2010
by Murray D.

Here is a list of available form and component routines:

function NewForm(FormWidth, FormHeight, Caption)

 

 
 
 
 

Description
Creates a new form to allow custom user input to the script.

Returns an object of class TForm.

 
Parameters
FormWidth

This is an integer value for the pixel width of the form.

 
FormHeight

This is an integer value for the pixel height of the form.

 
Caption

This is a string value for the caption of the form.

 
Example
Form = NewForm(230, 150, "Sample Form")

if Form.ShowModal <> mrOk then

 Exit Function
end if
 

This example would create a new form with the caption Sample Form.

 
function NewLabel(Left, Top, Caption)
 
 
 
 
 
 
 
 

Description
Creates a new text label.

Returns an object of class TLabel.

 
Parameters
Left

This is an integer value for the left position of the label on the form.

 
Top

This is an integer vale for the top position of the label on the form.

 
Caption

This is a string value for the caption of the label.

 
Example
Form = NewForm(230, 150, "Sample Form")
NewLabel(26,23,"Name:")
 

if Form.ShowModal <> mrOk then

 Exit Function
end if
 

This example would display a label on a sample form with the caption of Name:.

 
function NewEdit(Left, Top, DefaultText = "")
 
 
 
 
 
 
 
 
 

Description
Creates a new edit box.

Returns an object of class TEdit.

 
Parameters
Left

This is an integer value for the left position of the edit on the form.

 
Top

This is an integer vale for the top position of the edit on the form.

 
DefaultText

This is a string value for the default edit text.

 
Example
Form = NewForm(230, 150, "Sample Form")
NewLabel(26,23,"Name:")

NewEdit(60,20,"New Area")

 

if Form.ShowModal <> mrOk then

 Exit Function
end if
 

This example would display a sample form with the name label and a edit box with the default text of New Area.

 
function NewButton(Left, Top, Caption, ButtonType = mrNone)
 
 
 
 
 
 
 
 
 
 
 
 
 

Description
Creates a new button.
Returns an object of class TButton.
 
Parameters
Left

This is an integer value for the left position of the button on the form.

 
Top

This is an integer vale for the top position of the button on the form.

 
Caption

This is a string value for the caption of the label.

 

ButtonType (optional - default is mrNone)

This is the value that the form will return when they click the button.  If this value is not mrNone, when they click the button, it will close the form, and return the button value (see example).  This allows the script to determine which button was clicked on the form.

 
Possible Values:
mrOk - This makes the button an "Ok" button
mrCancel - This makes the button a "Cancel" button
mrYes - This makes the button a "Yes" button
mrNo - This makes the button a "No" button
mrNone -  This is the default value with no result
 
Example

Form = NewForm(200, 200, "Are you sure?")

YesButton = NewButton(20, 20, "Yes", mrYes)

NoButton = NewButton(20, 20, "No", mrNo)

 
if Form.ShowModal = mrYes then

  'The user clicked the yes button

  ShowMessage("You have clicked the Yes button")
end if
if Form.ShowModal = mrNo then

  'The user clicked the no button

  ShowMessage("You have clicked the No button")
end if
 

function NewRadioButton(Left, Top, Caption)

 
 
 
 
 
 
 
 
 
 
 
 
 

Description
Creates a new radio button.

Returns an object of class TRadioButton.

 
Parameters
Left

This is an integer value for the left position of the radio button on the form.

 
Top

This is an integer vale for the top position of the radio button on the form.

 
Caption

This is a string value for the caption of the radio button.

 

Checked (optional - default is false)

Possible values: True, 1, False, 0

If true selected then radio with be selected by default.

 
Example
Form = NewForm(230, 150, "Sample Form")
NewLabel(26,23,"Name:")

NewEdit(60,20,"New Area")

radiobutton = NewRadioButton(26,48, "New Area", 1)
radiobutton.Width = 200

radiobutton = NewRadioButton(26,68, "Continue with existing?", 0)

radiobutton.Width = 200
 

if Form.ShowModal <> mrOk then

 Exit Function
end if
 

This example would create a sample form with a the name label, and two radio buttons for select of New Area or Continue with existing?.

 

function NewCheckBox(Left, Top, Caption, Checked = false)

 
 
 
 
 
 
 
 
 
 

Description
Creates a new checkbox.

Returns an object of class TCheckBox.

 
Parameters
Left

This is an integer value for the left position of the check box on the form.

 
Top

This is an integer vale for the top position of the check box on the form.

 
Caption

This is a string value for the caption of the checkbox.

 

Checked (optional - default is false)

Possible values: True, 1, False, 0

If true selected then checkbox with be checked by default.

 
Example
Form = NewForm(230, 150, "Sample Form")
NewLabel(26,23,"Name:")

NewEdit(60,20,"New Area")

checkbox = NewCheckBox(28,48,"New Area")

checkbox.width = 200
 

if Form.ShowModal <> mrOk then

 Exit Function
end if
 

This example will create asample form with the name label, and a check box for Load From Template.

 

function NewColorBox(Left, Top)

 
 
 
 
 
 

 
 
Description
Creates a new color picker.

Returns an object of class TColorBox.

 
Parameters
Left

This is an integer value for the left position of the color box on the form.

 
Top

This is an integer vale for the top position of the color box on the form.

 
Example
Form = NewForm(230, 150, "Sample Form")
NewLabel(26,23,"Name:")

NewEdit(60,20,"New Area")

colorbox = NewColorPicker(28,48)
colorbox.width = 156
 

if Form.ShowModal <> mrOk then

 Exit Function
end if
 

This example would create a sample form with the name label, and a color picker box.

 

function NewComboBox(Left, Top, Text = "")

 
 
 
 
 
 
 

Description

Creates a new drop-down combo box.

Returns an object of class TComboBox.

 
Parameters
Left

This is an integer value for the left position of the combo box on the form.

 
Top

This is an integer vale for the top position of the combo box on the form.

 
Text

This is a string value for the default combo box text.

 
Example
Form = NewForm(230, 150, "Sample Form")
NewLabel(26,23,"Name:")
Spacing = NewComboBox(24, 48, "Item 1")
Spacing.Items.Add("Item 1")
Spacing.Items.Add("Item 2")
Spacing.Items.Add("Item 3")
 

if Form.ShowModal <> mrOk then

 Exit Function
end if
 

This would create a combo box on a sample form with the default value of Item 1, and possible drop-down values of Item 1, Item 2, and Item 3.  The user will also be able to type a custom value (regardless of what options are in the drop-down), similar to an edit box.

 
This article was:  
Prev  Not what you're looking for? Suggest a topic  Next
Scripting Routines     Graphics Routines