Reference Manual - Table of Contents
Controls This section describes controls that can be placed in forms/windows to display and receive information. The controls that are available include textboxes (with or without scrollbars), listboxes, command buttons, radio buttons, checkboxes, pictures, icons, labels, droplists, timers, and scrollbars. Visual MacStandardBasic automatically handles the operation of these controls.
There are commands to create controls 'on the fly' during runtime. Of course you can use the Visual Development Environment to create controls on forms during design time.
The terms Form and Window can be used interchangeably. A Form is just a Window that was created in the Visual Development Environment. You can use the Window command to create a Window (during runtime)without creating interactively in Visual MacStandardBasic's Visual Development Environment (design time).
When you see the parameter windowID in this manual you can give the FormName or the variable( var parameter) you used in the Window command.
Command Summary:
Button var, window#, left, top, width, height, text$, Sub
Checkbox var, window#, left, top, width, height, text$, Sub
Radio var, window#, left, top, width, height, text$, Sub
TextBox var, window#, left, top, width, height, text$, Sub
TextBoxRO control#, status
TextSelect control#, startOffset, endOffset
Label var, window#, left, top, width, height, text$, Sub
DropList var, window#, left, top, width, Sub
ListBox var, window#, left, top, width, height, option, Sub
ListClear control#
ListAdd control#, text$
ListRemove control#, item#
Scroll var, window #, left, top, width, height, Sub
ScrollSet control#, min, max, pageValue
Picture var, window #, left, top, width, height, ResourceID, Sub
Icon var, window #, left, top, ResourceID, Sub
Timer var, windowID, interval, enabledFlag, Sub
CtlValue control#, value
CtlText control#, text$, options
CtlHilite control#
CtlRemove control#
CtlHide control#
CtlShow control#
CtlDisable control#
CtlEnable control#
CtlSize control#, width, height
CtlMove control#, left, topFunction Summary:
var = TextLen ( control# )
var = TextStart ( control# )
var = TextEnd ( control# )
var$ = TextSelect ( control# )
var = ClipAvail( )
var = ListCount ( control# )
var = ListNumSel ( control# )
var$ = ListItem ( control#, item# )
var$ = ListSelect ( control#, item# )
var = CtlValue ( control# )
var$ = CtlText ( control# )
var = CtlExist ( control# )
var = CtlNum ( control# )
var$ = CtlBroder ( control#, dimension )
Button var, windowID, left, top, width, height, text$, Sub
This command creates a command button control in the window specified. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.
var - This should be a numeric variable that will contain a value the should be used to reference the command button control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this button control.
top - This is a numeric expression designating the top y window coordinate for this button control.
width - This is a numeric expression designating the width for this button control.
height - This is a numeric expression designating the height for this button control.
text$ - This is a string expression designating the the text that should appear in this button control.
Sub - This is a reference to the a SUB procedure that will be called when this button control is selected ( For example, when a user selects it with a mouse click) .
Examples: Dim a, WinNum Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None Button a, WinNum, 10, 10, 60, 20, "Button1", ButtonClick Form Form1 'Display Form Window Button a, Form1, 10, 10, 60, 20, "Button1", ButtonClick
Checkbox var, windowID, left, top, width, height, text$, Sub
This command creates a checkbox control in the window specified. A checkbox can have only two values: on (1) or off (0). The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.
var - This should be a numeric variable that will contain a value the should be used to reference the checkbox control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this checkbox control.
top - This is a numeric expression designating the top y window coordinate for this checkbox control.
width - This is a numeric expression designating the width for this checkbox control.
height - This is a numeric expression designating the height for this checkbox control.
text$ - This is a string expression designating the the text that should appear in this checkbox control.
Sub - This is a reference to the a SUB procedure that will be called when this checkbox control is selected ( For example, when a user selects it with a mouse click) .
Radio var, windowID, left, top, width, height, groupID, text$, Sub
This command creates a radio button control in the window specified. Radio buttons are different from checkboxes. Normally two or more radio buttons are grouped together by a identical groupID # . Only one of the group can be selected at a time. If another radio button of the group is selected then the previously selected button is deselected.
The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.
var - This should be a numeric variable that will contain a value the should be used to reference the radio control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this radio button control.
top - This is a numeric expression designating the top y window coordinate for this radio button control.
width - This is a numeric expression designating the width for this radio button control.
height - This is a numeric expression designating the height for this radio button control.
groupID - This is a numeric expression the group number for this radio button control.
text$ - This is a string expression designating the the text that should appear in this radio button control.
Sub - This is a reference to the a SUB procedure that will be called when this radiobutton control is selected ( For example, when a user selects it with a mouse click) .
Examples: Dim a, b, WinNum Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None Radio a, WinNum, 10, 10, 60, 20, 1, "Choice 1", None Radio b, WinNum, 10, 40, 60, 20, 1, "Choice 2", None Form Form1 Radio a, Form1, 10, 10, 60, 20, 50, "Choice 1", None Radio b, Form1, 10, 40, 60, 20, 50, "Choice 2", None
TextBox var, windowID, left, top, width, height, option, text$, Sub
This command creates a textbox control in the window specified. Textbox allows the user to enter and modify text. In essence it is a small text editor.
You can use the option parameter to add an automatic vertical scrollbar and/or make the textbox read only. If the read only status is set on, the user can scan the textbox with arrow keys and mouse movement but will not be able to alter the contents of the textbox. If the status is set off, the user can modify the contents of a textbox.
Keyboard cut, copy and paste operations by the user are automatically handled for you by MacStandardBasic. A user can select and copy text from the textbox regardless of the read only status. See the Cut, Copy, Paste, and Clear commands for manual clipboard operations.
The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0, 0.
var - This should be a numeric variable that will contain a value the should be used to reference the textbox control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this textbox control.
top - This is a numeric expression designating the top y window coordinate for this textbox control.
width - This is a numeric expression designating the width for this textbox control.
height - This is a numeric expression designating the height for this textbox control.
option - This is a numeric value that sets different options of the textbox control.
option values
0 = Normal textbox
1 = Textbox with vertical scrollbars
2 = Read only textbox
3 = Read only textbox with vertical scrollbars
text$ - This is a string expression designating the the initial text that should appear in this textbox control.
Sub - This is a reference to the a SUB procedure that will be called when this textbox control is selected ( For example, when a user selects it with a mouse click) .
TextBoxRO control_ID , status
This command sets the read only status of the specified textbox control. If the read only status is set ON ( = 1) then the user can scan the textbox with arrow keys and mouse movement but will not be able to alter the contents of the textbox. Set the status OFF ( = 0 ) to allow the user to modify the contents of the textbox.
A user can select and copy text from the textbox regardless of the read only status.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
status - This is a numeric expression specifying the read only status of the textbox.
Examples: TextBoxRO, Form1.TextBox1, 1
TextSelect control_ID , startOffset, endOffset
This command allows you to select a block of text of a textbox. If the startOffset and endOffset are equal then this will set the cursor position in the textbox without selecting any text. To select all the text in the textbox have startOffset equal 0 and endOffset equal 32767.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
startOffset - This should be a numeric value representing the starting character offset of text to be selected.
endOffset - This should be a numeric value representing the ending character offset of text to be selected.
Cut
This command will cut the selected text from the current textbox and places it in the Clipboard.
Copy
This command will copy the selected text from the current textbox and places it in the Clipboard.
Paste
Inserts the current text contents of the Clipboard at the current cursor position or in place of selected text in the current textbox.
Clear
This command will remove the selected text from the current textbox.
Label var, windowID, left, top, width, height, text$, Sub
This command creates a text label control in the window specified. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0. The text contents of a label can not be changed by the user directly, only by the ControlText command.
var - This should be a numeric variable that will contain a value the should be used to reference the label control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this label control.
top - This is a numeric expression designating the top y window coordinate for this label control.
width - This is a numeric expression designating the width for this label control.
height - This is a numeric expression designating the height for this label control.
text$ - This is a string expression designating the the text that should appear in this label control.
Sub - This is a reference to the a SUB procedure that will be called when this label control is selected ( For example, when a user selects it with a mouse click) .
DropList var, windowID, left, top, width, height, Sub
This command creates a droplist control in the window specified. A droplist control contains a list of text options added with the ListAdd command. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.
Please note that the width will probably be changed depending on the text length of the longest item.
var - This should be a numeric variable that will contain a value the should be used to reference the droplist control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this droplist control.
top - This is a numeric expression designating the top y window coordinate for this droplist control.
width - This is a numeric expression designating the initial width for this droplist control.
Sub - This is a reference to the a SUB procedure that will be called when this droplist control is selected ( For example, when a user selects an item with a mouse click) .
ListBox var, windowID, left, top, width, height, option, Sub
This command creates a listbox control in the window specified. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.
var - This should be a numeric variable that will contain a value the should be used to reference the listbox control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this listbox control.
top - This is a numeric expression designating the top y window coordinate for this listbox control.
width - This is a numeric expression designating the width for this listbox control.
height - This is a numeric expression designating the height for this listbox control.
option - This is a numeric value that sets different options of the listbox control.
option values
0 = Listbox with frame, select one item at a time
1 = Listbox with frame, multiple item selection
2 = Listbox w/o frame, select one item at a time
3 = Listbox w/o frame, multiple item selection
Sub - This is a reference to the a SUB procedure that will be called when this listbox control is selected ( For example, when a user selects an item with a mouse double-click) .
ListClear control_ID
This command removes all list items from the specified droplist or listbox control.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
ListAdd control_ID , text$
This command adds a list item to the specified droplist or listbox.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
text$ - This is a string expression that designates the text of an item that will be added to the DropList or ListBox control.
Example: Dim a a = ListAdd( Form1.ListBox1 )
ListSelect control_ID , item#
This command selects an item in a listbox.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
item# - This a numeric value representing the item number in the listbox.
ListDeselect control_ID , item#
This command deselects an item in a listbox.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
item# - This a numeric value representing the item number in the listbox.
ScrollBar var, windowID, left, top, width, height, Sub
This command creates a scrollbar control in the window specified. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.
var - This should be a numeric variable that will contain a value the should be used to reference the scrollbar control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this scrollbar control.
top - This is a numeric expression designating the top y window coordinate for this scrollbar control.
width - This is a numeric expression designating the width for this scrollbar control.
height - This is a numeric expression designating the height for this scrollbar control.
Sub - This is a reference to the a SUB procedure that will be called when this scrollbar control is selected ( For example, when a user selects it with a mouse click) .
ScrollSet control_ID , min, max, pageValue
This command sets the scrolling parameters of the scroll bar.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
min - This is a numeric expression designating value the control value will equal when the thumb of the scrollbar is at its lowest setting. This is the uppermost position in a vertical scrollbar or left in horizontal scrollbar.
max - This is a numeric expression designating value the control value will equal when the thumb of the scrollbar is at its highest setting. This is the lowest position in a vertical scrollbar or right in horizontal scrollbar.
pageValue - This is a numeric expression designating value the control value will be lowered when the mouse cursor is clicked between the arrow and left or above the thumb of the scrollbar OR the amount the control value will be raised when the mouse cursor is clicked between the arrow and right or below the thumb of the scrollbar.
Picture var, windowID, left, top, width, height, ResourceID, Sub
This command displays a picture in the window specified. The location and size specified for the picture are local coordinates to that window. The upper left corner of the window content area is designated as 0,0. If the width and height parameters equal 0 (zero) then the picture will not be scaled but drawn it's original size.
var - This should be a numeric variable that will contain a value the should be used to reference the picture control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this picture control.
top - This is a numeric expression designating the top y window coordinate for this picture control.
width - This is a numeric expression designating the width for this picture control.
height - This is a numeric expression designating the height for this picture control.
ResourceID - This is a numeric expression designating the PICT resource ID for this picture control.
Sub - This is a reference to the a SUB procedure that will be called when this picture control is selected ( For example, when a user selects it with a mouse click) .
Icon var, windowID, left, top, width, height, ResourceID, Sub
This command displays an icon picture in the window specified. The location and size specified for the icon are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.
var - This should be a numeric variable that will contain a value the should be used to reference the icon control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
left - This is a numeric expression designating the left x window coordinate for this icon.
top - This is a numeric expression designating the top y window coordinate for this icon.
width - This is a numeric expression designating the width for this icon control.
height - This is a numeric expression designating the height for this icon control.
ResourceID - This is a numeric expression designating the right x window coordinate for this icon control.
Sub - This is a reference to the a SUB procedure that will be called when this icon control is selected ( For example, when a user selects it with a mouse click) .
Timer var, windowID, interval, enabledFlag, Sub
You can have a Sub procedure called at timed intervals by creating a Timer control.
var - This should be a numeric variable that will contain a value the should be used to reference the icon control after it is created. This will be the control_ID. This variable will equal a -1 if an error occurs.
windowID - This should be a Form name or a variable, used in the WINDOW command, that contains a value that is used to reference the window.
interval - This is a numeric expression indicating the interval in timer ticks ( a tick is 1/60 of a second or 16.66 milliseconds).
enabled - This is a numeric expression indicating whether the timer is initially enabled.
Sub - This is a reference to the a SUB procedure that will be called when interval is done.
CtlValue control_ID, value
This command sets the current value of the control. This command can set the value of a scrollbar, the on/off status of checkboxes & radio buttons and the item selection of listboxes & droplists. For pictures and icons this is rhe resource ID.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
value - This should be a numeric value used to set the new value of the specified control.
Examples: Dim a, b, WinNum Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None Radio a, WinNum, 10, 10, 60, 20, 1, "Choice 1", None Radio b, WinNum, 10, 40, 60, 20, 1, "Choice 2", None CtlValue a, 1 ' Select first Radio button of group ' Change Resource ID of Picture do picture will change CtlValue Picture1, 1003
CtlText control_ID, text$, options
This command sets the text in the specified control.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
text$ - This should be a string expression that will contains text that is to replace or add to the control.
options - This should be a numeric variable that will contain a value the should be used to select options when setting the text of the specified control. This ONLY affects the TextBox control, all other controls will replace text, not append.
options values
0 = The text$ will replace the control's contents.
1 = The text$ will be append to the control's contents.
CtlHilite control_ID
This command places a highlight border around the specified control.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
CtlRemove control_ID
This command will remove a control from a window.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
CtlHide control_ID
This command will hide a control from from view. The control can be unhidden by using the ShowControl command.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
CtlShow control_ID
This command will show a control hidden by a previous HideControl command.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
CtlDisable control_ID
This command will disable a control. The user will not be able to select or change the control and no events will be generated. The control can be enabled by using the EnableControl command.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
CtlEnable control_ID
This command will enable a control. This command is usually used to enable enable a control that was disabled using the DisableControl command.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
CtlSize control_ID, width, height
This command will resize an existing control with a new width and height. Changes in width and height will only affect the right and bottom borders of the control.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
width - This is a numeric expression designating the new width for this control.
height - This is a numeric expression designating the new height of this control.
CtlMove control_ID, left, top
This command moves an existing control to a new location within its window while maintaining the current size.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
left - This is a numeric expression designating the new left x coodinate for this control.
top - This is a numeric expression designating the new top y coordinate for this control.
var
= TextLen( control_ID )
This function returns a numeric value representing the total number of characters in the specified textbox, including anny CR's(carriage returns) and LF's (line feeds).
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
Example: Dim a a = TextLen( TextBox1 )var$ = TextSelect( control_ID )
This function returns the a text string that represents the text selected in the specified textbox.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
var = TextStart( control_ID )
This function returns the offset value of the selected text starting point. If it is equal to the end point (found with the TextEnd function) then this is the current cursor position.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
var = TextEnd( control_ID )
This function returns the offset value of the selected text ending point. If it is equal to the the start point (found with the TextStart function) then this is the current cursor position.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
var = ClipAvail( )
This function returns a 1 (TRUE) if there is text in the clipboard available to paste into a textbox control. If the clipboard is empty this function will return a 0 (FALSE).
ListRemove control_ID , item#
This command removes a list item from the specified droplist or listbox.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
item# - This a numeric value representing the item number in the listbox that should be removed.
Example:
ListRemove DropList2, 4
var = ListCount( control_ID )
This function returns the number of items in a droplist or listbox.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
var = ListNumSel( control_ID )
This function returns the number of selected items in a listbox.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
var$ = ListItem( control_ID , item# )
This function returns a text string that represents the contents of the item# in the specified droplist or listbox control.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
item# - This a numeric value representing the item number in the DropList or ListBox control.
var = ListSelect( control_ID , item# )
This function returns a value that indicates whether an item in a listbox is selected. The value returned equals 1 if the item is selected or 0 if it is not.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
item# - This a numeric value representing the item number in the listbox.
var = CtlValue( control_ID )
This function returns the the current numeric value of the control.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
Examples: Dim a a = CtlValue( CheckBox2 )
var$ = CtlText ( control_ID )
This functions returns a string that represents the text of the specified control.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
var = CtlExist( control_ID )
This function returns a true(1) / false(0) value that is tindicates that a window with the windowID has already been created.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
var = CtlNum( control_ID )
This function returns a long value that is the reference number to a control that can be passed to Sub and Function procedures in long varaiables.
control_ID - This should be the control name from a form.
var = CtlBorder( control_ID , dimension )
This function returns a numeric value that represents a dimension of the specified control.
control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.
dimension - This should be a numeric expression that contains a value that is used to designate which control dimension to return:
Values for dimension
1 = Return the left x screen coordinate for this control.
2 = Return the top y screen coordinate for this control.
3 = Return the width in pixels of this control.
4 = Return the height in pixels of this control.