Using ToolDockManager in 2nd Form

Docking/MDI for Windows Forms Forum

Posted 13 years ago by Mike
Avatar
Using Visual Studio 2005 C#

My project contains two forms:
1) Main form which contains only UI Studio tab strips
2) Secondary form which contains tab strips, dockmanager and toolwindows (some design-time, some run-time).

If I launch the secondary form with "ShowDialog" method, I receive 1 of 2 errors when closing the main form (after closing the secondary form)

Error 1

System.InvalidOperationException was unhandled
  Message="Object is currently in use elsewhere."
  Source="System.Drawing"
  StackTrace:
       at System.Drawing.Graphics.GetHdc()
       at ActiproSoftware.Drawing.DrawingHelper.MeasureString(Graphics g, String text, Font font, StringFormat format)
       at ActiproSoftware.UIStudio.TabStrip.TabStripRenderer.MeasureTabStripTab(Graphics g, TabStripPage tabStripPage)
       at ActiproSoftware.UIStudio.TabStrip.VisualStudio2005ToolWindowTabStripRenderer.MeasureTabStripTab(Graphics g, TabStripPage tabStripPage)
       at ActiproSoftware.UIStudio.TabStrip.VisualStudio2005DocumentWindowTabStripRenderer.MeasureTabStripTab(Graphics g, TabStripPage tabStripPage)
       at ActiproSoftware.UIStudio.TabStrip.TabStripTab.MeasureCore(Graphics g, Size availableSize)
       at ActiproSoftware.WinUICore.UIElement.Measure(Graphics g, Size availableSize)
       at ᐦ.MeasureCore(Graphics g, Size availableSize)
       at ActiproSoftware.WinUICore.UIElement.Measure(Graphics g, Size availableSize)
       at ActiproSoftware.UIStudio.TabStrip.TabStrip.MeasureCore(Graphics g, Size availableSize)
       at ActiproSoftware.WinUICore.UIControl.Measure(Graphics g, Size availableSize)
       at ActiproSoftware.WinUICore.UIControl.UpdateLayout()
       at ActiproSoftware.WinUICore.UIControl.Invalidate(InvalidationLevels levels, InvalidationTypes types)
       at ActiproSoftware.WinUICore.UIControl.OnLayout(LayoutEventArgs e)
       at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
       at System.Windows.Forms.Control.PerformLayout()
       at ActiproSoftware.WinUICore.UIContainerControl.UpdateLayout()
       at ActiproSoftware.WinUICore.UIContainerControl.Invalidate(InvalidationLevels levels, InvalidationTypes types)
       at ActiproSoftware.WinUICore.UIContainerControl.OnLayout(LayoutEventArgs e)
       at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
       at System.Windows.Forms.Control.PerformLayout()
       at ActiproSoftware.WinUICore.UIControl.UpdateLayout()
       at ActiproSoftware.WinUICore.UIControl.Invalidate(InvalidationLevels levels, InvalidationTypes types)
       at ActiproSoftware.WinUICore.UIControl.OnLayout(LayoutEventArgs e)
       at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
       at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty)
       at System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, String property)
       at System.Windows.Forms.Control.ControlCollection.Remove(Control value)
       at ActiproSoftware.UIStudio.Dock.AutoHideContainer.ᐁ(ToolWindow )
       at ActiproSoftware.UIStudio.Dock.DockManager.ᐁ(TabbedMdiWindow[] )
       at ActiproSoftware.UIStudio.Dock.DockManager.ᐁ(TabbedMdiWindow[] , Boolean )
       at ActiproSoftware.UIStudio.Dock.ToolWindow.Dispose(Boolean disposing)
       at System.ComponentModel.Component.Finalize()
Error 2

System.ArgumentException was unhandled
  Message="Parameter is not valid."
  Source="System.Drawing"
  StackTrace:
       at System.Drawing.Font.ToLogFont(Object logFont, Graphics graphics)
       at System.Drawing.Font.ToLogFont(Object logFont)
       at System.Drawing.Font.ToHfont()
       at ActiproSoftware.Drawing.DrawingHelper.MeasureString(Graphics g, String text, Font font, StringFormat format)
       at ActiproSoftware.UIStudio.Dock.DockRenderer.MeasureAutoHideTabCore(Graphics g, AutoHideTab autoHideTab)
       at ActiproSoftware.UIStudio.Dock.VisualStudio2005DockRenderer.MeasureAutoHideTab(Graphics g, AutoHideTab autoHideTab)
       at ActiproSoftware.UIStudio.Dock.AutoHideTab.MeasureCore(Graphics g, Size availableSize)
       at ActiproSoftware.WinUICore.UIElement.Measure(Graphics g, Size availableSize)
       at ActiproSoftware.UIStudio.Dock.AutoHideTabGroup.MeasureCore(Graphics g, Size availableSize)
       at ActiproSoftware.WinUICore.UIElement.Measure(Graphics g, Size availableSize)
       at ActiproSoftware.UIStudio.Dock.AutoHideTabStripPanel.MeasureCore(Graphics g, Size availableSize)
       at ActiproSoftware.WinUICore.UIControl.Measure(Graphics g, Size availableSize)
       at ActiproSoftware.WinUICore.UIControl.UpdateLayout()
       at ActiproSoftware.WinUICore.UIControl.Invalidate(InvalidationLevels levels, InvalidationTypes types)
       at ActiproSoftware.WinUICore.UIControl.OnLayout(LayoutEventArgs e)
       at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
       at System.Windows.Forms.Control.PerformLayout()
       at ActiproSoftware.WinUICore.UIControl.UpdateLayout()
       at ActiproSoftware.WinUICore.UIControl.Invalidate(InvalidationLevels levels, InvalidationTypes types)
       at ActiproSoftware.UIStudio.Dock.AutoHideTabGroup.ᐁ(ToolWindow )
       at ActiproSoftware.UIStudio.Dock.AutoHideContainer.ᐁ(ToolWindow )
       at ActiproSoftware.UIStudio.Dock.DockManager.ᐁ(TabbedMdiWindow[] )
       at ActiproSoftware.UIStudio.Dock.DockManager.ᐁ(TabbedMdiWindow[] , Boolean )
       at ActiproSoftware.UIStudio.Dock.ToolWindow.Dispose(Boolean disposing)
       at System.ComponentModel.Component.Finalize()
If I launch the secondary form using just the "Show" method, then my secondary form does not close immediately when I click the close button in the form's control box. Instead, when I click the button, the form first closes all toolwindows that I created at runtime. Then, when I click it a second time, it closes the secondary form. Finally, when I close the main it closes without any errors.

I have seen a couple of posts from users that seem to have this issue but they all "figured it out" but did not post a resolution. Any ideas? Unfortunately, I am unable to post my code. I can try to reproduce it with a test project (let me know).

Thanks,
Mike

Comments (15)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mike,

Question... in your Main method, do you run the main form like this?
Application.Run(new MainFormName())
If not, that could be causing things. A main app form needs a message queue properly instantiated and that's what does it.

If that isn't the problem, a small sample project emailed to us would help. Thanks!


Actipro Software Support

Posted 13 years ago by Mike
Avatar
That's how we're launching the main form. I'm trying to reproduce this issue in a test project and have now stumbled across another problem.

I can add toolwindows to my form, however, if I try to reposition the windows, the VS IDE crashes. It almost always occurs when I try to drag a toolwindow to the right side of the form. Any ideas?

Here's the info on my development environment:
Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727

Installed Edition: Professional

Microsoft Visual C# 2005 77626-009-0000007-41341
Microsoft Visual C# 2005
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I'm not sure what is causing that without seeing it myself. I just tested dragging and dropping of tool windows in C# Visual Studio 2005 RTM and didn't have any issues. Can you email the project to us?


Actipro Software Support

Posted 13 years ago by Mike
Avatar
Actually, I was able to reproduce the drag issue with the dock form in your sample project.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Can you post or email the exact steps to repro it?


Actipro Software Support

Posted 13 years ago by Mike
Avatar
OK, I can't seem to get the drag issue to happen consistently. Anyhow, here's a sample project which results in error. To reproduce the issue:
1) Run the project
2) Click "Button 1"
3) Close the child window after it runs
4) Close the main window [Error should occur]

If you run the same steps but launch the child using "Button 2", the error does not occur.

Stupid question: how do I post the project? Or should I email it to you?

[Modified at 12/15/2005 01:00 PM]
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You can e-mail it to us, that's easiest.


Actipro Software Support

Posted 13 years ago by Mike
Avatar
Email sent to support@acitprosoftware.com.
Posted 13 years ago by Mike
Avatar
To reproduce the issue, you need to move some of the toolwindows around before closing the child form.

Please let me know if you are still unable to reproduce the problem.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Nope, works fine here even after dragging tool windows around in different combinations. Are you sure you have the latest build of UIStudio?


Actipro Software Support

Posted 13 years ago by Mike
Avatar
I installed 1.5.41 yesterday and it didn't make a difference. The Shared adn WinUICore references still indicate 1.0.3705 and runtime version is 1.0.75. Is this all correct?

Also, this is happening on all of our development machines.
Posted 13 years ago by Mike
Avatar
What course of action can we take if you cannot reproduce the error? Is there a debug version I can use that will give you more information on the error?
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mike,

I had sent you an email Saturday morning about this issue. I was able to duplicate it but think I found a workaround for now. If you call Dispose on the child form right after the modal ShowDialog call, it seemed to work around the issue.


Actipro Software Support

Posted 13 years ago by Mike
Avatar
Sorry, I checked the forum before I checked my email. I did verify that this works. Are you still planning on working on a fix or is this the solution (either is fine by me)?
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes we will still look into it since it shouldn't be happening but at least you can work around the problem with that solution for now.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.