Startup and component wiring
Transmission Remote GUI becomes a desktop application through a small set of connected Lazarus project parts. The program entry point prepares the process, the project declaration supplies the forms and packages, and the main form joins the reusable controls into the running user interface. For the wider session model, see Application lifecycle; for behavior after the window is ready, see Main-window workflows.
Runtime assembly
The runtime assembly turns a compiled program into a usable desktop session. It loads the Lazarus widget system, validates process and input state, creates the main form from its saved form resource, and then gives control to the event loop.
flowchart TD
A[Operating system starts program] --> B[Program entry point]
B --> C[Runtime and input checks]
C -->|Continue| D[Lazarus application initialization]
D --> E[Main form creation]
E --> F[Form resource and component wiring]
F --> G[Desktop event loop]
C -->|Stop or hand off| H[Process exits]
Program entry
The program entry point is the boundary between process startup and the Lazarus application model. It checks command-line and single-instance state before it initializes the user-interface framework. On success it creates TMainForm, applies the Windows taskbar rule when needed, and starts the event loop that drives the desktop session.
This order keeps process ownership and incoming torrent inputs separate from form creation. A process that must hand work to an existing instance exits before it creates a second window.
References: transgui.lpr• L29-65 main.pas• L1280-1403
Project declaration
The Lazarus project declaration defines the build-level assembly that the entry point relies on. It identifies transgui.lpr as the program unit, lists the application and form units, enables resource-backed forms, and requires the Lazarus Component Library (LCL) plus the trcomp package. Automatic form creation is disabled, so the program entry point chooses the main form explicitly.
The project also carries the application identity and display expectations used by the desktop build. Its version data, manifest settings, scaling setting, and compiler search paths help the same application target different widget systems without changing the startup contract.
References: transgui.lpi• L5-19 transgui.lpi• L21-26 transgui.lpi• L45-53 transgui.lpi• L54-190 transgui.lpi• L193-220
Form creation
Form creation combines a Pascal form class with a Lazarus form resource. The project lists the form units and their component names, while each form resource declares the visual tree and event links that the class completes at run time. The main form is the first such form created by the program, and its create event then prepares the session coordinator and its data views.
All forms inherit common behavior from TBaseForm. That shared boundary applies interface scaling and optional automatic sizing before the form finishes creation. As a result, the main window and secondary dialogs enter the event loop with a consistent display scale.
References: transgui.lpi• L59-190 main.lfm• L1-26 main.pas• L1573-1629 baseform.pas• L31-63 baseform.pas• L217-244
Reusable component package
The reusable component package supplies controls that the application uses as part of its normal interface rather than as one-off form code. Its main component is TVarGrid, a variable-data grid that presents structured rows while supporting the selection, sorting, search, editing, and cell interaction needed by torrent views.
Variable grid
TVarGrid provides the shared table surface for data-rich views. It connects a variable list of row data to columns and exposes common user interactions such as multi-selection, row visibility, sorting, quick search, check boxes, tree buttons, and cell editing. The main form uses this same control family for the filter list and torrent list, which gives those views a common interaction model.
The control is available to both the Lazarus designer and the running program through the TransGUI component palette. Its package registration makes the control recognizable when form resources are loaded, while the application unit uses the same registered type at run time.
References: vargrid.pas• L31-59 vargrid.pas• L69-169 vargrid.pas• L175-249 vargrid.pas• L251-265 main.lfm• L47-81 main.lfm• L83-180
Package boundary
The trcomp package is the delivery boundary for the reusable grid component. It depends on the LCL and Free Component Library (FCL), supports design-time and run-time use, and exposes the package output path to the project. The package registration unit connects the package name to the grid unit and its component registration routine.
This boundary lets the main project depend on a stable component package instead of treating the grid as part of the program entry sequence. A change to the package can therefore affect both form design and the runtime loading of the controls that those forms name.
References: trcomp.lpk• L3-16 trcomp.lpk• L17-35 trcomp.pas• L5-20 transgui.lpi• L45-53
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the project unit list must keep the form classes, form resources, and component names aligned.
- Changes to automatic form creation must preserve the explicit
TMainFormcreation contract in the program entry point. - Changes to the
trcomppackage must remain valid for both Lazarus design-time loading and application run time. - Changes to
TVarGridproperties or registration must remain compatible with the grid instances and event links stored in form resources. - Changes to startup checks must preserve the handoff of command-line torrent inputs before the new process exits.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The entry point creates the main form before process checks finish | A second process can create a competing desktop session or consume input that belongs to the active instance | Keep CheckAppParams before application initialization and form creation |
| A form unit or its resource is missing from the project declaration | Lazarus cannot create the named form or restore its visual component tree | Keep each form class, resource-backed unit, and project entry aligned |
The trcomp package is unavailable or its registration does not run | Form resources that use TVarGrid cannot resolve the shared control | Keep the package dependency and component registration together |
| A registered grid property changes without matching form resources | A view can load with invalid settings or lose its configured interaction behavior | Treat TVarGrid published properties as a resource compatibility contract |
| Shared form setup does not apply the configured scale | The main window and dialogs can use inconsistent sizes or become hard to use on high-DPI displays | Keep TBaseForm creation ahead of normal form use |
Key files
| File | Why to read it |
|---|---|
transgui.lpr | Shows the complete process-to-event-loop startup boundary. |
transgui.lpi | Defines the project entry point, form units, package dependencies, and resource-backed form declarations. |
main.lfm | Shows how the main form resource names the window, its grid controls, and its event links. |
main.pas | Shows the main form’s creation boundary and the session objects it prepares after resource loading. |
baseform.pas | Defines the common form contract for scaling and automatic sizing. |
vargrid.pas | Defines the reusable data-grid behavior used by the main interface. |
trcomp.lpk | Defines the reusable component package and its LCL/FCL dependencies. |
trcomp.pas | Connects package loading to the component registration routine. |
| Application lifecycle | Places startup wiring in the full process, window, refresh, and shutdown lifecycle. |
| Main-window workflows | Explains the user flows that begin after the startup wiring is complete. |