Link to home
Start Free TrialLog in
Avatar of quique
quique

asked on

Closing Toolbars

How can I capture the close event of a toolbar when is dragged out of the form, so I can change the check in my menu options?
With example, please.
Avatar of jecksom
jecksom

hi quique!

toolbar = Ttoolbar , or desktop's taskbar ? dragged out the form = hidden ?

Jecksom

If you have a menu like this:

&View
      &Toolbar
      &Status bar

and so on, then you can set the checked property of the Toolbar menu item inside the View menu item click event.

Double click the TMainMenu component that is on your form. Double click the View menu. Type:
ToolbarMenu1.Checked := Toolbar.Visible;

The menu will be updated before is displayed. This way, you don't need to monitor the close event of the toolbar.

Avatar of quique

ASKER

The problem is that it's a dockable toolbar and if you drag this toolbar out of it's docksite, it becomes a like little window with just a close button, and it is when you click this button and close this little window when the menu check has to change.
I think you didn't understand my answer.
I know it is a dockable toolbar which can be closed when not docked.
The point is that the check on the menu does not need to be updated until the parent menu is opened.

Maybe this will demonstrate.
Create a new app, add a controlbar and put a toolbar inside. Set DockKind to dkDock.
Add the menu in my last comment.

Name of View menu item: View1
Name of Toolbar menu item: ToolbarMenuItem
Name of Toolbar:  Toolbar1

In the OnView1Click add this code:
ToolbarMenuItem.Checked := Toolbar1.Visible;

In the OnToolbarMenuItemClick type this code:
Toolbar1.Visible := not Toolbar1.Visible;

Run your program. The check next to ToolbarMenuItem is always synchronised with the visibility of the toolbar, even if the close button on the toolbar is clicked.

Avatar of quique

ASKER

The problem is that there isn't an onclose event in the toolbar, so there's no way to uncheck the 'Visible Toolbar' menu option when you close the toolbar. It must work both ways, using the menu option and closing the toolbar. Is it more clear now the problem?
ASKER CERTIFIED SOLUTION
Avatar of philipleighs
philipleighs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of quique

ASKER

Thanks for all, folk!