Hiding and Showing Toolbars

From RAD Studio
Jump to: navigation, search

Go Up to Designing Toolbars and Cool Bars


Often, you want an application to have multiple toolbars, but you do not want to clutter the form with them all at once. Or you may want to let users decide whether to display toolbars. As with all components, toolbars can be shown or hidden at run time as needed.

To show or hide a toolbar at run time, set its Visible property to False or True, respectively. Usually you do this in response to particular user events or changes in the operating mode of the application. To do this, you typically have a close button on each toolbar. When the user clicks that button, the application hides the corresponding toolbar.

You can also provide a means of toggling the toolbar. In the following example, a toolbar of pens is toggled from a button on the main toolbar. Since each click presses or releases the button, an OnClick event handler can show or hide the Pen toolbar depending on whether the button is up or down.

procedure TForm1.PenButtonClick(Sender: TObject);
begin
  PenBar.Visible := PenButton.Down;
end;
void __fastcall TForm1::PenButtonClick(TObject *Sender) 
{
    PenBar->Visible = PenButton->Down;
}

See Also