Interfaces will be a big part of future Delphi (Kylix, JBuilder(?))
releases, so there may be some merit in getting to grips with them now?
In D6 you will see interface properties appearing in the object inspector at
design time and so forth (a use outside of designing a nice flat hierarchy)
which will allow you to reference a group of classes by a common interface.
i.e. Find all of the data aware controls on a form...
type
IDataAware = interface
['{293D20D0-0876-4B5A-8FDA-EC32E56042E9}']
procedure DoSomethingThatIsAware;
end;
...
var
intf: IMyDataAware
...
for i := 0 to ControlCount - 1 do
// No need to use the RTTI to check for a DataSource/DataField property
if Supports(Controls[i], IDataAware, intf) then
begin
Controls[i].ReadOnly := True; // or what ever!
or ...
inft.DoSomethingThatIsAware;
end;
I'm not sure if this functionality in D6, maybe someone could clarify, but
in theory you should be able to drop a TEdit on a form, right click on it,
select from the context menu an option that allows you to pick from a list
of available interfaces which interface(s) you would like to implement in
the TEdit i.e. IDataAware, IFormatTextAsCurrency, IChangeColourOnFocus etc..
You could then implement the same set of interfaces on a TGrid, TMemo,
TImage and so forth. (I suppose they would then appear in the Object
inspector?).
Cheers,
Andrew
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Sandeep
Sent: Wednesday, 13 June 2001 10:27 a.m.
To: Multiple recipients of list delphi
Subject: [DUG]: Interfaces
Is there any advantage of using interfaces?
Sandeep
Software Developer
CFL
[EMAIL PROTECTED]
http://www.cfl.co.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"
---------------------------------------------------------------------------
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"