Board index » delphi » Error creating window (Delphi 1)

Error creating window (Delphi 1)

I'm still using Delphi 1 in Windows 3.1 and when I try to open a
window I get the error-message 'Error creating window'.

When I close the program, windows and restart, I can solve this
problem by opening the concerning window at once (instead of opening
first 3 or more other windows).

So I think this is a memory-problem.  However I create my form
everytime I try to open it (application.createForm(TMyForm, MyForm))
and in the close-event I've added 'action := caFree' in order to
destroy that window.

Can you help me ?

Ivan
eulae...@online.be

 

Re:Error creating window (Delphi 1)


Ivan,

I think increasing the heap will help. It's in one of the Delphi 1 menus.
The stack+heap cannot exceed 32K, I think, so you have to balance them if
they are already there. Default values don't add up to that much, so that's
probably OK. So, just increase heap by a few KB and see if that helps.

--
Mark Bratcher
mbra...@ix.netcom.com

Ivan <eulae...@online.be> wrote in article
<3395a6e6.3713...@news.online.be>...

Quote
> I'm still using Delphi 1 in Windows 3.1 and when I try to open a
> window I get the error-message 'Error creating window'.

> When I close the program, windows and restart, I can solve this
> problem by opening the concerning window at once (instead of opening
> first 3 or more other windows).

> So I think this is a memory-problem.  However I create my form
> everytime I try to open it (application.createForm(TMyForm, MyForm))
> and in the close-event I've added 'action := caFree' in order to
> destroy that window.

> Can you help me ?

> Ivan
> eulae...@online.be

Re:Error creating window (Delphi 1)


Quote
Mark Bratcher wrote:
> I think increasing the heap will help. It's in one of the Delphi 1
> menus.
> The stack+heap cannot exceed 32K, I think, so you have to balance them
> if
> they are already there. Default values don't add up to that much, so
> that's
> probably OK. So, just increase heap by a few KB and see if that helps.

I think you mean stack plus global variables (data segment). See below.

Quote
> Ivan <eulae...@online.be> wrote in article
> <3395a6e6.3713...@news.online.be>...
> > I'm still using Delphi 1 in Windows 3.1 and when I try to open a
> > window I get the error-message 'Error creating window'.
> > When I close the program, windows and restart, I can solve this
> > problem by opening the concerning window at once (instead of opening
> > first 3 or more other windows).
> > So I think this is a memory-problem.  However I create my form
> > everytime I try to open it (application.createForm(TMyForm, MyForm))
> > and in the close-event I've added 'action := caFree' in order to
> > destroy that window.

Just more info, no fix.

A vastly different number of windows can be created from the same D1
program
when running under 3.1, 95, NT 4.  I wrote a little program that does
nothing
but create edits that are displayed.  I could create roughly 350 under
3.1, 257
under 95 and 500+ under NT.
Moving global variables and structures from the data segment to the heap
definitively helps.  Decreasing the stack size helps.  Increasing the
local
heap make a marginal (1-3 edits) difference.
What I've done to circumvent the problem is to destroy the window
handles
for all non-visible components (usually on non-showing notebook pages)
using destroyhandle.  As DestroyHandle is not public, I had to come up
with a few girations but it did make a big difference.

Hope this bit helps,
Jochen

PS.If anyone has more info, please send me a copy or post it.

Re:Error creating window (Delphi 1)


Ivan,
  This error is normally the result of your app running out of windows
handles.  Each windowed control on a form will use up a windows handle once
it is displayed.  Unfortunately when you then hide the form the handle is
not freed up automatically.  For example if you have a form with a tabbed
notebook which has 5 pages with 100 edit boxes on each page then as you
look through each page additional handles are used up for each control on
that page.  By the time you get to the fifth page you will probably have
maxed out the number of handles available to the app (this is a fixed
number but I'm not sure what the limit is).  One solution to minimize the
problem is to use non-windowed controls where possible.  I.e. use a TLabel
and a TBevel instead of a TPanel.

Another thing you can do is to take a look at the code provided in TI3138
at Borland's web site ( http://www.borland.com/devsupport/delphi/ti_list/
).  This shows how to handle the problem with Tabbed Notebooks and can
probably be adjusted to work for other situations.

Hope this helps!
--

Rodney E Geraghty
GERA-Tech
Ottawa, Canada
gera...@ibm.net

Quote
> > Ivan <eulae...@online.be> wrote in article
> > <3395a6e6.3713...@news.online.be>...
> > > I'm still using Delphi 1 in Windows 3.1 and when I try to open a
> > > window I get the error-message 'Error creating window'.

> > > When I close the program, windows and restart, I can solve this
> > > problem by opening the concerning window at once (instead of opening
> > > first 3 or more other windows).

> > > So I think this is a memory-problem.  However I create my form
> > > everytime I try to open it (application.createForm(TMyForm, MyForm))
> > > and in the close-event I've added 'action := caFree' in order to
> > > destroy that window.

Re:Error creating window (Delphi 1)


I would like to thank everybody for his answer to my question.

With GetFreeResources I could find out where I lost my resources.  And
it seems that everytime I created a window, I didn't destroyed it,
altough I used 'action := caFree' in my close-event.

I've replaced this sentence with the 'Release' command, and now I free
my memory and don't lose any resources.

Thanks again for your tips !

Ivan
eulae...@online.be

Re:Error creating window (Delphi 1)


Hi...

I've had this one too...

First, make sure you create and destroy all your windows, contrary to
Delphi's default of auto-create. See the Project manager.

Second... Windows 3.x is real low on control handles, but Delphi makes it
real easy to create a form with, say 150 controls (TLabel, Tedit, ListBox
etc.) especially if you use scrollboxes or tabbed notebooks. Windows 3.x
won't handle these 'real world' forms!

I broke my app into 40 or so dialogue boxes. Not beautiful, but it worked.

Shaun

Other Threads