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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:16:06+00:00 2026-05-15T09:16:06+00:00

When Delphi (2006) goes quantum: I’ve got something that appears to be both a

  • 0

When Delphi (2006) goes quantum: I’ve got “something” that appears to be both a TToolBar and a TPanel, depending on how you observe it. I’d like to understand what’s going on.

Here is how to create it and what happens:

  1. in the DFM

    • add a TToolBar named bar;
    • in that TToolBar, put a TPanel.
  2. in the code and at runtime:

    • the panel appears in the list of buttons bar.Buttons[], let’s say at index i
    • bar.Buttons[i], from the compiler point of view, is a TToolButton
    • bar.Buttons[i].ClassName = ‘TPanel’
    • (bar.Buttons[i] is TToolButton) = true, but that’s the compiler optimising the call to ‘is’ out;
    • indeed IsBarButton(bar.Buttons[i]) is false for function IsBarButton (defined below);
    • bar.Buttons[i].Name is the name I gave the TPanel in the DFM
    • inspecting the value bar.Buttons[i] in the debugging:
      • it has a property ‘Caption’ the real TToolButton’s don’t have
      • strangely, it has all properties TToolButton’s have, like TToolButton.Indeterminate (=true).

IsToolButton:

function IsToolButton(X : TObject) : boolean;
begin
    Result := X is TToolButton;
end;

So bar.Buttons[i] both is and is not a TToolButton… what’s up ?

(Bottom story is I’d like to distinguish my TPanel from the genuine TToolButton’s. This I can do in more or less hackish ways. My goal by asking this question here, is to get a fuller understanding of what’s really happening here.)

Question: what is happening ?
Sub-question: is it legitimate to add a TPanel to a TToolBar ?

  • 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-15T09:16:06+00:00Added an answer on May 15, 2026 at 9:16 am

    The only thing the OS allows to be added to a tool bar is a tool button. To add anything else, you technically need to create a button and then put your other things on top of it. The button that gets added is literally a placeholder. It’s there to take up space so the next thing you add gets positioned properly.

    You can see this sometimes if the non-tool-button control you add is transparent. Then you can see the tool bar’s separator underneath, so it looks like there’s a vertical line running through the middle of your control.

    When you add a non-tool-button control to the tool bar, the Buttons property indeed lies about the type of the control. You’ll notice throughout ComCtrls.pas that TToolBar itself always casts the buttons to TControl and then checks whether they really descend from TToolButton. It’s completely legitimate to add non-buttons to a tool bar; that’s why the Form Designer allows it in the first place.

    I suggest you use the Form Designer to create your tool bar. That way, the IDE will maintain an identifier for you in your form, so you’ll always have a direct reference to your panel. You won’t have to go hunting for it in the tool bar. Even if you’re creating the tool bar manually, it’s a good idea to make an extra field to refer to the panel. Even if you move the panel around within the tool bar, it will still be the same object the whole time, so you needn’t worry about dangling references.

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

Sidebar

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.