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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:45:39+00:00 2026-05-22T19:45:39+00:00

I have two components A and B. Component B derives from component A and

  • 0

I have two components A and B. Component B derives from component A and shares most properties and procedures with it. Now I have a lengthy procedure like this:

procedure DoSomething;
begin
  Form1.Caption := Component_A.Caption;
  // hundreds of additional lines of code calling component A
end;

Depending on whether component B is active or not, I would like to reuse the above procedure and replace the Component_A part with the name of component B. It should look like this then:

procedure DoSomething;
var
  C: TheComponentThatIsActive;
begin
  if Component_A.Active then
    C := Component_A;
  if Component_B.Active then
    C := Component_B;
  Form1.Caption := C.Caption;
end;

How can I do that in Delphi2007?

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-22T19:45:40+00:00Added an answer on May 22, 2026 at 7:45 pm

    TheComponentThatIsActive should be the same type that ComponentA is (TComponentA).

    Now, if you run into a stumbling block where some properties/methods only belong to ComponentB, then check and typecast it.

    procedure DoSomething;
    var
        C: TComponentA;
    
    begin
        if Component_A.Active then
            C := Component_A
        else if Component_B.Active then
            C := Component_B
        else
            raise EShouldNotReachHere.Create();
    
        Form1.Caption := C.Caption;
    
        if C=Component_B then
            Component_B.B_Only_Method;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two components that that communicate via TCP/IP. Component A acts as a
I have a dependent UIPicker that loads the values into its two components from
I have two date picker components and a JComboBox component with their associated Action
I have two components, a base Entity component: <cfcomponent persistent=true> <cfproperty name=Id fieldtype=id generator=native>
I have a UIPickerView that has two components. The number of rows in component
I have a multi-component UIPickerView in my application. Two components are plain and completely
I have two components. One is called InsideComp and one is called OutsideComp. OutsideComp
I am creating an application in which I have two mxml components, MainPanel.mxml and
I have two JSF <h:selectOneMenu> components. One called category another is subcategory . If
Say I have two classes, and neither of them are GUI components. Class A

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.