Skip to main content
Table of Contents

TTMSFNCToolBar.CanCompact Property

When True, the toolbar is allowed to switch to compact mode when its width drops below CompactWidth.

API unit family: TMSFNCToolBar Declaring type: TTMSFNCToolBar Inherited from: TTMSFNCCustomToolBar Type: Boolean

Syntax

FMX.TMSFNCToolBar.hppPascalC++
property CanCompact: Boolean;
__property bool CanCompact = {read=FCanCompact, write=SetCanCompact, default=1};

Default: True

Usage examples

Let the toolbar compact on narrow surfaces

Enables compacting below a width threshold and customizes the generated compact toolbar.

Let the toolbar compact on narrow surfacesPascalC++
procedure TForm1.EnableCompactMode;
begin
  // Below CompactWidth the toolbar collapses and moves overflowing commands
  // into the options (overflow) menu, so nothing becomes unreachable.
  TMSFNCToolBar1.CanCompact := True;
  TMSFNCToolBar1.CompactWidth := 240;
  TMSFNCToolBar1.OptionsMenu.ShowButton := True;
  TMSFNCToolBar1.OptionsMenu.ShowItemText := True;
  TMSFNCToolBar1.OptionsMenu.ShowItemBitmap := True;

  TMSFNCToolBar1.OnCustomizeCompactToolBar := CustomizeCompact;
  TMSFNCToolBar1.Build;
end;

procedure TForm1.CustomizeCompact(Sender: TObject; ACompactToolBar: TTMSFNCToolBar);
begin
  // Adjust the generated compact toolbar before it is shown to the user.
  ACompactToolBar.Appearance.Fill.Kind := gfkSolid;
  ACompactToolBar.Appearance.Fill.Color := gcWhitesmoke;
end;
void __fastcall TForm1::EnableCompactMode()
{
  // Below CompactWidth the toolbar collapses and moves overflowing commands
  // into the options (overflow) menu, so nothing becomes unreachable.
  TMSFNCToolBar1->CanCompact = true;
  TMSFNCToolBar1->CompactWidth = 240;
  TMSFNCToolBar1->OptionsMenu->ShowButton = true;
  TMSFNCToolBar1->OptionsMenu->ShowItemText = true;
  TMSFNCToolBar1->OptionsMenu->ShowItemBitmap = true;

  TMSFNCToolBar1->OnCustomizeCompactToolBar = CustomizeCompact;
  TMSFNCToolBar1->Build();
}

void __fastcall TForm1::CustomizeCompact(TObject *Sender, TTMSFNCToolBar *ACompactToolBar)
{
  // Adjust the generated compact toolbar before it is shown to the user.
  ACompactToolBar->Appearance->Fill->Kind = gfkSolid;
  ACompactToolBar->Appearance->Fill->Color = gcWhitesmoke;
}

Read the related guide