WaynesForm class

The top-level form class that hosts the package’s custom controls. A WaynesForm is the equivalent of a Form from the VB package, but instead of being a Win32 native window with controls overlaid on top, it is an owner-drawn surface that paints itself and its child controls through the CustomControls framework.

Within the current release of the package every form created with the designer is hard-coded to use WaynesForm as its root class; other base form classes are planned but not yet supported.

A form has a Caption (shown in the Win32 title bar), a BackgroundFill (painted across its entire client area), and a WindowsOptions sub-object that controls the surrounding Win32 frame — border style, window state, taskbar visibility, minimize / maximize buttons, and so on. Call Show to display the form; call Close to close it.

Setting up a form

A WaynesForm raises no Load event — Click is its only event — so a Form_Load procedure in its code is never called. The code that sets the form up goes in its constructor, Sub New, which runs once the values saved by the form designer are loaded and before the form’s window is made. The form’s controls exist by then, so Sub New can set their properties as well as the form’s own.

Sub New()
    Me.Caption = "Welcome"
    Me.BackgroundFill.ColorPoints.SetSolidColor vbWhite
    With Me.WindowsOptions
        .StartUpPosition = tbStartUpCenterScreen
        .BorderStyle = tbFixedDialog
        .MaximizeButton = False
    End With
End Sub

BackgroundFill is an ordinary Fill, so the form can display a gradient backdrop or a solid colour — a soft top-to-bottom wash, for example:

Sub New()
    Me.BackgroundFill.SetSimplePattern &HE5E5E5, &HF8F8F8, _
            Pattern:=tbGradientNorthToSouth
End Sub

The current release supports modal display only. Calling Show with vbModeless writes a debug-print message and otherwise does nothing — call Show vbModal to display the form.

Properties

BackgroundFill

The Fill that paints the form’s entire client area. Defaults to a solid light-grey (WAYNESCOLOR_LIGHTGREY — &HD0D0D0).

Caption

The text shown in the Win32 title bar of the form. String.

Syntax: object.Caption [ = string ]

Controls

The CustomControlsCollection of every control hosted on the form. Inherited from the form base. Read-only — iterate or look up by index / name to access individual controls.

Note BETA 1045

Controls is Nothing whenever code can read it — in Sub New, before Show and while the form is shown — so any use of it, such as Me.Controls.Count, raises error 91, Object variable or With block variable not set. Reach each control by its name instead (Me.Label1).

FormDesignerId

A String holding the unique GUID that associates this form instance with its designer-saved metadata. Inherited from the form base. Application code does not normally read or write this — the framework populates it.

Height

The form’s height in pixels. PixelCount. Inherited.

Left

The form’s left position in pixels — honoured only when WindowsOptions.StartUpPosition is tbStartUpManual. PixelCount. Inherited.

Name

The form’s name within the project. String. Inherited.

Top

The form’s top position in pixels — honoured only when WindowsOptions.StartUpPosition is tbStartUpManual. PixelCount. Inherited.

Width

The form’s width in pixels. PixelCount. Inherited.

WindowsOptions

The WindowsFormOptions that controls the Win32 frame — border style, window state, taskbar visibility, minimize / maximize buttons, system menu.

Methods

Close

Closes the form’s underlying window.

Syntax: object.Close

Show

Shows the form. The current release supports modal display only — calling with vbModeless writes a debug message and otherwise does nothing.

Syntax: object.Show [ Modal ]

Modal
optional A member of FormShowConstants. Pass vbModal for the supported modal display; vbModeless is currently a no-op.

StartupShow

Shows the form unconditionally — used by the framework to display the project’s startup form. Application code can call it but Show is the normal entry point.

Syntax: object.StartupShow

Events

Click

Raised when the user clicks on the form’s background — i.e. on a region not occupied by a hosted control.

Syntax: object_Click( )