Re: How to minimize windows instead of closing?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Wed, 23 Sep 2009 22:23:23 -0400
Since GDI handles are rarely used or retained beyond the OnPaint handler in most cases,
this may not be an issue. Only in a few rare cases are they commonly retained outside the
OnPaint handler, such as HBRUSHes for OnCtlColor handlers, and HBITMAPs. The 16K limit
on HWNDs may be more serious.
In one app I did, we built a set of nested tabbed dialogs based on an external description
(for simplicity, pretend it was defined in an XML-like notation). It had features like
"Controller N has 8 outputs" and I had to create eight tabs, each one of which could have
tens of subcontrols and in some cases hundreds of subcontrols. The way I made it work was
to destroy all the child controls when the tab was hidden, and re-create them when the tab
was made visible. A complex internal control structure maintained the values, including
the fact that the values were being updated in realtime by messages from embedded
controllers. Therefore, I would create a single controller that might require 20,000
windows to show every control, value, label, etc. but I rarely showed more than about 200
at a time (a few heavily-populated pages required over 350 windows, and many required only
a couple dozen). In addition, I could simultaneously run 30-40 embedded controllers,
since only one controller at a time would typically be displayed (if I couldn't create
windows, the user got an error message displayed on the window surface; but in fact if a
view was maximized, the non-active views also had their child windows destroyed). Since
it never made sense to try to show 40 windows concurrently (they were too small to be
useful) the common paradigm was to either have two to four controllers visible, or one
controller at a time, fully maximized. So the window limit posed no problem. When a tab
was clicked, the page appeared instantly; the cost of re-creating a couple hundred windows
was undetectable, even on a slow Win95 laptop (330 MHz, 500MB machines).
Note that the notion of "hiding" a window may allow a user to never detect that a large
number of window handles have been consumed, and this must be planned for.
The issue of one document and view per object might also be questionable; it depends on
the nature of the objects. If the objects are lightweight and numerous, and do not have
persistent state, single-document multiple-view MDI might be a better approach, but since
we have no parameters on the quantity of objects, their persistence, or their "weight", it
is hard to offer advice. In fact, if the objects have no individual persistent state, it
is not at all clear why a separate document is required; you can simply add new views to
the one-and-only existing document, and each view knows which object it is supposed to
display. Don't feel forced into a one-object-one-document-one-view model if a
many-objects-one-document-many-views model will do the job. At this point I have
insufficient information to offer more specific advice.
joe
On Wed, 23 Sep 2009 12:42:43 -0700 (PDT), Seetharam <smisro@xxxxxxxxx> wrote:
Alir is right with the solution. But beware that such a design mayJoseph M. Newcomer [MVP]
have issues if your app is a UI intensive one. There are limits to GDI
handles for every app ( on a regular 32-bit machaine the limit is
10,000).
http://msdn.microsoft.com/en-us/library/ms724291(VS.85).aspx
-Seetharam
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- How to minimize windows instead of closing?
- From: MicroEbi
- Re: How to minimize windows instead of closing?
- From: AliR
- Re: How to minimize windows instead of closing?
- From: Seetharam
- How to minimize windows instead of closing?
- Prev by Date: Re: How to minimize windows instead of closing?
- Next by Date: Re: CMutex /CEvent (multiple threads)
- Previous by thread: Re: How to minimize windows instead of closing?
- Next by thread: Re: How to minimize windows instead of closing?
- Index(es):
Relevant Pages
|