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 6898411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:17:34+00:00 2026-05-27T07:17:34+00:00

I need to get a list of form types, but only for types derived

  • 0

I need to get a list of form types, but only for types derived from a given base form.

I use Delphi 2010 and enhanced RTTI to browse types

My current code is:

rc := TRTTIContext.Create;
rtyps := rc.GetTypes;
for rtyp in rtyps do
begin
  if not(rtyp.IsInstance) then Continue;

  // Now I need to check if rtyp.AsInstance.MetaclassType is derived from TMyBaseForm
end;

I dont want to instanciate an object and use the ‘is’ operator, as it would not execute in a timely manner.
As a current workaround, I test if a method, introduced in TMyBaseForm, was found in the RTTI context:

if (rtyp.GetMethod('MyMethod') = nil) then Continue;

but this is not a clean solution, as it can lead to issue if a method with the same name was introduced in another class branch.

So, my question: is there a regular way to detect if a class type is derived from another class type?

Thanks,

  • 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-27T07:17:35+00:00Added an answer on May 27, 2026 at 7:17 am

    When you call the AsInstance returns a TRttiInstanceType , from there you must access the MetaclassType property wich is a TClass reference to the reflected type, finally using the TClass you can call the InheritsFrom function

    for rtyp in rtyps do
    if (rtyp.TypeKind=tkClass) and rtyp.IsInstance and rtyp.AsInstance.MetaclassType.InheritsFrom(TMyBaseForm) then
    begin
    
      // do something
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to get the list of domain names on my network... but i
i have a problem with sql query. I need to get list of users.
I need a get a list of all databases in a Couchdb server inside
I need to get a list of all tables that are published for replication
I need to get a list of tags in a text, make their contents
I need to get the list of dates between two dates - for e.g.
I have an app where I need to get the list of countries,languages etc
I am developing an application in which I need to get the list of
I have a List<List<String>> I need to get a List of all possible concatenation
I have a little doubt. I need to get a list of the files

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.