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:
in the DFM
- add a TToolBar named bar;
- in that TToolBar, put a TPanel.
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 ?