Board index » delphi » Best way create form on run-time

Best way create form on run-time

what's difference between following methods

1. MyForm := TMyForm.Create(Self)
2. TMyForm.Create(Application)

if I create form using 1st methods then I can't access any objects.
second methods seems I can access all object inside form after I create,
but if I use popup menu I get GPF

please mail me back.
Thanks in advanced

 

Re:Best way create form on run-time


Quote
Joe Yiu wrote:

> what's difference between following methods

> 1. MyForm := TMyForm.Create(Self)
> 2. TMyForm.Create(Application)

> if I create form using 1st methods then I can't access any objects.
> second methods seems I can access all object inside form after I create,
> but if I use popup menu I get GPF

> please mail me back.
> Thanks in advanced

To add to the question - where does this one fit in?

Application.CreateForm(TMyForm, MyForm);

TIA,
Gary Thornock
--
___________________________________________________________
"We are what we repeatedly do.  Excellence, therefore,
is not an act, but a habit."   -Aristotle
___________________________________________________________

Re:Best way create form on run-time


Quote
Joe Yiu wrote:

> what's difference between following methods

> 1. MyForm := TMyForm.Create(Self)
> 2. TMyForm.Create(Application)

> if I create form using 1st methods then I can't access any objects.
> second methods seems I can access all object inside form after I create,
> but if I use popup menu I get GPF

> please mail me back.
> Thanks in advanced

The Best way to create a new form is by using the Application object
method CreateFrom.

 Example:

 Application.CreateForm(MyForm,TMyForm);

--------------------------------------------------------------------
Alon Elish
Widecom Ltd, Israel.

E-Mail : a...@widecom.co.il
------------------------------------------------------------------

Re:Best way create form on run-time


Quote
In article <4k3e09$...@news2.ios.com> 3cl...@chelsea.ios.com "Joe Yiu" writes:
> what's difference between following methods

> 1. MyForm := TMyForm.Create(Self)
> 2. TMyForm.Create(Application)

> if I create form using 1st methods then I can't access any objects.
> second methods seems I can access all object inside form after I create,
> but if I use popup menu I get GPF

> please mail me back.
> Thanks in advanced

I'v never had a problem with
    MyForm := TMyForm.Create( application);

--
regards

Dave Gray                                 Nailsea Bristol UK 01275 857746
Bespoke Engineering & Technical Software       da...@davegray.demon.co.uk

Other Threads