15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


PropertyPage Allocation Problem

Sueli dos Santos Rabaзa -- suelir@nutecnet.com.br
Saturday, October 19, 1996

Environment: VC++ 4.0, Win32s 1.3, Win 95

Hi,

I am having problem in trying to display many pages with the same
template.
In my application, I have, inside a CDialogBar, a CPropertySheet
derivative with 18 CPropertyPages built with the same template, each
page has 120 owner-draw buttons. 
I try to tab among the pages,one by one,but when I tab the 10th page, I
receive the following messages in the debugwin screen:
"Error 04: LocalAlloc failed"
"Error 44: CreateWindow failed: Window class not found"
"Error 40: CreateDialog failed: Couldn't load menu or create window"
These messages appear only when I run on Win 3.1. I tested in Win95 and
worked fine.
I see there is a problem with memory allocation,but I don't know what to
do.
Is there any limit in loading controls in a dialog(CPropertyPage)?

I would appreciate any help.

Thank you.
Sueli





Roger Onslow/Newcastle/Computer Systems Australia/
Tuesday, October 22, 1996

[Mini-digest: 3 responses]

>In my application, I have, inside a CDialogBar, a CPropertySheet
>derivative with 18 CPropertyPages built with the same template, each
>page has 120 owner-draw buttons. 

Sounds like you should have one template that has a tab control in it rather 
than lots of instances of the same page.  With a tab control you can then 
change what information the dialog displays (by responding to tab selection), 
rather than displaying lots of identical pages (with the resources that 
consumes).

Roger
-----From: robmanderson@unn.unisys.com

Sueli,
 You've hit a 16 bit windows limit on the number of windows you can have open 
at one time.  If you hit this error on the 10th property page and each page has 
120 controls on it that means that your app alone has opened 1200 + windows.  
Frankly I'm surprised you are able to get that many windows - always thought 
the upper limit was around 600 windows under 16 bit windows.  To fix it you're 
going to have to either redesign your app to not require that many windows,  or 
you're going to have to destroy each property page as you tab away from it and 
recreate it when you tab back to it.

Rob

-----From: "Shrikanth Swaminathan" 

120*9 = 1080 : That seems painfully close to 1024.
And u have all sorts of magic numbers, with win32s. 
I once had a problem, with PropertyPages on Win32's, and while browsing
through the MFC source, did see some numbers but am not able to locate it
now.
A simple thing u could try is putting all controls on a single dialog, 
that way u know for sure.
wish u luck,

-------------------------------------------------------------------
S.Shrikanth  sshri@csi-gmbh.de
Ph (o) +49-231-55707214 (h) +49-231-7270030
-------------------------------------------------------------------
We are what we repeatedly do,
Excellence, then is not an act, but a habit
Aristotel
-------------------------------------------------------------------




Philip Shaffer -- shafferp@mindspring.com
Sunday, October 27, 1996

CPropertySheet (under Win16) creates each property page as it is =
displayed.  Once it has been created it continues to exist for the life =
of the CPropertySheet.

What you can do is write a derived CPropertySheet that dynamically =
destroys each CPropertyPage as the user navigates off of it.  The =
penalty is a slight hesitation is each page is re-created and some extra =
logic is required to make the data persistent across destroy/create =
cycles, but you effectively reduce the resource consumption to at most =
two property pages worth.  "Two?" you might ask.  Because the =
CPropertySheet uses the properties of the zero-indexed property page =
when creating all the others, you need to write your logic that the =
zero-index property page is a special case that is never deleted.  =
Otherwise, you would need to almost entirely rewrite the CPropertySheet =
to do what I'm describing.  (I've done this quite successfully in =
applications.)  This gives you effectively no limit to the number of =
pages you can have on a CPropertySheet.

----------
From:  Roger Onslow/Newcastle/Computer Systems =
Australia/AU[SMTP:Roger_Onslow@compsys.com.au]
Sent:  Tuesday, October 22, 1996 8:15 AM
To:  Sueli dos Santos Rabaga
Cc:  mfc-l
Subject:  Re: PropertyPage Allocation Problem

[Mini-digest: 3 responses]

>In my application, I have, inside a CDialogBar, a CPropertySheet
>derivative with 18 CPropertyPages built with the same template, each
>page has 120 owner-draw buttons.=20

Sounds like you should have one template that has a tab control in it =
rather=20
than lots of instances of the same page.  With a tab control you can =
then=20
change what information the dialog displays (by responding to tab =
selection),=20
rather than displaying lots of identical pages (with the resources that=20
consumes).

Roger
-----From: robmanderson@unn.unisys.com

Sueli,
 You've hit a 16 bit windows limit on the number of windows you can have =
open=20
at one time.  If you hit this error on the 10th property page and each =
page has=20
120 controls on it that means that your app alone has opened 1200 + =
windows. =20
Frankly I'm surprised you are able to get that many windows - always =
thought=20
the upper limit was around 600 windows under 16 bit windows.  To fix it =
you're=20
going to have to either redesign your app to not require that many =
windows,  or=20
you're going to have to destroy each property page as you tab away from =
it and=20
recreate it when you tab back to it.

Rob

-----From: "Shrikanth Swaminathan" 

120*9 =3D 1080 : That seems painfully close to 1024.
And u have all sorts of magic numbers, with win32s.=20
I once had a problem, with PropertyPages on Win32's, and while browsing
through the MFC source, did see some numbers but am not able to locate =
it
now.
A simple thing u could try is putting all controls on a single dialog,=20
that way u know for sure.
wish u luck,

-------------------------------------------------------------------
S.Shrikanth  sshri@csi-gmbh.de
Ph (o) +49-231-55707214 (h) +49-231-7270030
-------------------------------------------------------------------
We are what we repeatedly do,
Excellence, then is not an act, but a habit
Aristotel
-------------------------------------------------------------------





Philip Shaffer -- shafferp@mindspring.com
Tuesday, October 29, 1996

The persistence of data across destroy/create cycles (not delete/new) is =
pretty easy.  All you do is declare instance variables that hold the =
data from the controls.  Prior to destroying the property page, move the =
data into the instance attributes.  The window is detached from the =
CPropertyPage instance and destroyed.  When it's subsequently created =
and reattached to the CPropertyPage instance, you repopulate the =
controls from the instance attributes.  Although this sounds like a lot =
of work, your purpose here is to reduce the property sheet's overall =
consumption of scarce system resources.

You will basically need to copy both the CPropertySheet and CTabControl =
from the MFC v1.52 source code and rename them to be something else.  =
You will need to re-implement the CPropertySheet code that handles =
switching between CPropertyPages.  Sadly, I cannot post the relevant =
code because it was part of work done "for-hire" and thus belongs to a =
former client.  The work took me approximately two weeks and a good part =
of that was figuring out how everything worked together.  Your mileage =
may vary.

----------
From:  rwagner[SMTP:rwagner@genre.com]
Sent:  Tuesday, October 29, 1996 3:39 AM
To:  Philip Shaffer
Subject:  RE: PropertyPage Allocation Problem

Hello Philip,

Do you have any good examples of your suggestion?  The new and delete =
part is=20
pretty straightforward, but the data persistence part, I'm not sure how =
best to=20
proceed.  If you could post any relevant examples you have, or point to =
an=20
internet site that has them, I'm sure many people would find them useful =
(as=20
well as i)...

Thanks,
Rob Wagner

> What you can do is write a derived CPropertySheet that dynamically =
destroys=20
each CPropertyPage as the user navigates off of it.  The penalty is a =
slight=20
hesitation is each page is re-created and some extra logic is required =
to make=20
the data persistent [...]





| Вернуться в корень Архива |