[DUG] basic question

Edward Koryagin ed_iv2001 at yahoo.co.nz
Thu Jul 26 08:55:58 NZST 2007


;) May be we are talking about different things?

In your case you were probably tricked by Delphi
(optimizer??)...

Yes, if you have just ShowMessage in your method
everything will be fine. But ... did you try to assign
value to some local variable? You will have AV cause
we don't have the object of the class.

--- Conor Boyd <Conor.Boyd at trimble.co.nz> wrote:

> I'll say it again: no you won't. ;-)
> 
> I'll clarify my posting for you.
> 
> If you tried what the original poster said (I'm
> using D2006), and
> recreated it (i.e. create two forms, make the second
> one not
> autocreated, add a method to the second form with a
> simple ShowMessage
> in it, and call that method on the object reference
> for the form), you
> will definitely not get an AV.
> 
> Using the references in your line below, you can
> happily invoke a method
> on your FormB variable with no AVs - if, as Myles
> said, there is no code
> in that method that refers to instance properties,
> fields, etc.
> 
> E.g.
> In your project source the following will (maybe
> surprisingly) not AV:
> begin
> 	Application.Initialise;
> 	Application.CreateForm(TFormA, FormA);
> 	FormB.SomeMethodThatOnlyCallsShowMessage;
> 	Application.Run;
> end;
> 
> Maybe the compiler has inlined it or something, I
> don't know.
> 
> C.
> 
> -----Original Message-----
> From: delphi-bounces at delphi.org.nz
> [mailto:delphi-bounces at delphi.org.nz]
> On Behalf Of Edward Koryagin
> 
> Yes I do ;) 
> 
> if you don't have
>   Application.CreateForm(TFormB, FormB); in your
> project source you will
> have AV
> 
> --- Conor Boyd <Conor.Boyd at trimble.co.nz> wrote:
> 
> > No you don't. ;-)
> > 
> > Try it.
> > 
> > C. 
> > 
> > -----Original Message-----
> > From: delphi-bounces at delphi.org.nz
> > [mailto:delphi-bounces at delphi.org.nz]
> > On Behalf Of Edward Koryagin
> > 
> > Remove FormB from AutoCreate list and you will
> have
> > AV.
> > 
> > --- David Moorhouse <delphi at moorhouse.net.nz>
> wrote:
> > 
> > > The Delphi compiler creates an implicit
> parameter
> > to Self and places 
> > > it before the other params to the method.
> 
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to
> delphi-request at delphi.org.nz with Subject:
> unsubscribe
> 


Edward Koryagin

Send instant messages to your online friends http://au.messenger.yahoo.com 


More information about the Delphi mailing list