Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7054439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:37:36+00:00 2026-05-28T03:37:36+00:00

continue with my previous investigation regarding the use of Interface with VCL. How to

  • 0

continue with my previous investigation regarding the use of Interface with VCL.

How to implement identical methods with 2 and more Classes?

How to use Interface with VCL Classes?

I would like to have a code example to demonstrate where and how the two work together.
Or what is the classic benefit/usage of the two:

ISomething = interface
['{EFE0308B-A85D-4DF3-889C-40FBC8FE84D0}']
...
end;

TSomeThing = class(TSomeVCLObject, ISomething)
...
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:37:37+00:00Added an answer on May 28, 2026 at 3:37 am

    Imagine you have TSomeThing and TSomeThingElse classes, but they do not have a common ancestor class. As-is, you would not be able to pass them to the same function, or call a common method on them. By adding a shared interface to both classes, you can do both, eg:

    type
      ISomething = interface 
      ['{EFE0308B-A85D-4DF3-889C-40FBC8FE84D0}'] 
      public
        procedure DoSomething;
      end; 
    
      TSomeThing = class(TSomeVCLObject, ISomething) 
        ... 
        procedure DoSomething;
      end; 
    
      TSomeThingElse = class(TSomeOtherVCLObject, ISomething) 
        ... 
        procedure DoSomething;
      end; 
    
    procedure TSomeThing.DoSomething;
    begin
      ...
    end; 
    
    procedure TSomeThingElse.DoSomething;
    begin
      ...
    end; 
    
    procedure DoSomething(Intf: ISomething);
    begin
      Intf.DoSomething;
    end;
    
    procedure Test;
    var
      O1: TSomeThing;
      O2: TSomeThingElse;
      Intf: ISomething;
    begin
      O1 := TSomeThing.Create(nil);
      O2 := TSomeThingElse.Create(nil);
      ...
      if Supports(O1, ISomething, Intf) then
      begin
        Intf.DoSomething;
        DoSomething(Intf);
      end;
      if Supports(O2, ISomething, Intf) then
      begin
        Intf.DoSomething;
        DoSomething(Intf);
      end;
      ...
      O1.Free;
      O2.Free;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a log tailer that will continue tailing after the previous
I continue my understanding of MVVC with the code of MSDN and I have
To continue to question further I'm more interested in blogs, websites who once in
As I continue to build more and more websites and web applications I am
How to continue from where I have been searching to find the index? I
Is it possible to use continue/break in a %control structure loop. For example: %
I want to continue on my previous question: https://stackoverflow.com/questions/3007168/torrents-can-i-protect-my-software-by-sending-wrong-bytes Developer Art suggested to add
I would like to format a gridview based on comparing the current row value
From a previous question , I have the following: So I have implemented a
I am posting a follow-up question to a previous question I had regarding reading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.