Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error when creating window handle in Winforms MDI App

Posted on 2009-07-13
3
Medium Priority
?
742 Views
Last Modified: 2013-12-17
I have written a Windows Forms MDI Application. In this application the user is allowed to create new windows without any restriction. At some point, after creating several hundreds of windows, the following error occurs:

System.ComponentModel.Win32Exception: Fehler beim Erstellen des Fensterhandles.
   bei System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
   bei System.Windows.Forms.Control.CreateHandle()
   bei System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   bei System.Windows.Forms.Control.CreateControl()
   bei System.Windows.Forms.Control.ControlCollection.Add(Control value)

How can I test, if the next window to create can be created successfully or not?
Or how can I test, if the program has reached 90% of the maximum handles, so that I can stop creating new windows early enough to ensure, the rest of the programm will go on working correctly, because if I will stop one window before the maximum the program possibly will need more handles without creating new windows and the error will occur later without creating any new window.
So the best would be to test, if the program has reached x% of the maximum handles. Does someone know how to do this or does someone has any other suggestion to solve my problem?
 
Thanks for any help.
0
Comment
Question by:thbruns
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 

Author Comment

by:thbruns
ID: 24839380
Perhaps I should add some information here:

A fix mamimum number of windows, the user can create, is no solution, because the application has different types of windows. Some of them have many child controls others only have a few.
0
 

Author Comment

by:thbruns
ID: 24839417
... and I assume the number of available handles differ for some operating systems.

So I need to know how many window handles does my application use at the moment and how many window handles can my application use at maximum.
0
 

Accepted Solution

by:
thbruns earned 0 total points
ID: 24861122
I have found the solution to get the number of user objects and gdi object per process. See:
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c73c.aspx
(see section 40.8 on that page)

To get the current used handles use the following code:
System.Diagnostics.Process.GetCurrentProcess().Handle
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

670 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