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

  • Home
  • SEARCH
  • 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 414463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:17:06+00:00 2026-05-12T18:17:06+00:00

Working with my ongoing TFrames-based component set project, I’m coming across various instances where

  • 0

Working with my ongoing TFrames-based component set project, I’m coming across various instances where I am wanting to replace one of the TFrame’s components (usually non-visual) at runtime with one that is generated dynamically at runtime.

I think I’ve probably found the answer to my immediate problem here, but in my own digging around and experimenting prior to finding that, it’s become clear I’ve got quite a bit to learn about how Delphi handles object references, particularly with respect to forms/frames, and (in general) class properties which are object references rather than non-pointer values.

A specific example of one experiment is here:

(On a form with three TButtons)

procedure TForm1.Button3Click(Sender: TObject);
var
  MyButton : TButton;

begin
  MyButton := TButton.Create(Self);
  MyButton.Caption := 'New Button';
  MyButton.Parent := Form1;
  Form1.Button2 := MyButton;
  Form1.Repaint;
  ShowMessage('Button2 caption = ' + Form1.Button2.Caption);
end;

Doesn’t replace Button2 with the created button, but does show both on the form. The ShowMessage results indicates Button2’s caption still = “Button2”

I find myself asking questions like, “Is this ‘non-replacement’ unique to forms, or would that be true for other classes as well?” etc. In short, I’ve discovered yet another sinkhole of my own ignorance. 😉 I find in working with instances/object references/derefencing/class definitions/class properties etc, that oftentimes things behave exactly as they expect them to, but other times, not at all, and not even close.

It’s clear I need to study up on this area. Rather than post stupid question after stupid question revolving around this subject, I thought I’d ask this instead:

What is a really good reference or tutorial for getting a better grasp on the subtle distinctions re: how Delphi handles such things?

Thanks in advance for all your help!

  • 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-12T18:17:07+00:00Added an answer on May 12, 2026 at 6:17 pm

    Those fields on the forms are there purely for your convenience when writing code. You can delete them from the .pas file and they’d still show up. The form’s layout is defined in the DFM, and the form object holds an internal list of references to the controls placed on it, just like any other visual control.

    I don’t know about tutorials on the subject, but I do know how you can replace a button. You’ve got it mostly right, but you also have to free Form1.Button2 before you overwrite the reference. That will cause the button to remove itself from the form’s control list as part of its destruction process. Or, if you want to save the button somewhere instead of destroying it, call Form1.RemoveControl(Button2); instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 192k
  • Answers 192k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I prefer one class per file. You'll never have to… May 12, 2026 at 6:17 pm
  • Editorial Team
    Editorial Team added an answer Use the Javascript Date function? Pass the date to JS… May 12, 2026 at 6:17 pm
  • Editorial Team
    Editorial Team added an answer If you put something like this in your .ssh/config: Host… May 12, 2026 at 6:17 pm

Related Questions

I know there is ongoing work for in this regards but what is the
I am currently working on a project with five other developers and we are
I am working on a drawing-based product where I want to produce versions for
When working with my .Net 2.0 code base ReSharper continually recommends applying the latest
I'm working with my ASP.NET development team to try and create better (i.e. cleaner)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.