我在工具栏中使用 Delphi 2009 Toolbuttons 创建,如下所示:创建 TToolbutton 运行时
不同之处在于我也在运行时分配了一个动作。我的代码如下:
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;
当我留下线条(标记的问题)时,我看到以下奇怪的行为:
我按下按钮并触发分配的操作,但按钮左侧的两个按钮设置为向下。当我再次按下另一个按钮时,左边的两个按钮向下,前面的按钮向上。
我需要帮助,我不知道原因
亲切的问候
克里斯汀