Chapter 29 Key Takeaways

  1. Main menus (TMainMenu) organize application operations into discoverable categories. Use & in captions for accelerator keys and the ShortCut property for keyboard shortcuts.

  2. Context menus (TPopupMenu) provide right-click actions relevant to the clicked item. Use OnPopup to enable/disable items based on context.

  3. Standard dialogs — TOpenDialog, TSaveDialog, TColorDialog, TFontDialog — wrap native OS dialogs. Configure with Filter, DefaultExt, and InitialDir.

  4. Message dialogs range from simple (ShowMessage) to configurable (MessageDlg with icon, buttons, and return value). Use InputBox/InputQuery for single-value input.

  5. Application lifecycle: OnCreate for initialization, OnCloseQuery to check unsaved changes, OnClose for cleanup. Save/load settings with TIniFile.

  6. Toolbars (TToolBar) provide icon-based quick access. Status bars (TStatusBar) display contextual information in panels.

  7. 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.

  8. TAction.OnUpdate is called automatically during idle processing, keeping UI elements synchronized with application state without manual polling.

  9. The title bar should show [* ] filename — AppName to indicate the current file and unsaved-changes status.

  10. Architecture patterns (MVC, MVP, Document-View) separate business logic from UI code. The minimum rule: model units must never reference LCL units.