-1

我在工具栏中使用 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;

当我留下线条(标记的问题)时,我看到以下奇怪的行为:

我按下按钮并触发分配的操作,但按钮左侧的两个按钮设置为向下。当我再次按下另一个按钮时,左边的两个按钮向下,前面的按钮向上。

我需要帮助,我不知道原因

亲切的问候

克里斯汀

4

1 回答 1

1

AutoCheck如评论中所述,我可以在设置操作后复制您的问题。

您的错误是没有对问题中链接的问题给出的公认答案给予足够的关注。设置属性,答案是按钮的父级。Left链接答案的评论中也提到了这一点,这是该问题试图解决的问题的原因(尽管存在不同的问题-可能都与索引混乱有关)。

于 2015-01-31T21:51:33.060 回答