Solved

Error when creating window handle in Winforms MDI App

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

20 Experts available now in Live!

Get 1:1 Help Now