Chapter 28 Key Takeaways

  1. The LCL provides a rich set of common controls — TLabel, TEdit, TMemo, TButton, TComboBox, TCheckBox, TRadioButton, TListBox, TRadioGroup — each designed for a specific interaction pattern. Choose the right control for the right task.

  2. Layout is built with three tools: Align for major structural regions (top toolbar, left sidebar, client area), Anchors for flexible positioning within regions, and BorderSpacing for margins and gaps. Avoid hardcoded pixel positions.

  3. TStringGrid is a versatile tabular display with fixed header rows, editable cells, row highlighting, and column resizing. For custom cell rendering, use the OnDrawCell event.

  4. Data entry forms require careful attention to tab order, validation strategy (on-submit, on-exit, or as-you-type), and focus management. Always call SetFocus and SelectAll when highlighting a validation error.

  5. Modal forms block the parent window and return a ModalResult. Modeless forms coexist with the parent. Use modal for dialogs that require a decision; use modeless for auxiliary windows.

  6. Pass data between forms via public properties or methods — not global variables. A form is just an object; treat it like one.

  7. Shared event handlers with Sender and Tag eliminate code duplication. Ten buttons can share one handler.

  8. Controls can be created at runtime using TControl.Create(Owner) and setting the Parent property. This enables data-driven UIs where the number of controls depends on the data.

  9. Custom events using method pointers (procedure(Sender: TObject) of object) let your business logic classes notify the UI without depending on it — the Observer pattern in action.

  10. Forms are classes. Everything you learned about OOP in Part III — encapsulation, properties, methods, inheritance — applies directly to form design.