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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:55:34+00:00 2026-06-04T21:55:34+00:00

I am working on a component that is derived from a commercial component suite,

  • 0

I am working on a component that is derived from a commercial component suite, and have run into a challenge, which I’ve never considered before. Consider the following code snippet:

TMyClass = class
protected
  procedure SomeMethod; virtual;
end;

TMyClass1 = class(TMyClass)
protected
  procedure SomeMethod; override;
end;

TMyMode = (mmOne, mmTwo);
TMyClass2 = class(TMyClass1)
private
  FMode: TMyMode;
protected
  procedure SomeMethod; override;
public
  property Mode: TMyMode read FMode write FMode;
end;

...

procedure TMyClass2.SomeMethod;
begin
  if FMode = mmOne then inherited SomeMethod
                   else inherited TMyClass.SomeMethod;
end;

So if Mode = mmOne then I inherit as normal, but if it is mmTwo, I still want to inherit the code from my ancestor’s ancestor, but not what was introduced in the ancestor. I’ve tried the above, with no success, and since I’ve never encountered this before, I gather it’s not possible. Any takers?

  • 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-06-04T21:55:36+00:00Added an answer on June 4, 2026 at 9:55 pm

    You can do this with class helpers:

    type
      TA = class
      public
        procedure X; virtual;
      end;
    
      TB = class(TA)
      public
        procedure X; override;
      end;
    
      TA_Helper = class helper for TA
        procedure A_X;
      end;
    
      TC = class(TB)
      public
        procedure X; override;
      end;
    
    procedure TA.X;
    begin
      // ...
    end;
    
    procedure TB.X;
    begin
      // ...
    end;
    
    procedure TA_Helper.A_X;
    begin
      inherited X; // TA.X
    end;
    
    procedure TC.X;
    begin
      A_X;
      inherited X; // TB.X
    end;
    

    I think class helpers exist in D2006, but if they don’t, you can also use a hack to the same effect:

    // ...
      TA_Helper = class(TA)
        procedure A_X;
      end;
    // ...
    procedure TC.X;
    begin
      TA_Helper(Self).A_X;
      inherited X; // TB.X
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a component derived from TCustomPanel. On that panel I have a
I'm working on a Python script that transforms this: foo bar Into this: [[Component
I have recently been working with a COM+ component that processes an input XML
I'm working on a .NET component that gets a set of data from the
I have an application that i am working on which needs actually a file
I have a component that inherits from JPanel, I draw a grid on it.
I'm working on a component that is a subclass from UIView and contains a
I'm working on a component that is placed on every form of my project.
I just discovered this component and started working with it. I understand that the
I have inherited a jquery component that simulates a dropdown for users to choose

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.