Board index » delphi » How to hide MDIChild forms during runtime creation

How to hide MDIChild forms during runtime creation

Does any one know how to hide a MDIChild form during a runtime creation?  I
have tried setting Visible to false, but it errors.  What happens at the
moment is that you can see the form being created then maximized and it look
really ugly while all of this happens.
Any thoughts?

Cheers,
Nick Barrett

 

Re:How to hide MDIChild forms during runtime creation


I dont have this problem... how do you create your MDIChild?
TMDIChild.Create(Application) ?

Quote
"Nick Barrett" <NBarr...@SentryCorp.com> wrote in message

news:3bafd2b2_1@dnews...
Quote
> Does any one know how to hide a MDIChild form during a runtime creation?
I
> have tried setting Visible to false, but it errors.  What happens at the
> moment is that you can see the form being created then maximized and it
look
> really ugly while all of this happens.
> Any thoughts?

> Cheers,
> Nick Barrett

Re:How to hide MDIChild forms during runtime creation


I have managed to fix it.  I found a very old post at google.  A guy said he
tried using LockWindowUpdate and it didn't work for him, but I tried it and
it worked.  (I had never heard of LockWindowUpdate before then)  Here's how
I do it now.

  LockWindowUpdate(MDIParentForm.Handle);
  TMDIChildForm.Create(Application);
  LockWindowUpdate(0);

I now have a new problem (As always...lol)  Every time I open and close an
MDIChild form the amount of memory my program uses seems to grow. (Is that
what is called a memory leak?)  Any way, I destroy the MDIChild forms by
calling their Release method.  Should I be using release?

Cheers,
Nick Barrett

Quote
"Michael Hansen" <Dyster_...@hotmail.com> wrote in message

news:3bafdbed_1@dnews...
Quote
> I dont have this problem... how do you create your MDIChild?
> TMDIChild.Create(Application) ?

> "Nick Barrett" <NBarr...@SentryCorp.com> wrote in message
> news:3bafd2b2_1@dnews...
> > Does any one know how to hide a MDIChild form during a runtime creation?
> I
> > have tried setting Visible to false, but it errors.  What happens at the
> > moment is that you can see the form being created then maximized and it
> look
> > really ugly while all of this happens.
> > Any thoughts?

> > Cheers,
> > Nick Barrett

Re:How to hide MDIChild forms during runtime creation


I would try and use the Free method of the form instead?

--
Paul Nicholls (Delphi 5)     Live long and optimise!
"Life is a beach - every so often you are swept out to sea by a rip and get
into trouble!"  - Paul Nicholls

 Home Page: www.southcom.com.au/~phantom
       < IF YOU WANT TO EARN MONEY WHILE YOU SURF ON THE NET GO HERE: >
       < http://www.alladvantage.com/go.asp?refid=BEM-274 >

Quote
Nick Barrett <NBarr...@SentryCorp.com> wrote in message

news:3bafe3ae_1@dnews...
Quote
> I have managed to fix it.  I found a very old post at google.  A guy said
he
> tried using LockWindowUpdate and it didn't work for him, but I tried it
and
> it worked.  (I had never heard of LockWindowUpdate before then)  Here's
how
> I do it now.

>   LockWindowUpdate(MDIParentForm.Handle);
>   TMDIChildForm.Create(Application);
>   LockWindowUpdate(0);

> I now have a new problem (As always...lol)  Every time I open and close an
> MDIChild form the amount of memory my program uses seems to grow. (Is that
> what is called a memory leak?)  Any way, I destroy the MDIChild forms by
> calling their Release method.  Should I be using release?

> Cheers,
> Nick Barrett

> "Michael Hansen" <Dyster_...@hotmail.com> wrote in message
> news:3bafdbed_1@dnews...
> > I dont have this problem... how do you create your MDIChild?
> > TMDIChild.Create(Application) ?

> > "Nick Barrett" <NBarr...@SentryCorp.com> wrote in message
> > news:3bafd2b2_1@dnews...
> > > Does any one know how to hide a MDIChild form during a runtime
creation?
> > I
> > > have tried setting Visible to false, but it errors.  What happens at
the
> > > moment is that you can see the form being created then maximized and
it
> > look
> > > really ugly while all of this happens.
> > > Any thoughts?

> > > Cheers,
> > > Nick Barrett

Re:How to hide MDIChild forms during runtime creation


Delphi's help says
"Any event handlers of the form should use Release instead of Free. Failing
to do so could lead to an access violation."
I have tried using Free but I get the access violations.
This is how I currently do it.

procedure TMDIChildForm.btnOKClick(Sender: TObject);
begin
  Release;
end;

Release is supposed to "Destroy the form and frees its associated memory"
but it doesn't appear to be happening.

Cheers,
Nick Barrett

PS: Is this getting OT for this newsgroup?

Quote
"Paul Nicholls" <paul_f_nicho...@hotmail.com> wrote in message

news:3bafe54a_1@dnews...
Quote
> I would try and use the Free method of the form instead?

> --
> Paul Nicholls (Delphi 5)     Live long and optimise!
> "Life is a beach - every so often you are swept out to sea by a rip and
get
> into trouble!"  - Paul Nicholls

>  Home Page: www.southcom.com.au/~phantom
>        < IF YOU WANT TO EARN MONEY WHILE YOU SURF ON THE NET GO HERE: >
>        < http://www.alladvantage.com/go.asp?refid=BEM-274 >
> Nick Barrett <NBarr...@SentryCorp.com> wrote in message
> news:3bafe3ae_1@dnews...
> > I have managed to fix it.  I found a very old post at google.  A guy
said
> he
> > tried using LockWindowUpdate and it didn't work for him, but I tried it
> and
> > it worked.  (I had never heard of LockWindowUpdate before then)  Here's
> how
> > I do it now.

> >   LockWindowUpdate(MDIParentForm.Handle);
> >   TMDIChildForm.Create(Application);
> >   LockWindowUpdate(0);

> > I now have a new problem (As always...lol)  Every time I open and close
an
> > MDIChild form the amount of memory my program uses seems to grow. (Is
that
> > what is called a memory leak?)  Any way, I destroy the MDIChild forms by
> > calling their Release method.  Should I be using release?

> > Cheers,
> > Nick Barrett

> > "Michael Hansen" <Dyster_...@hotmail.com> wrote in message
> > news:3bafdbed_1@dnews...
> > > I dont have this problem... how do you create your MDIChild?
> > > TMDIChild.Create(Application) ?

> > > "Nick Barrett" <NBarr...@SentryCorp.com> wrote in message
> > > news:3bafd2b2_1@dnews...
> > > > Does any one know how to hide a MDIChild form during a runtime
> creation?
> > > I
> > > > have tried setting Visible to false, but it errors.  What happens at
> the
> > > > moment is that you can see the form being created then maximized and
> it
> > > look
> > > > really ugly while all of this happens.
> > > > Any thoughts?

> > > > Cheers,
> > > > Nick Barrett

Re:How to hide MDIChild forms during runtime creation


"Nick Barrett" <NBarr...@SentryCorp.com> wrote in <3bafedb4$1_2@dnews>:

Quote
>Delphi's help says
>"Any event handlers of the form should use Release instead of Free.
>Failing to do so could lead to an access violation."
>I have tried using Free but I get the access violations.
>This is how I currently do it.

>procedure TMDIChildForm.btnOKClick(Sender: TObject);
>begin
>  Release;
>end;

>Release is supposed to "Destroy the form and frees its associated
>memory" but it doesn't appear to be happening.

Try to use close instead.

and on the form's onclose event set the action to caFree this does the trick for us.

Regards
Johnnie.

Re:How to hide MDIChild forms during runtime creation


Cheers for that.  Seems to be better now.

Cheers,
Nick Barrett

Quote
"Johnnie" <N...@Noware.non> wrote in message news:3bb04ec6$1_2@dnews...

> Try to use close instead.

> and on the form's onclose event set the action to caFree this does the
trick for us.

> Regards
> Johnnie.

Re:How to hide MDIChild forms during runtime creation


Quote
>Try to use close instead

That's what I use :)

--
Paul Nicholls (Delphi 5)     Live long and optimise!
"Life is a beach - every so often you are swept out to sea by a rip and get
into trouble!"  - Paul Nicholls

 Home Page: www.southcom.com.au/~phantom
       < IF YOU WANT TO EARN MONEY WHILE YOU SURF ON THE NET GO HERE: >
       < http://www.alladvantage.com/go.asp?refid=BEM-274 >

Other Threads