Table of Contents

Class VB6FormReader

Namespace
RDCore.Forms.Import.VB6
Assembly
RDCore.Forms.dll

Reads a VB6 designer file (.frm, .ctl or .pag) and its companion binary file into a FormDefinition.

public static class VB6FormReader
Inheritance
VB6FormReader
Inherited Members

Remarks

The designer half, from VERSION to the root block's End, becomes the form; the rest of the file is returned as ModuleText. Property and class names are read without regard to case. A component's Index becomes its Index, and a root's Client* rectangle its position and size. A file's positions and sizes are twips whatever a container's ScaleMode, and are read as pixels, at 15 twips a pixel. A Line's ends are in its container's scale, and are read as written.

A read does not throw on what a file holds. A property the model does not have, or whose value it cannot hold, is kept as an UnmodelledProperty, and so is a property bag other than a Font its class has; a component of a class the model does not have as a control or a menu, such as an ActiveX control, or with no name, or nested deeper than MaxNestingDepth, is kept as an UnmodelledComponent; a header line that names no control library is kept in UnmodelledHeader, and a root block that is not a form's in UnmodelledRoot. Each of these is reported in Diagnostics, except a property or a property bag the model does not have. A line that cannot be read and an EndProperty that closes nothing are reported and left out. The VERSION line is left out, and so are the header lines of a file that holds no form. A property a block sets twice has the value of its last line.

A control that writes no Font, on a VB.Form that writes one, takes a copy of that form's font. A component placed inside one that cannot hold it, such as a control inside a ListBox, is placed in the nearest enclosing component that can, at its position as written. A companion record is read in the shape its property's type has: a string cited as $"Form1.frx":0000 has a 4-byte length, and one cited as "Form1.frx":0000 a 1-byte length and ends at its first NUL; a picture is a 4-byte length of the rest, the signature lt\0\0, then the image file's 4-byte length and its bytes, an image of no bytes being no picture; a List is a 2-byte count, then, for a list that is not empty, a 2-byte word, then each item's 2-byte length and bytes; an ItemData is a List of the decimal text of each Long.

Fields

MaxNestingDepth

How deep the blocks of a designer file are read, the root's included: 2,500. A block nested deeper is kept as text, its own contents included.

public const int MaxNestingDepth = 2500

Field Value

int

Methods

Read(string, byte[]?, VB6ImportOptions?)

Reads a designer file's text and its companion binary file.

public static VB6FormImport Read(string designerFile, byte[]? companion = null, VB6ImportOptions? options = null)

Parameters

designerFile string

The designer file's text.

companion byte[]

The companion binary file's bytes, read for every property that cites a companion record, or null when there is none. A property citing one is then kept as text.

options VB6ImportOptions

How strings in the companion are decoded, and the project's own classes; null for Default.

Returns

VB6FormImport

The form, the module text, and what the import reports.

Exceptions

ArgumentNullException

designerFile is null.

ReadFile(string, VB6ImportOptions?)

Reads a designer file, and the companion binary files its properties cite, such as Form1.frx: each one by the name the designer file cites, from the designer file's folder, its name compared without regard to case. A cited name that is a rooted path, such as a network path, is not read, and neither is one that holds a NUL: the property is reported as citing a missing companion.

public static VB6FormImport ReadFile(string path, VB6ImportOptions? options = null)

Parameters

path string

The designer file's path.

options VB6ImportOptions

How the designer file and the strings in its companions are decoded, and the project's own classes; null for Default.

Returns

VB6FormImport

The form, the module text, and what the import reports.

Exceptions

ArgumentNullException

path is null.

ArgumentException

path is empty, or holds a NUL.

IOException

The designer file, or a companion file that was found, cannot be read.

UnauthorizedAccessException

The designer file, or a companion file that was found, or the designer file's folder, cannot be accessed.