>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/