Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

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.
0
quique
Asked:
quique
  • 3
  • 3
1 Solution
 
jecksomCommented:
hi quique!

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

Jecksom

0
 
philipleighsCommented:
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.

0
 
quiqueAuthor Commented:
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
philipleighsCommented:
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.

0
 
quiqueAuthor Commented:
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?
0
 
philipleighsCommented:
quique,
Reread my answer.
There is *NO* need for an OnClose event for the toolbar.

The menu item that you want checked only needs to be updated just before it is displayed to the user. OK, now reread that sentence until you realise that you don't need OnClose.

You can detect when it is about to be displayed because the *PARENT* menu gets an ONCLICK event.

Look at this menu carefully:
View
      Toolbar

The check next to "Toolbar" should be updated in the OnClick event of the *VIEW* menu item.
You "DON'T* need to update the check when the floating toolbar is closed because the user won't see the check until they open the menu.

If you still don't understand, just follow the steps in my second answer and run the program. Play with the program until you realise that it works.

So here is how it works.
1. The toolbar is floating and visible.
2. The menu item is checked.

3. You close the toolbar.
4. The menu item is still ticked (this is fine).

5. The user opens the View menu
6. Now the menu item is unticked!!! Exactly what you want.

No, this isn't magic. The OnViewClick removed the check *BEFORE* the drop down menu became visible to the user.

Do you get it now? I can't make it any simpler.
0
 
quiqueAuthor Commented:
Thanks for all, folk!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now