By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,795 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,795 IT Pros & Developers. It's quick & easy.

HELP: Error creating window handle

P: n/a
I have 30 - 40 type of different window.
For each type I need about 20 instances of the window.

When I try to create them, I get "Error creating window handle"
My guess is there is a maximum number of window handle, because if I reduce
to about 2 instances of each window,
it can run. But not 20 instances of each window.

Does anyone know what the problem is? is it really because it exceeds the
maximum number of window handle?
If it is, how do I increase this maximum number of window handles?
Is there any other way around this?

This is really critical.
Furthermore, the number of types of window and the number of instances for
each type might further increase.
Thanks.

Regards,
Altramagnus
Nov 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Windows itself has some limitations on the number of concurrent windows that
it runs well with. This was a well-known problem in earlier versions of
Windows such as Windows 95. I don't know what the situation is with newer
versions such as XP, but as a desktop system it's likely that it works best
with a reasonably small number of windows, such as the average user might
have open at any one time - you know, perhaps at most a half-dozen
applications, maybe only two or three unminimized at any one time.

The situation you're describing has something like 600 to 800 windows open
at once. I'm baffled to imagine an application that would have literally
hundreds of windows open at once. Because you're posting this in a .Net
newsgroup, I assume you're creating windows through the normal
System.Windows.Forms classes such as Form, and not coding directly to the
Windows API to create windows. Could you describe your application and the
problem that it's designed to solve, to give us an idea of what you're
trying to accomplish? Maybe once we have an idea of what you're doing, we
might have some suggestions that would help out.

Thanks,
Tom Dacon
Dacon Software Consulting
"Altramagnus" <al*********@hotmail.com> wrote in message
news:41********@news.starhub.net.sg...
I have 30 - 40 type of different window.
For each type I need about 20 instances of the window.

When I try to create them, I get "Error creating window handle"
My guess is there is a maximum number of window handle, because if I reduce to about 2 instances of each window,
it can run. But not 20 instances of each window.

Does anyone know what the problem is? is it really because it exceeds the
maximum number of window handle?
If it is, how do I increase this maximum number of window handles?
Is there any other way around this?

This is really critical.
Furthermore, the number of types of window and the number of instances for each type might further increase.
Thanks.

Regards,
Altramagnus

Nov 22 '05 #2

P: n/a
The OS is Windows XP Professional SP1.
Yes the software is coded in C#.

It is a real-time command and control system (client).
The PC is suppose to display thousands of moving entity, for example cars,
buses, etc.
The user can pinpoint on any entity and display all the information about
that particular entity.
Such information can be quite a lot, so each window may have up to hundreds
of controls ( text boxes, labels, buttons ).
And the user may choose to display multiple windows of such entity.
There are probably up to 30 - 40 different types of entity, so there are
30 - 40 different types of windows.
( This is a rough estimate, may be more )

I have 1 GB of RAM entirely for the software. ( The PC is only meant to run
this software ).
The idea is to create 20 instances of each type of window beforehand and
keep them hidden, and display them when necessary.
It is implementated this way rather than adhoc newing a window and then
disposing it, because time is critical.
Moreover I have 1 whole GB of RAM available for this program.
The main purpose is to use memory to overcome speed.

Regards,
Altramagnus


"Tom Dacon" <td****@community.nospam> wrote in message
news:Ou**************@TK2MSFTNGP12.phx.gbl...
Windows itself has some limitations on the number of concurrent windows that it runs well with. This was a well-known problem in earlier versions of
Windows such as Windows 95. I don't know what the situation is with newer
versions such as XP, but as a desktop system it's likely that it works best with a reasonably small number of windows, such as the average user might
have open at any one time - you know, perhaps at most a half-dozen
applications, maybe only two or three unminimized at any one time.

The situation you're describing has something like 600 to 800 windows open
at once. I'm baffled to imagine an application that would have literally
hundreds of windows open at once. Because you're posting this in a .Net
newsgroup, I assume you're creating windows through the normal
System.Windows.Forms classes such as Form, and not coding directly to the
Windows API to create windows. Could you describe your application and the
problem that it's designed to solve, to give us an idea of what you're
trying to accomplish? Maybe once we have an idea of what you're doing, we
might have some suggestions that would help out.

Thanks,
Tom Dacon
Dacon Software Consulting
"Altramagnus" <al*********@hotmail.com> wrote in message
news:41********@news.starhub.net.sg...
I have 30 - 40 type of different window.
For each type I need about 20 instances of the window.

When I try to create them, I get "Error creating window handle"
My guess is there is a maximum number of window handle, because if I

reduce
to about 2 instances of each window,
it can run. But not 20 instances of each window.

Does anyone know what the problem is? is it really because it exceeds the maximum number of window handle?
If it is, how do I increase this maximum number of window handles?
Is there any other way around this?

This is really critical.
Furthermore, the number of types of window and the number of instances

for
each type might further increase.
Thanks.

Regards,
Altramagnus


Nov 22 '05 #3

P: n/a
A long time ago I had a similar problem to solve, although not as large as
yours. I ran into the same limitation when I tried to use controls for each
of the images I needed to display (it was a directed graph problem, and the
images were nodes in the graph). Instantiating a control for each of the
images required the Windows API to create a new window, and not only did I
run into limitations on how many controls I could create, the performance
was poor when the graphs were small enough that I could stay within the
Windows limits on the number of concurrent windows. So far this sounds
pretty much like your problem.

Instead of creating controls for each of the items, I created a set of
classes, one for each type of image, and wrote for each class the code that
enabled it to draw its own image. None of the objects required a window of
its own, and they were able to draw themselves quickly and easily on the
background of the control that displayed the graph.

Each of the classes got Location and Size properties, which the owning class
set to coordinates and dimensions in the coordinate system of the control
upon which they drew themselves. Each class had a Paint method, which took
as an input argument the Graphics object it needed to send its graphics
output to. The Paint method was called from the Paint event handler of the
control that held the graphic display of the whole network. Whenever some
interesting event happened to cause one of the nodes to need to be moved,
the owning form updated coordinates in one or more of the objects and just
invalidated the client area of the display control, causing its Paint event
to fire.

I did this in an earlier version of VB, probably VB 3.0 if I remember
correctly. It would be vastly easier to do it today in VB.Net or C# using
GDI+ calls. With today's speedy processors and high-performance graphics
processors, I'd bet that it would not be necessary to go through the
acrobatics of having each object try to erase its previous position and
redraw itself elsewhere on the canvas. With double-buffering, you could
redraw the whole works into an off-screen buffer for each update and then
switch it onto the screen in a single step. It would be simple and
light-weight and quick.

Regards,
Tom Dacon
Dacon Software Consulting

"Altramagnus" <al*********@hotmail.com> wrote in message
news:41********@news.starhub.net.sg...
The OS is Windows XP Professional SP1.
Yes the software is coded in C#.

It is a real-time command and control system (client).
The PC is suppose to display thousands of moving entity, for example cars,
buses, etc.
The user can pinpoint on any entity and display all the information about
that particular entity.
Such information can be quite a lot, so each window may have up to hundreds of controls ( text boxes, labels, buttons ).
And the user may choose to display multiple windows of such entity.
There are probably up to 30 - 40 different types of entity, so there are
30 - 40 different types of windows.
( This is a rough estimate, may be more )

I have 1 GB of RAM entirely for the software. ( The PC is only meant to run this software ).
The idea is to create 20 instances of each type of window beforehand and
keep them hidden, and display them when necessary.
It is implementated this way rather than adhoc newing a window and then
disposing it, because time is critical.
Moreover I have 1 whole GB of RAM available for this program.
The main purpose is to use memory to overcome speed.

Regards,
Altramagnus


"Tom Dacon" <td****@community.nospam> wrote in message
news:Ou**************@TK2MSFTNGP12.phx.gbl...
Windows itself has some limitations on the number of concurrent windows

that
it runs well with. This was a well-known problem in earlier versions of
Windows such as Windows 95. I don't know what the situation is with newer
versions such as XP, but as a desktop system it's likely that it works

best
with a reasonably small number of windows, such as the average user might have open at any one time - you know, perhaps at most a half-dozen
applications, maybe only two or three unminimized at any one time.

The situation you're describing has something like 600 to 800 windows open at once. I'm baffled to imagine an application that would have literally
hundreds of windows open at once. Because you're posting this in a .Net
newsgroup, I assume you're creating windows through the normal
System.Windows.Forms classes such as Form, and not coding directly to the Windows API to create windows. Could you describe your application and the problem that it's designed to solve, to give us an idea of what you're
trying to accomplish? Maybe once we have an idea of what you're doing, we might have some suggestions that would help out.

Thanks,
Tom Dacon
Dacon Software Consulting
"Altramagnus" <al*********@hotmail.com> wrote in message
news:41********@news.starhub.net.sg...
I have 30 - 40 type of different window.
For each type I need about 20 instances of the window.

When I try to create them, I get "Error creating window handle"
My guess is there is a maximum number of window handle, because if I

reduce
to about 2 instances of each window,
it can run. But not 20 instances of each window.

Does anyone know what the problem is? is it really because it exceeds the maximum number of window handle?
If it is, how do I increase this maximum number of window handles?
Is there any other way around this?

This is really critical.
Furthermore, the number of types of window and the number of

instances for
each type might further increase.
Thanks.

Regards,
Altramagnus



Nov 22 '05 #4

P: n/a
I think you misunderstood.
For those moving entities, i did not use any controls to draw them at all.
Instead, as you said, i am using GDI+ to paint them and using double
buffering.
That whole canvas is only 1 picture box.

However, the user is able to click on any of the entity, and upon doing so,
a window has to be poped up to display information. It is this window
that has lots of controls, because it is a typical window with text boxes,
labels and buttons.

I do not think it is appropriate to draw my own window on the canvas.
Coz the windows are supposed to be normal windows, maximizable, minimizable,
closable
able to move out of the canvas.
It is this information window that I am trying to instantiate about 20 for
each entity type.
Thanks.

Regards,
Altramagnus

"Tom Dacon" <td****@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
A long time ago I had a similar problem to solve, although not as large as
yours. I ran into the same limitation when I tried to use controls for each of the images I needed to display (it was a directed graph problem, and the images were nodes in the graph). Instantiating a control for each of the
images required the Windows API to create a new window, and not only did I
run into limitations on how many controls I could create, the performance
was poor when the graphs were small enough that I could stay within the
Windows limits on the number of concurrent windows. So far this sounds
pretty much like your problem.

Instead of creating controls for each of the items, I created a set of
classes, one for each type of image, and wrote for each class the code that enabled it to draw its own image. None of the objects required a window of
its own, and they were able to draw themselves quickly and easily on the
background of the control that displayed the graph.

Each of the classes got Location and Size properties, which the owning class set to coordinates and dimensions in the coordinate system of the control
upon which they drew themselves. Each class had a Paint method, which took
as an input argument the Graphics object it needed to send its graphics
output to. The Paint method was called from the Paint event handler of the
control that held the graphic display of the whole network. Whenever some
interesting event happened to cause one of the nodes to need to be moved,
the owning form updated coordinates in one or more of the objects and just
invalidated the client area of the display control, causing its Paint event to fire.

I did this in an earlier version of VB, probably VB 3.0 if I remember
correctly. It would be vastly easier to do it today in VB.Net or C# using
GDI+ calls. With today's speedy processors and high-performance graphics
processors, I'd bet that it would not be necessary to go through the
acrobatics of having each object try to erase its previous position and
redraw itself elsewhere on the canvas. With double-buffering, you could
redraw the whole works into an off-screen buffer for each update and then
switch it onto the screen in a single step. It would be simple and
light-weight and quick.

Regards,
Tom Dacon
Dacon Software Consulting

"Altramagnus" <al*********@hotmail.com> wrote in message
news:41********@news.starhub.net.sg...
The OS is Windows XP Professional SP1.
Yes the software is coded in C#.

It is a real-time command and control system (client).
The PC is suppose to display thousands of moving entity, for example cars,
buses, etc.
The user can pinpoint on any entity and display all the information about that particular entity.
Such information can be quite a lot, so each window may have up to

hundreds
of controls ( text boxes, labels, buttons ).
And the user may choose to display multiple windows of such entity.
There are probably up to 30 - 40 different types of entity, so there are
30 - 40 different types of windows.
( This is a rough estimate, may be more )

I have 1 GB of RAM entirely for the software. ( The PC is only meant to

run
this software ).
The idea is to create 20 instances of each type of window beforehand and
keep them hidden, and display them when necessary.
It is implementated this way rather than adhoc newing a window and then
disposing it, because time is critical.
Moreover I have 1 whole GB of RAM available for this program.
The main purpose is to use memory to overcome speed.

Regards,
Altramagnus


"Tom Dacon" <td****@community.nospam> wrote in message
news:Ou**************@TK2MSFTNGP12.phx.gbl...
Windows itself has some limitations on the number of concurrent windows
that
it runs well with. This was a well-known problem in earlier versions
of Windows such as Windows 95. I don't know what the situation is with

newer versions such as XP, but as a desktop system it's likely that it works

best
with a reasonably small number of windows, such as the average user might have open at any one time - you know, perhaps at most a half-dozen
applications, maybe only two or three unminimized at any one time.

The situation you're describing has something like 600 to 800 windows open at once. I'm baffled to imagine an application that would have literally hundreds of windows open at once. Because you're posting this in a ..Net newsgroup, I assume you're creating windows through the normal
System.Windows.Forms classes such as Form, and not coding directly to the Windows API to create windows. Could you describe your application and the problem that it's designed to solve, to give us an idea of what you're
trying to accomplish? Maybe once we have an idea of what you're doing, we might have some suggestions that would help out.

Thanks,
Tom Dacon
Dacon Software Consulting
"Altramagnus" <al*********@hotmail.com> wrote in message
news:41********@news.starhub.net.sg...
> I have 30 - 40 type of different window.
> For each type I need about 20 instances of the window.
>
> When I try to create them, I get "Error creating window handle"
> My guess is there is a maximum number of window handle, because if I
reduce
> to about 2 instances of each window,
> it can run. But not 20 instances of each window.
>
> Does anyone know what the problem is? is it really because it
exceeds the
> maximum number of window handle?
> If it is, how do I increase this maximum number of window handles?
> Is there any other way around this?
>
> This is really critical.
> Furthermore, the number of types of window and the number of

instances for
> each type might further increase.
>
>
> Thanks.
>
> Regards,
> Altramagnus
>
>



Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.