Table of Contents

Appearance and layout

Every toolbar in this group derives from the same base, so they share one set of appearance, sizing and overflow features. Use this chapter to brand the bars, make them collapse gracefully when space is tight, and route overflow into the options menu. These properties apply equally to the font, paragraph, clipboard, insert and file I/O toolbars.

Styling the toolbar

Appearance carries the toolbar surface Fill and Stroke; the individual buttons, separators and pickers each have their own appearance objects reachable from the toolbar. Set the surface colours to match your application chrome.

A font toolbar with a branded surface fill and border A font toolbar with a branded surface fill and border

Compact mode

When a toolbar is narrower than its buttons need, compact mode moves the overflow into a drop-down. Set CanCompact (default True) to allow it, Compact to turn it on, and CompactWidth to the width at which the bar collapses. The QuickMenuButton adds a one-click button that surfaces the collapsed actions.

When fully compacted the bar shrinks to just the quick-menu button, and every action moves into that menu — useful on narrow forms where a full bar will not fit.

The options menu

OptionsMenu is the built-in drop-down that lists actions which do not fit, plus any entries you add. CustomOptionsMenu lets you supply your own TPopupMenu instead. The On...OptionsMenu* events let you customise the menu before it is shown and respond to selections.

Note

AutoSize, AutoWidth and AutoHeight (all on by default) size the bar to its content. Set an explicit CompactWidth (or turn AutoWidth off) when you want the bar to collapse at a fixed width rather than always fitting its buttons.

Combining a theme with compact mode

Putting it together — a branded surface plus compact mode and the quick-menu button, so the same bar looks consistent and stays usable when the form narrows:

// Style a toolbar through its Appearance, and enable compact mode so overflow
// buttons collapse into the options menu when the bar is narrow.
procedure TForm1.StyleToolBar;
begin
  TMSFNCFontToolBar1.Appearance.Fill.Color := gcWhitesmoke;
  TMSFNCFontToolBar1.Appearance.Stroke.Color := gcSilver;

  // Compact mode plus the quick-menu button keep the bar usable when space
  // is limited.
  TMSFNCFontToolBar1.CanCompact := True;
  TMSFNCFontToolBar1.Compact := True;
  TMSFNCFontToolBar1.CompactWidth := 220;
  TMSFNCFontToolBar1.QuickMenuButton := True;
end;

Common mistakes

  • Setting Compact without CanCompact. If CanCompact is False the bar never collapses regardless of Compact.
  • Expecting compaction while AutoWidth stretches the bar. A bar that always auto-sizes to its content never reaches CompactWidth; fix the width or turn AutoWidth off.

See also