Solved

Closing Toolbars

Posted on 1998-11-26
7
308 Views
Last Modified: 2012-05-04
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
Comment
Question by:quique
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:jecksom
ID: 1347977
hi quique!

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

Jecksom

0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1347978
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
 
LVL 1

Author Comment

by:quique
ID: 1347979
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 3

Expert Comment

by:philipleighs
ID: 1347980
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
 
LVL 1

Author Comment

by:quique
ID: 1347981
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
 
LVL 3

Accepted Solution

by:
philipleighs earned 50 total points
ID: 1347982
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
 
LVL 1

Author Comment

by:quique
ID: 1347983
Thanks for all, folk!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now