Programmering - BASIC - Visual Basic - Objects - Form >Controls
rightx.gif (837 bytes)Code examples
gox.gif (837 bytes)Properties: ActiveForm

downx.gif (830 bytes)Propertiesdownx.gif (830 bytes)Methodsdownx.gif (830 bytes)Events

The Me keyword may be used to represent the form:
Me.Left = 100
Me.Hide
The Load statement places a Form in memory, but does not display it (> method: Show)
Load frmFrm1

NB: The form is automatically loaded if a property, method or control is accessed (so, the Load statement is not necessary)
NB: When a form loads, any code in the Form_Load() event procedure is executed.

The Unload statement removes a form from memory (> method: Hide)
Unload Me
Form - Properties:
design: BorderStyle, ControlBox, MaxButton, MDIChild, MinButton
design/run:  Font, Icon, Left, StartupPosition, Top, Width, WindowState
BorderStyle
0 - None
= vbBSNone
form-0.gif (1016 bytes)
1 - Fixed Single
= vbFixedSingle
form-1.gif (1561 bytes)
2 - Sizable (Default)
= vbSizable
form-2.gif (1625 bytes)
3 - Fixed Dialog
= vbFixedDialog
form-3.gif (1483 bytes)
4 - Fixed Tool Window
= vbFixedToolWindow
form-4.gif (1395 bytes)
5 - Sizable Tool Window
= vbSizableToolWindow
form-5.gif (1379 bytes)
ControlBox
True form-cb-t.gif (1541 bytes)form-cb-tf.gif (1634 bytes)
False form-cb-f.gif (1245 bytes)
MaxButton
True form-cb-t.gif (1541 bytes)
False form-mxb-f.gif (1456 bytes)
MDIChild
MinButton
True form-cb-t.gif (1541 bytes)
False form-mnb-f.gif (1454 bytes)
 
Font
sets base font used by the form's Print method - and for controls added to the form.
> object: Font
Form1.Font.Size = 10
Icon
Left
StartupPosition [vb5]
Form position when the form loads
0 - Manual Form position set by properties Top and Left
1 - CenterOwner Form centered
- on Windows desktop (non-MDI)
- in MDI parent window (MDI child form)
2 - CenterScreen Form centered on Windows desktop
3 - Windows Default Form placed by Windows
> Event: Resize
Top
Width
WindowState

Form - Methods: Hide, Line, Move, Print, PopUpMenu, Pset, Show

Hide
removes a form from the screen but not from memory - the properties may still be accessed.
Me.Hide
> statement: Unload
> method: Show
> event: Deactivate
Line
[Form.]Line [[Step](x1, y1)] - [Step](x2, y2) [,[color][,B[F]]]
  
' make line, color 0 (black)
Line (200, 100)-(1200, 500), 0
' make rectangle, color red
Line (200, 100)-(1200, 500), QBColor(12), B
Line.gif (1621 bytes)
 
PopUpMenu
Display the PopUp Menu 'popFormat'
frmMain.PopUpMenu popFormat
> event: MouseUp
 
Print
> property: AutoRedraw, CurrentX, CurrentY, Font
> method: Refresh
Pset
[Form.]PSet [Step](x, y)[,color]
  
For i = 200 To 2000
  PSet (i, 200), QBColor(14)
Next
PSet.gif (1497 bytes)
 
Show
(loads and) displays and activates a form
frmForm1.Show [m][, owner]
m
0 Modeless: Other forms may be activated while this form is open.
1 = vbModal Modal: No other form or code may be activated or executed until this form is closed.
 
frmForm1.Show vbModal
 
> statement: Load
> method: Hide
> event: Activate, Load

Form - Events: MouseDown, MouseUp
start sequence: Initialize, Load, Resize, Paint, Activate
stop sequence: QueryUnload, Deactivate, Unload, Terminate

Initialize
when the form object is created
 
Load
when the form is loaded into memory
> statement: Load
> method: Show
 
Activate, Deactivate
Activate is triggered when a form is activated (gets focus). The show  method will activate the form.
Sub Form1_Activate()
Deactivate is triggered when an active form loses focus. The Hide method will deactivate the form.
Sub Form1_Deactivate()
These events respond only to shifts in focus between the forms af VB - not between VB and other Windows programs.
> statement: Load
> property: ActiveControl, Screen.ActiveForm
> method: Hide, SetFocus, Show
> event: GotFocus/LostFocus, Initialize/Terminate, QueryUnLoad
 
Resize
> Ex: 1 - Keep form centered after size is changed
 
Unload
when form is removed from memory.
Unloading the last form ends the program.
> Statement: Unload
> method: Hide
 
MouseDown, MouseUp
Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Button
 : 
vbLeftButton
vbRightButton
Shift
 : 
X, Y
 : 
Location on screen of mouse cursor
Display PopUp Menu 'popFormat' when RightClick on Form:
Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = vbRightButton Then
    frmMain.PopUpMenu popFormat
  End If
End Sub
> method: PopUpMenu