WaynesTextBox class

A single-line editable text field. The user can type, select with the mouse or with shift-modified cursor keys, jump word-by-word with Ctrl+Left / Ctrl+Right, double-click to select a word, and copy / cut / paste / select-all with the standard Windows shortcuts. The control draws its own caret, selection highlight, and inline text decorators (squiggle for ERROR, underline for WARNING, background highlight for INFO) on top of the configurable background.

The control paints three visual states (NormalState, HoverState, FocusedState) driven by parallel WaynesTextBoxState sub-objects, each of which carries its own background fill, borders, corners, text rendering, selection colours, caret colour, and decorator colours.

The current text is held in Value. Surrogate-pair characters are handled correctly by the cursor / selection logic — the caret never lands between the high and low halves of a pair.

Private Sub Form_Load()
    txtName.Value = ""
    txtName.NormalState.TextRendering.Padding.Left = 6
    txtName.NormalState.TextRendering.Padding.Right = 6
End Sub

The three states are styled independently — a common pattern is to give the focused state a heavier border in an accent colour and brighten its fill, so the active field stands out from its siblings:

Private Sub Form_Load()
    With txtName.NormalState
        .BackgroundFill.ColorPoints.SetSolidColor vbWhite
        .Borders.SetSimpleBorder StrokeSize:=1, ColorRGB:=&HC0C0C0
        .Corners.SetAll tbCurve, 4
        .TextRendering.Padding.Left = 6
        .TextRendering.Padding.Right = 6
    End With

    With txtName.FocusedState
        .BackgroundFill.ColorPoints.SetSolidColor vbWhite
        .Borders.SetSimpleBorder StrokeSize:=2, ColorRGB:=&HC07014  ' accent blue
        .Corners.SetAll tbCurve, 4
        .TextRendering.Padding.Left = 6
        .TextRendering.Padding.Right = 6
    End With
End Sub

Inline text decorators

As the user types, the control automatically marks any occurrence of three literal strings inside Value:

The colours are configurable per visual state. The substrings themselves are hard-coded into the control’s paint logic in the current release.

Properties

Anchors

Which sides of the control are pinned to its container during resize. Anchors. Inherited.

Dock

How the control is docked inside its container. A member of DockMode. Inherited.

FocusedState

The WaynesTextBoxState used when the control has the keyboard focus. Pre-set with focus-specific defaults — orange caret, blue selection background.

Height

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

HoverState

The WaynesTextBoxState used when the mouse is hovering over the textbox without it having focus.

Left

The horizontal offset of the control’s left edge from its container, in pixels. PixelCount. Inherited.

Name

The unique design-time name of the control on its parent form. String. Inherited.

NormalState

The WaynesTextBoxState used when the textbox is at rest — not focused and not hovered.

TabIndex

The position of the control in the form’s TAB-key navigation order. Long. Inherited.

TabStop

Whether the user can reach the control by pressing TAB. Boolean. Inherited. Default: True.

Top

The vertical offset of the control’s top edge from its container, in pixels. PixelCount. Inherited.

Value

The current text in the field. String. Default: "Textbox".

Syntax: object.Value [ = string ]

Visible

Whether the control is currently displayed. Boolean. Inherited. Default: True.

Width

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