LOL. I figured that was the case. Was a bit cheeky of me to point it out really... never mind, I think Dave Jollie has received about 5 alternative approaches now so I think the community has probably answered his question ;-)
David. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Myles Penlington > Sent: Wednesday, 26 February 2003 2:33 PM > To: Multiple recipients of list delphi > Subject: RE: [DUG]: How do I refer back to a calling form? > > > Yeah, I was waiting for that - after I read the rest of your message. > Whoops. > Myles. > > > -----Original Message----- > From: David Brennan [mailto:[EMAIL PROTECTED] > Sent: Wednesday, 26 February 2003 1:24 p.m. > To: Multiple recipients of list delphi > Subject: RE: [DUG]: How do I refer back to a calling form? > > > Myles, > > This is not quite correct? > > Mmmm, maybe I am just being pedantic but further on my email did actually > mention that you could achieve this by using RTTI. However I > don't think it > is a good solution as it is comparitively slow, bypasses the normal type > checking and is just generally "messy". > > I also gave an example of how to achieve it by using interfaces.... > > Cheers, > David. > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Behalf Of Myles Penlington > > Sent: Wednesday, 26 February 2003 12:18 PM > > To: Multiple recipients of list delphi > > Subject: RE: [DUG]: How do I refer back to a calling form? > > > > > > > > >To answer your question tho... there isn't really any way that > > you can get > > >the code in DatabaseUtils.pas to directly access properties declared in > > >TMainForm without having MainForm.pas in your uses clause (which > > obviously > > >you don't want for generic database utilities). Having said that > > there are > > >various options. You could define a generic form class which has the UV > > >property and then descend TMainForm from it. eg, > > > > This is not quite correct. You can do this with RTTI (have to declare > > property as published) - I have done it before to stop circular > references > > between units and packages - it's not nice, but does have it uses. > > eg > > To set a "PUBLISHED" event property on a class without having a > > reference > > in the units uses clause. > > > > if Assigned( Application.MainForm ) and > > Application.MainForm.ClassNameIs('TApplicationMainForm') then begin > > Method.Code := @TDataUnit.OnEnvironmentChanged; > > Method.Data := Self; > > SetMethodProp( Application.MainForm, 'OnEnvironmentChange', > Method ); > > end; > > > > Of course a cleaner way would be to use interfaces to achieve the > > same thing > > (why didn't I think of that at the time)??? > > > > eg > > Something like. > > > > if Assigned( Application.MainForm ) and Application.MainForm.Supports( > > IMyEnvironmentInterface) then > > IMyEnvironmentInterface := Application.MainForm; > > IMyEnvironmentInterface.OnEnvironmentChange := > > Self.OnEnvironmentChanged > > end; > > > > > > Myles. > > > > > > ------------------------------------------------------------------ > > --------- > > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > > Website: http://www.delphi.org.nz > > To UnSub, send email to: [EMAIL PROTECTED] > > with body of "unsubscribe delphi" > > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > > ------------------------------------------------------------------ > --------- > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > ------------------------------------------------------------------ > --------- > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/