82 lines
3.1 KiB
Text
82 lines
3.1 KiB
Text
.topic ctrl.form
|
|
.title Form
|
|
.toc 1 Form
|
|
.index Form
|
|
.index Window
|
|
.index Caption
|
|
.index AutoSize
|
|
.index Resizable
|
|
.index Load
|
|
.index Unload
|
|
.index Show
|
|
.index Hide
|
|
|
|
.h1 Form
|
|
|
|
VB Equivalent: Form -- DVX Widget: Window + VBox/HBox root
|
|
|
|
The Form is the top-level container representing a DVX window. It is declared in the .frm file with Begin Form FormName. All controls are children of the form's content box, which uses either VBox (default) or HBox layout.
|
|
|
|
.h2 Form Properties
|
|
|
|
.table
|
|
Property Type Default Description
|
|
---------- ------- -------------- -------------------------------------------
|
|
Name String "Form1" The form's name, used for event dispatch and Load statement.
|
|
Caption String (same as Name) Window title bar text.
|
|
Width Integer 400 Window width in pixels. Setting this disables AutoSize.
|
|
Height Integer 300 Window height in pixels. Setting this disables AutoSize.
|
|
Left Integer 0 Initial X position. Used when Centered is False.
|
|
Top Integer 0 Initial Y position. Used when Centered is False.
|
|
Layout String "VBox" Content box layout: "VBox" (vertical) or "HBox" (horizontal).
|
|
AutoSize Boolean True When True, the window shrink-wraps to fit its content.
|
|
Resizable Boolean True Whether the user can resize the window at runtime.
|
|
Centered Boolean True When True, the window is centered on screen. When False, Left/Top are used.
|
|
.endtable
|
|
|
|
.h2 Form Events
|
|
|
|
.table
|
|
Event Parameters Description
|
|
----------- --------------------- -------------------------------------------
|
|
Load (none) Fires after the form and all controls are created. This is the default event.
|
|
Unload (none) Fires when the form is being closed or unloaded.
|
|
QueryUnload Cancel As Integer Fires before Unload. Set Cancel = 1 to abort the close.
|
|
Resize (none) Fires when the window is resized by the user.
|
|
Activate (none) Fires when the window gains focus.
|
|
Deactivate (none) Fires when the window loses focus.
|
|
.endtable
|
|
|
|
.h2 Form Methods
|
|
|
|
.table
|
|
Statement Description
|
|
------------------ -------------------------------------------
|
|
Load FormName Load the form (creates the window and controls, fires Load event).
|
|
Unload FormName Unload the form (fires Unload, destroys window).
|
|
FormName.Show Make the form visible.
|
|
FormName.Show 1 Show as modal dialog (blocks until closed).
|
|
FormName.Hide Hide the form without unloading it.
|
|
.endtable
|
|
|
|
.h2 Example
|
|
|
|
.code
|
|
Sub Form_Load ()
|
|
Form1.Caption = "Hello World"
|
|
Print "Form loaded!"
|
|
End Sub
|
|
|
|
Sub Form_QueryUnload (Cancel As Integer)
|
|
If MsgBox("Really quit?", 4) <> 6 Then
|
|
Cancel = 1
|
|
End If
|
|
End Sub
|
|
|
|
Sub Form_Resize ()
|
|
Print "Window resized"
|
|
End Sub
|
|
.endcode
|
|
|
|
.link ctrl.common.props Common Properties, Events, and Methods
|
|
.link ctrl.frm FRM File Format
|