Jump to content
Registration disabled at the moment Read more... ×
shineworld

How to check if an object implements an interface

Recommended Posts

Hi all,

I've many TFrame objects which can implement one or more interfaces, depends.

There is a Delphi way to check if a frame implements an interface?

E.g:
 

procedure UpdateTheme(Obj: TFrame);
begin
   if "Obj implements ITheme" then
      (Obj as ITheme).UpdateTheme;
end;

 

Share this post


Link to post
 
procedure UpdateTheme(Obj: TFrame);
var
  objAsIThen : ITheme;
begin
  If Supports(Obj, ITheme, objAsIThen) then
      objAsITheme.UpdateTheme;
end;

 

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×