Error creating window handle

R

Ramana

Hi,
I am working on a windows application (C#) which has number of tab pages
and each tab page contains large number of controls (labels, text boxes,
buttons etc).
After facing the window creation problem, I came to know that the maximum
no. of window handles per process is limited to 10000.
I thought of calculating the no. of user objects in the current process and
restrict the user to add more tabs pages if the total no. of user objects
exceeds 1000.

After few trials, I found that the 1000 limit is not the only reason for
this error.
If I run one single instance of my application with out any other
application on my desktop, then the error is coming at 1000 user objects.
But if I start two instances of the same application or If start few other
applications on my machine, then I am getting the "error creating window
handle" error before reaching the 1000 limit. Some times I am getting the
error after creating few hundreds of user objects also.

What is the limiting factor (other than the number of user objects) for
creating more windows. I have 1GB RAM on a 2.8 GHz machine with WinXP and I
don't think RAM is the problem.
I would like check for this limit before creating the new tab page itself.


Advance thanks.
-Ramana
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Ramana,

Indeed windows NT/XP has 10,000 windwos handles per process limit. But this
is a huge number. Rule of thumb is to have no more then 5,000 handles if
good performance. Application having 5,000 hwnds is considered as huge. For
win9x limit the limit is more severe. 200-250 hwnds at most.

Anyways even with 1,000 window handles you should consider redesign your
application. E.g. if you have grid with comboboxes for some fo the fields
consider reusing one combobox for all the cells. If you have control with a
lot of labels consider painting those labels your self instead of using
controls or create as many label control as you need to show at the same
time on the screen.
You have options I believe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top