Chapter 29 Key Takeaways
-
Main menus (TMainMenu) organize application operations into discoverable categories. Use
&in captions for accelerator keys and theShortCutproperty for keyboard shortcuts. -
Context menus (TPopupMenu) provide right-click actions relevant to the clicked item. Use
OnPopupto enable/disable items based on context. -
Standard dialogs — TOpenDialog, TSaveDialog, TColorDialog, TFontDialog — wrap native OS dialogs. Configure with
Filter,DefaultExt, andInitialDir. -
Message dialogs range from simple (
ShowMessage) to configurable (MessageDlgwith icon, buttons, and return value). UseInputBox/InputQueryfor single-value input. -
Application lifecycle:
OnCreatefor initialization,OnCloseQueryto check unsaved changes,OnClosefor cleanup. Save/load settings withTIniFile. -
Toolbars (TToolBar) provide icon-based quick access. Status bars (TStatusBar) display contextual information in panels.
-
TActionList is the key pattern — it centralizes command code, enabled state, captions, icons, and shortcuts. A single action serves menu items, toolbar buttons, and keyboard shortcuts simultaneously.
-
TAction.OnUpdate is called automatically during idle processing, keeping UI elements synchronized with application state without manual polling.
-
The title bar should show
[* ] filename — AppNameto indicate the current file and unsaved-changes status. -
Architecture patterns (MVC, MVP, Document-View) separate business logic from UI code. The minimum rule: model units must never reference LCL units.