From: Jon Jenkins <jenkinsj@ozy.dec.com>
Subject: DELPHI **SERIUOS LIMITATION** WORKAROUND !!!!
Date: 11 Jun 1995 21:54:54 GMT

Hi,

After much hacking swearing and tantrums I have found
a workaround to this problem. To refesh memories
I had a 16 page tabbed notebook with approximately
7 lables and 8 edit boxes per page. I have
a few other forms with edit boxes in them.

It was not possible to display every page in the TabbedNotebook
as I was getting an EOutOfResources Exception.
This was narrowed down to some problem
local to the Delphi App as I could start and run
several other large Windows apps WHILE this problem
existed in the Delphi App. It was not a problem with
stack/heap or any global resource problem. So it has
to be some problem local to the Delphi App or with
the way Delphi interacts with Windows as this 
app really is a pretty trvial one in terms of
Windows resources.

To cut a long story short I have found a
solution to my immediate problem. The solution
is applicable to any control that is in a form
and itself contains child controls such as edit
boxes etc. When the control such as a Notebook 
page is displayed the Delphi app creates child windows
for each control of the current page. As the
current page is hidden the child windows STAY
in existance **forever** and obviously clog up
something within the Delphi App or Windows.

The solution was when the page is about to change in
a TabbedNotebook I get the old page and send a
WM_CLOSE message to all the controls on that page.
Unlike before the child windows now disappear from
the Winsight display and I can have all the windows
in my app open AND tab thru the notebook pages: ALL of them.

Obviously the Delphi App knows when a control has
a window handle and creates them if necessary.

Anyway here is my code fix:

procedure T<Name>.TabbedNotebook1Change(Sender: TObject;
                                        NewTab: Integer;
                                        var AllowChange: Boolean);
var
Pindex : integer;
ob     : TTabPage;
ms     : Tmessage;

begin
with Sender as TTabbedNotebook do
   begin
   { get the page index for current page }
   pindex := PageIndex;
   {get the object for that page }
   ob:=TTabpage(Pages.objects[pindex]);
   ms.msg:=WM_CLOSE;
   ms.Wparam:=0;
   ms.Lparam:=0;
   {broadcast a close message to all controls on page }
   ob.BroadCast(ms);
   end;
end;

This doesnt fix the problem it just makes it go away in
my particlular application. The limit is still there
somewhere. But I think the take home message is if a
control is not visible then send it a WM_CLOSE message
to release whatever it is hogging, Delphi will recreate
whatever is necessary when it comes time to display
it again.

I have had contact from Borland and sent them an exe
They have said they will have a look into the problem.

Good Luck


-- 
----------------------------------------------------------------------
Name:        Dr Jon Jenkins
Location:    Digital Equipment Corp, NaC, 
             Burnett Place, Research Park, 
             Bond University, Gold Coast
             QLD, AUSTRALIA 4229
Phone:       61-75-75-0151
Fax:         61-75-75-0100
Internet:    jenkinsj@ozy.dec.com
Close Proximity: "HEY YOU !!!"

The opinions expressed above are entirely personal and do not
reflect the corporate policy of DEC or the opinions of DEC management.
-----------------------------------------------------------------------

