Reference Manual - Table of Contents

Execution Control
Forms and Windows
Controls
Menus
System and Desktop
Graphic Drawing Commands

Animation
QuickTime Movies
Speech
Sound
File I/O
Printing
Serial Ports

Math Functions
String Functions
Date and Time
Memory Buffers
Error Handling
Console Text Window

Events

Direct Memory Access
Direct Mouse Access
Direct Keyboard Access
Code Resource Modules

A - Runtime Error Messages
B - Compiler Error Messages

Forms and Windows

The commands and functions in this section are used to create and manipulate Macintosh windows. Visual MacStandardBasic automatically handles the operation of a window such as moving, resizing, and updating.

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:
Form formName
Window
var, left, top, width, height, title$, windowType, Sub
WinSize
windowID, width, height
WinMove
windowID, left, top
WinTitle
windowID, title$
WinClose
windowID
WinHide
windowID
WinShow
windowID
WinRedraw
windowID
WinOrigin
windowID, left, top
WinClip
windowID, left, top, width, height
LoadPalette
palette#, resourceID
WinPalette
windowID, palette#
ClearWindow
windowID
ClearControls
windowID
ClearGraphics
windowID
AlertBox
resourceID

Function Summary:
var = WinBorder ( windowID, dimension )
var = WinHandle ( windowID )
var = WinExist ( windowID )
var$ = WinTitle ( windowID )
var$ = FrontWindow ( )
var = WinNum ( windowID )
var = MsgBox( message$, buttontypes )

 

Form formName

This command load and displays, if the visible property is enabled, the specified form. A form is the term used for a window, possibly containing controls, that was created in the visual development environment of Visual MacStandardBasic.

 

Example:

Form Form1

 

Window var, left, top, width, height, windowType, title$, Sub

This command creates a window with the location and size specified.

Example:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None

 

WinSize windowID, width, height

This command resizes an existing window with a new width and height. Changes in width and height will only affect the right and bottom borders of the window.

Examples:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
WinSize WinNum, 200, 100 'Set for 200 pixels wide & 100 high

Form Form1
WinSize Form1, 200, 100

WinMove windowID, left, top

This command moves the window to a new location while maintaining it’s current width and height.

 

Examples:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
WinMove WinNum, 200, 100

Form Form1
WinMove Form1, 200, 100

WinTitle windowID, title$

This command sets or changes the title of the specified window.

Examples:
Dim WinNum, A$
A$ = "New Window Title"

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
WinTitle WinNum, "New Window Title"

Form Form1
WinTitle Form1, A$

 

WinClose windowID

This command closes the specified window.

Examples:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
WinClose WinNum

Form Form1
WinClose Form1

 

WinHide windowID

This command hides the specified window from view.

Examples:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
WinHide WinNum

Form Form1
WinHide Form1

 

WinShow windowID

This command selects and shows the specified window.

Examples:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
WinShow WinNum

Form Form1
WinShow Form1

 

WinRedraw windowID

This command redraws the specified window.

Examples:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
WinRedraw WinNum

Form Form1
WinRedraw Form1

 

WinOrigin windowID, left, top

This command sets the content coordinates of an existing window. This allows for easy scrolling of the windows contents. This is normally set at 0,0.

 

Examples:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
WinOrigin WinNum, -10, -10

Form Form1
WinOrigin Form1, -10, -10

 

WinClip windowID, left, top, width, height

This command sets the clip area of an existing window.

Examples:
Dim WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
' Clip inside window content area by 10 pixels on all 4 sides
WinClip WinNum, 10, 10, 390, 290

Form Form1
WinClip Form1, 10, 10, 390, 290

 

LoadPalette palette#, resourceID

This command loads one of the 10 palettes with a Color LookUp Table resource ('clut').

WinPalette windowID, palette#

This command activates a pallete for a specified on the window.

ClearWindow windowID

This command removes all controls and graphics previously created.

ClearControls windowID

This command removes all controls previously created.

ClearGraphics windowID

This command clears all graphics created by previous graphic commands.

AlertBox resourceID

This command will load and us an alert dialog from a resource 'ALRT'. The dialog will pop up and notify the user. Custom alert dialogs can be created with ResEdit.

Examples:

AlertBox 128

 

var = WinBorder( windowID , dimension )

This function returns a numeric value that represents a dimension of the specified window.

Values for dimension
1 = Return the left x screen coordinate for this window.
2 = Return the top y screen coordinate for this window.
3 = Return the width in pixels of this window.
4 = Return the height in pixels of this window.

 

var = WinHandle( windowID )

This function returns a long value that is the actual MacOS handle to a form/window. This function is normally used to get the MacOS window handle to pass to a Code Resource Module. (See Code Resource Modules section for more information )

var = WinExist( windowID )

This function returns a true(1) / false(0) value that is indicates that a window with the windowID has already been created.

var$ = WinTitle( windowID )

This function a string value that is the window title of the specified window.

var$ = FrontWindow( )

This function a string value that is the window title of the frontmost window in the application. This will be a empty string if there no window in front or the front window has no title.

 

var = WinNum( windowID )

This function returns a long value that is the reference number to a window that can be passed to Sub and Function procedures in long varaiables.

var = MsgBox( message$, buttontypes )

This command creates a message box window centered on the desktop. It will not relinquish control until a command button option is selected by the user. Message boxes are normally used to notify the user of important information or to confirm an action that is about to take place.

MessageBox Results
1 = The OK, Yes, Save, Retry, or Continue button was selected.
0 = The No, Don’t Save, or Don’t Quit button was selected.
-1 = The Cancel button was selected.

MessageBox Button Types
0 = OK button only.
1 = OK and Cancel buttons.
2 = Yes and No buttons
3 = Yes, No, and Cancel buttons
4 = Save, Don’t Save, Cancel, buttons
5 = Quit and Don’t Quit buttons.

Examples:
Dim a

a = MsgBox( "Choose OK or Cancel", 1 )
If a = 1 then
? "OK was pressed"
Else
? "Cancel was pressed"
Endif