Is ToolStrip with VSIP/VS SDK dialogs a no-no?
Hi all,
I've ran into an odd issue that I thought I'd run by you guys. I have a VS 2005 SDK package that pops up a modal dialog. I've been redesigning the dialog and decided to use ToolStrip component to serve as a toolbar. So, here's what I have on the dialog:
And here' s the problem I ran into. I bring up the dialog via package's command. It comes up and I move the mouse around to show/hide those context tool strip items. After I close the dialog, VS gets into this crazy state where I can't access any of its menu items, bring up the context menu or invoke any commands. The only thing I can do is to shutdown VS at that point.
I suspect that ToolStripManager gets in the way and possibly hooks/unhooks WndProc incorrectly, screwing up VS somehow. Is ToolStrip and VSIP/VS SDK a bad or unsupported combo? I'd appreciate any ideas or suggestions.
Thanks in advance.
[1156 byte] By [
SergeyM] at [2008-1-9]
Hi Aaron,
My dialog is a descendant of System.Windows.Forms.Form. I tried both .ShowDialog() with and w/o an owner with the same effect. With an owner I was basically had a IVsUIShell.GetDialogOwnerHwnd() wrapped in IWin32Window.
The easiest way I can reproduce this issue is to have one of the ContextMenuStrip popup while the dialog is up and then hit Escape key.
Let me know if there is anything else I can answer on my end. Thanks.
Hi Sergey,
I'm having trouble reproducing the behavior you're seeing. I've created a Form-derived class with a ToolStripContainer, ToolStrip, and ContextMenuStrip. I'm creating a new instance and calling .ShowDialog() when my menu handler is called. When the user clicks on the form, I am calling contextMenuStrip.Show() to display the context menu over the form. I can dismiss the menu with ESC and then close the "dialog". At this point, VS seem to be in a normal state.
Is this what you're also doing? There's probably some critical difference here that I'm doing slightly differently. Could you clarify?
Thanks,
Aaron
Hi Aaron,
Yes, the crucial difference is in how ContextMenuStip is setup and invoked. Add ToolStripDropDownButton to the ToolStrip (step I omitted) and set its DropDown property to that ContextMenuStrip. Now, instead of calling .Show() on ContextMenuStrip click on the ToolStripDropDownButton so that context menu shows up. Hit Escape key to close the menu down and close the form. VS should be in a very weird state at that point.
BTW, just to make sure it's not my code, I was able to reproduce it on a brand new package with a simple form.
Thanks for looking into this for me.
Hi Sergey,
Thanks for the extra info. I am now able to repro this on VS 2005 & VS 2008. 
I'll open a bug and ask a few folks around the VS Platform team if they know what might be going on here.
Thanks,
Aaron