I create with Delphi 2009 Toolbuttons in a toolbar like it is desribed here: Create TToolbutton runtime
The difference is that I assign an action also at runtime. My code is as follows:
Function TSymbolVisWin.MakeButton(BCnt:integer; Act:TAction):integer;
var
TB : TToolButton;
ACnt, Ind: Integer;
begin
TB:=TToolButton.Create(ListBar);
try
with TB {NB} do
begin
Parent:=ListBar;
Action:=act; // here seems to be the difference
Style:=tbsButton;
grouped:=false;
Enabled:=true;
ShowHint:=True;
Tag:=BCnt;
Hint:=Act.Hint;
caption:='';
Wrap:=False;
ImageIndex:=Act.ImageIndex;
// here comes the problem
if ListBar.ButtonCount > 0 then
Left:=ListBar.Buttons[ListBar.ButtonCount-1].Left+tb.Width
else
Left:=0; }
// end of problem
end;
except
end;
When I leave the lines (marked problem) in, I see followin strange behaviour:
I press the button and the assigned action is fired, but the button two buttons left is set to down. when I press an other button again the button two buttons left get down and the button before gets up.
I need help, I have no idea for the reason
Kind regards
Christine
I can duplicate your problem when actions have AutoCheck
set, as mentioned in the comments.
Your mistake is to not to pay enough attention to the accepted answer given to the question linked in your question. The answer have the button parented after setting the Left
property. This is also mentioned in the comments to the linked answer to be the cause of the very problem that the question tries to resolve (although a different one there - probably both related with indexes getting messed up).