Solved

Error when creating window handle in Winforms MDI App

Posted on 2009-07-13
3
724 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now