RAD Studio |  |

Hiding and Showing Toolbars
See Also
Collapse All

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 runtime as needed.

To show or hide a toolbar at runtime, 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.

Copy Code

    procedure TForm1.PenButtonClick(Sender: TObject);
    begin
      PenBar.Visible := PenButton.Down;
    end;

Copy Code

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

See Also

TToolBar

TCoolBar

TPanel

TToolButton

TSpeedButton

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!