A Form object is a window or dialog box that makes up part of an application's user interface.
Form
Forms are the foundation for creating the interface of an application. You can use forms to add windows and dialog boxes to your application. You can also use them as containers for items that are not a visible part of the application's interface. For example, you might have a form in your application that serves as a container for graphics that you plan to display in other forms.
You can design a form using the Form Editor or create them in code. A form designed with the Form Editor is brought into the program using the LoadForm command. In code, forms are created by Form, OpenW, Ocx Form, ParentW, ChildW, and Dialog .
To close and destroy a Form, the appropriate method or command must be used; Forms can not be closed/destroyed using Nothing as other objects can.
Forms have properties that determine aspects of their appearance, such as position, size, and color; and aspects of their behavior, such as whether or not they are resizable.
Forms can also respond to events initiated by a user or triggered by the system. For example, you could write code in a form's Click event procedure that would enable the user to change the color of a form by clicking it.
In addition to properties and events, you can use methods to manipulate forms using code. For example, you can use the Move method to change a form's location and size.
When designing forms, set the BorderStyle property to define a form's border, and set the Caption property to put text in the title bar. In code, you can use the Hide and Show methods to make forms invisible or visible at run-time.
Align | Appearance | AutoClose |AutoRedraw | BackColor | BkColor | BorderStyle | Caption | ControlBox | Controls | CurrentX | CurrentY | DrawMode | Enabled | Font | FontBold | FontItalic | FontName | FontSize | FontStrikethru | FontTransparent | FontUnderline | ForeColor | hDC~hDC2 | Height | HelpButton | HelpContextID | hMdiClientWnd | HScMax | HScMin | HScPage | HScPos | HScStep | HScTrack | hWnd | Icon | Image | Index | IsDialog | Left | MaxButton | MdiChild | MdiParent | MenuEnabled | MenuItem | MenuText | MinButton | MouseCursor | MouseIcon | MousePointer | Moveable | Name | OcxScale | OnTop | PaintLeft | PaintTop | PaintWidth | PaintHeight | Parent | Picture | PictureMode | PrintScroll | PrintWrap | ScaleHeight | ScaleLeft | ScaleMode | ScaleTop | ScaleWidth | ScrollBars | ShowInTaskBar | Sizeable | SmallIcon | StartUpMode | TabStripIndex | TabStop | Tag | ToolTipText | Top | Visible | VScMax | VScMin | VScPage | VScPos | VScStep | VScTrack | WhatsThisHelpID | Width | WindowState
The PictureMode property determinates how the Form picture is displayed (0 = default, 1 = Tile, 2 = stretched).
Activate | Adjust | Center | Close | Deactivate | Disable | DoClick | Enable | FullW | Hide | Invalidate | InvalidateAll | Maximize | MdiCascade | MdiGetActive | MdiActivate | MdiIconArrange | MdiNext | MdiPrev | MdiSetMenu | Minimize | Move | Owner | PixelsPerTwipX | PixelsPerTwipY | PrintForm | PrintFormHeight | PrintFormWidth | PrintPicture, PrintPicture2 | Refresh | Restore | Scale | ScaleX | ScaleY | SetFocus | SetFont | Show | SysMenuText | TextHeight | TextWidth | ToBack | ToTop | TwipsPerPixelX | TwipsPerPixelY | Validate | ValidateAll | WhatsThisMode | ZOrder
Activate | Click | Close | DblClick | DDEWndProc | Deactivate | Destroy | DisplayChange | EndSession | GotFocus, LostFocus | HScroll | HScrolling | KeyDown, Keyup | KeyPress | Load | MciNotify | MenuEvent | MenuOver | Message | MessageProc | MonitorPower | MouseDblClick | MouseDown, MouseUp | MouseMove | MouseWheel | Moved | OnCtrlHelp | OnHelp | OnMenuHelp | Paint | QueryEndSession | Resize | ScreenSave | SysColorChange | SysMenuOver | VScroll | VScrolling | WinIniChange
Some properties are only valid for an Ocx Form, a form used as a control. For instance, a non-Ocx form cannot have a Parent, but an Ocx can and does (more accurately, interrogating Parent for a non-Ocx Form is returns a reference to itself - if youi need to find it's Parent, use the GetParent(hWnd) API function).
Note Setting the BorderStyle to 0 removes the border. If you want your form to have a border without the title bar or Control-menu box, delete any text from the form's Caption property and set the form's ControlBox properties to False.
Positional and size propeties (Top, Left, Width, Height, etc) use different unit types, dependant upon the type of Form being set/read: Ocx Forms use pixels and non-Ocx Forms/Windows twips. There is no definitive way to tell the difference programmatically between the different Form types (the relevant values are stored in the internal GB32 Form Value Tables which can not be directly referenced) and the functions IsObject and IsControl return True for all types; all forms return "Form" when interrogated with TypeName and if you interrogate the control, the class names are all the same. The FormType function in the example below is the closest one can come to differentiating, but be warned that there will be rare instances where it will not work correctly:
OpenW 1
OpenW Owner Win_1, 2
OpenW MdiParent 4
OpenW MdiChild Owner Win_4, 3
Form frm1
Ocx Form frx = "", 10, 10, 100, 100
Ocx ComboBox cbx
Trace FormType(Win_1) // 1 (Window/Form)
Trace FormType(Win_2) // 1 (Window/Form) - There is no way of telling if a Window is owned in code
Trace FormType(Win_3) // 3 (MdiChild Window)
Trace FormType(Win_4) // 2 (MdiParent Window)
Trace FormType(frm1) // 1 (Window/Form)
Trace FormType(frx) // 4 (Ocx Form)
Trace FormType(cbx) // -3 (Not a Form)
CloseW 2
Trace FormType(Win_2) // -1 (Object is Nothing)
Debug.Show
Function FormType(ctrl As Control)
If IsNothing(ctrl) Then Return -1 // Control does not exist
If Not IsObject(ctrl) Then Return -2 // Value passed not an Object
If TypeName(ctrl) <> "Form" Then Return -3 // Control passed not a form
If GetParent(ctrl.hwnd) <> 0
If ctrl.MdiChild Then Return 3 // Form is MdiChild window
Return 4 // Form is OCX Form
EndIf
If ctrl.MdiParent Then Return 2 // Form is MdiParent
Return 1 // Form is Form/Window
EndFunction
Form, Form(), LoadForm, OpenW, ChildW, ParentW, Dialog
{Created by Sjouke Hamstra; Last updated: 15/02/2023 by James Gaite}