Savoir si un objet implement une interface
Bonjour a tous j'ai créer une interface
Code:
1 2 3 4 5
|
ISecurity = interface(IInterface)
['{C05A0D2F-0E87-45E0-95DF-9315D1A02EEF}']
procedure CanSessionAcces(Session: TSession); stdcall;
end; |
et j'ai une class qui implemente cette interface
Code:
1 2 3 4 5 6 7 8 9 10
| TPersoBouton = class(TBitBtn, ISecurity)
private
........
procedure CanSessionAcces(Session: TSession); stdcall;
........
public
constructor Create(AOwner: TComponent); override;
published
..........
end; |
sur un formulaire ou je depose mon bouton j'ai la fonction suivante
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| procedure TFormPerso.securityControl;
var i: integer;
Int :ISecurity;
btn :TPersoBouton;
begin
for i:=0 to self.ComponentCount -1 do
begin
if Components[i].IsImplementorOf(int) then
begin
Int := Components[i] as ISecurity;
Int.CanSessionAcces(nil);
end;
end;
end; |
la condition Components[i].IsImplementorOf(int) retourne toujours false bien l'element à l'index i implement l'interface.
j'espère avoir exposé clairement mon probleme.
Cordialement.