How to detect when a toolbar is closed in ArcMap 10

692
6
Jump to solution
02-19-2013 05:48 AM
TimSexton1
Occasional Contributor
I have a custom toolbar developed in C# using ArcObjects that is displayed in ArcMap 10.  I need to run a function whenever the toolbar is closed/hidden but I have yet to find an event to go by.  I've looked at document and toolbar events but cannot seem to find one that fits.  Any help is greatly appreciated.
0 Kudos
1 Solution

Accepted Solutions
AlexanderGray
Occasional Contributor III
Alexander,

I'm trying your suggestion but it seems like the Enabled event on a command is not fired when the parent toolbar is not visible.


No the enabled is only fired when the command is visible...  That won't work if the command is on the toolbar you want to assess the visibility...  The event stops firing precisely when you want to check...  It has to be on a different command bar.

View solution in original post

0 Kudos
6 Replies
NeilClemmons
Regular Contributor III
As far as I know, there isn't any way to be notified when a toolbar is closed.  What is it you're wanting to do when it's closed?
0 Kudos
AlexanderGray
Occasional Contributor III
I have seen something similar done in a very cludgy way.  Basically, if the event doesn't exist you can make your own.  I have seen commands placed on an interface for the sole purpose of taking advantage of the enabled property being fired basically all the time.  In the enabled property they place a check to the desired command bar isvisible property and raise a custom event if it changes.  The reference to the command bar was obtained only once. Like I said cludgy but some times you have little choice.
0 Kudos
TimSexton1
Occasional Contributor
As far as I know, there isn't any way to be notified when a toolbar is closed.  What is it you're wanting to do when it's closed?


I've developed a custom user control that resides on the toolbar in question.  The custom control has on/off modes that control some functionality on a set of feature classes in the map while editing and if the control is 'on' when the user closes the toolbar, I need to set the mode to 'off' on the custom control to prevent any confusion if the user no longer intends to leave it on.

The command on the toolbar that hosts my custom control implements BaseTool and IToolControl.  Maybe I should be looking into one of those for an event?
0 Kudos
TimSexton1
Occasional Contributor
Alexander,

I'm trying your suggestion but it seems like the Enabled event on a command is not fired when the parent toolbar is not visible.
0 Kudos
AlexanderGray
Occasional Contributor III
Alexander,

I'm trying your suggestion but it seems like the Enabled event on a command is not fired when the parent toolbar is not visible.


No the enabled is only fired when the command is visible...  That won't work if the command is on the toolbar you want to assess the visibility...  The event stops firing precisely when you want to check...  It has to be on a different command bar.
0 Kudos
TimSexton1
Occasional Contributor
I figured placing it on a command on another toolbar would work, but unfortunately that is too unpredictable for me to use (what if the other toolbar is already closed - nothing happens and I'm back in the same boat).  Thanks for your help guys, it was worth a shot.
0 Kudos