Class FormDesigner
Reads what a form module's designer declares: the form's class and designer properties, and its controls.
public static class FormDesigner
- Inheritance
-
FormDesigner
- Inherited Members
Remarks
A form module (.frm) opens on a VERSION 5.00 header line and a designer block:
Begin <class> <name> … End, before its code-behind. What the block holds depends on the
designer that wrote it:
- A VBA UserForm (
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UserForm1) holds the form's own properties only. Its controls are in the designer data Microsoft Forms persisted, which the VBE exports to the companion.frxfile at theOleObjectBlobproperty's offset: a 24-byte blob header, whose bytes 4 to 7 are the length of what follows it, then a compound file ([MS-CFB]) holding the form's storage ([MS-OFORMS] 2.1.2). The blob header is not documented; its layout is what the VBE writes. - A Visual Basic 6.0 form (
Begin VB.Form Form1) holds its controls too, as nestedBegin…Endblocks, each with its properties;BeginProperty…EndPropertyblocks group a property's own properties (aFont). Its.frxfile holds binary property values (pictures, lists), which the controls' declarations do not need.
The reader takes the companion file's content from its caller, which owns the file system: CompanionOf(string?) says which file and where.
Fields
MSFormsClassId
The class identifier of the Microsoft Forms 2.0 designer, which names a VBA UserForm's designer block.
public static readonly Guid MSFormsClassId
Field Value
MSFormsLibrary
The name of the Microsoft Forms type library, which qualifies the classes of a UserForm and of its controls (MSForms.TextBox).
public const string MSFormsLibrary = "MSForms"
Field Value
Methods
CompanionOf(string?)
Where the designer data of the form module source is, or null when the module is not a
form module or keeps no designer data in a companion file (its OleObjectBlob property).
public static FormDesignerReference? CompanionOf(string? source)
Parameters
sourcestringThe form module's source.
Returns
Exceptions
- FormDesignerFormatException
The designer block is not terminated.
Read(string?, ReadOnlyMemory<byte>)
What the form module source declares, or null when it is not a form module (it has no
designer block).
public static FormDescriptor? Read(string? source, ReadOnlyMemory<byte> companion = default)
Parameters
sourcestringThe form module's source.
companionReadOnlyMemory<byte>The content of the module's companion file (CompanionOf(string?)), when the module keeps designer data there; ignored when it does not.
Returns
Exceptions
- FormDesignerFormatException
The designer block is not terminated, the module keeps designer data in a companion file and
companionis empty, or that designer data cannot be read.
StateOf(string?, ReadOnlyMemory<byte>)
The designer's state of the form module source: for a VBA UserForm, the compound file its companion file keeps at the offset its
OleObjectBlob says, which is what Microsoft Forms loads a form from (IPersistStorage). Empty when the module keeps no designer data in a
companion file.
public static ReadOnlyMemory<byte> StateOf(string? source, ReadOnlyMemory<byte> companion)
Parameters
sourcestringThe form module's source.
companionReadOnlyMemory<byte>The content of the module's companion file (CompanionOf(string?)).
Returns
Remarks
The state is opaque here: Read(string?, ReadOnlyMemory<byte>) reads what a form declares from it, and the form host hands it, as it is, to the library that hosts the form.
Exceptions
- FormDesignerFormatException
The designer block is not terminated, the module keeps designer data in a companion file and
companionis empty, or the designer data is not where it says.