DockableWindow with embedded Toolstrip: ToolStripButtons don't react on first click

5014
3
05-04-2012 12:44 AM
AndryJoos
Occasional Contributor
Hey

In my 10.0 SP4 ArcMap application I have a DockableWindow (created using the templates (as UserControl implementing IDockableWindowDef), C#, .Net3.5) that contains a Listbox and a Toolstrip with a few ToolstripButtons. I do encounter a rather strange behaviour with this:
If the DockWindow is not active (ie. if I click in the map somewhere) and then I'll directly hit one of the ToolstripButtons in my Window, the click method is not being called. I have to click the button again to make it fire. It seems to me, the DockWindow has to be activated first (by the first click)?

However:
* If I click an item in the listbox in the same window, it react immediately (no matter if the previous click was on the map)
* The toolstrip buttons do get activated (blue border) even if my previous click was on the map
* Everything works smooth if the Window is docked (not floating)

Any ideas on that? ArcMap itself contains a few windows that look the same (toolbar/toolstrip and a list...) but do not behave this weird.
Anything I did wrong? Do I need to implement some strange WM_-handling/custom message handling?

I'm happy for every hint 🙂

Greetings,
Andry
0 Kudos
3 Replies
TimSexton1
Occasional Contributor

Andry Joos - I was having the same issue but was able to find a solution.  I documented it on GIS Stack Exchange here.

AndryJoos
Occasional Contributor

Hi Tim! Thank you very much for letting me know. It's awesome to read that there actually is a solution. I will check if we still have that problem at the customer's side and implement it that way, if possible.

Maybe you want to copy&paste your solution into GeoNet too, for future reference for other people having the same issue?

0 Kudos
TimSexton1
Occasional Contributor

I found a work around to this by using Rick Brewster's suggestions.

First, I modified Rick's class by adding a constructor public ToolStripEx() : base() { }

Then in my dockable window's designer class "MyClass.Designer.cs" I changed the toolstrip's declared type from System.Windows.Forms.ToolStrip to ToolStripEx.

Next, in the InitializeComponent() method of the same designer class, I changed the initialization type for the toolstrip the same way from this.MyToolStrip = new System.Windows.Forms.ToolStrip() to this.MyToolStrip = new ToolStripEx().

Finally, I set this.MyToolStrip.ClickThrough = true; in the default property assignment section in the same designer class.

Now the buttons on the toolstrip fire the onClick event everytime - even when the dockable window is not active!