小弟今天在看一个例程,里面有一个过程procedure createbutton(Toolbar:TToolbar;Const ButtonCaptions:array of String);是用来动态的增加toolbutton的,但是后面的Const ButtonCaptions:array of String这句动态数组的参数的申明不是很了解,还有,如果我要调用的话,用createbutton(?),那括号中应该怎么写呢?等着您的回复。

解决方案 »

  1.   

    找了一个例子和你的一样的。
    procedure TForm1.createbutton(Toolbar:Ttoolbar;Const ButtonCaptions: array of String);
      var
       I,m: Integer;
      begin
       m:=0;
       for I := 0 to High(ButtonCaptions) do
       begin
       with TToolButton.Create(ToolBar) do
       begin
       Parent := ToolBar;
       Caption := ButtonCaptions[I];
       onclick:=superbuttonclick;{为toolbutton增加鼠标click事件}
       if (ButtonCaptions[I]=‘|’) then{判断是不是分隔符}
       begin
       Style := tbsSeparator;
       m:=m+1;
       end
       else
       begin
       Style := tbsButton;
       imageindex:=I-m;
       end;
       end;
       end;
      end;
      
    他的主要功能是建立N个BUTTON。
    然后分别向他们给CAPTION。
      

  2.   

    调用过程如下:
    var
      toolbar:Ttoolbar;
      CaptionList:array[0..2] of String=(
       ‘A’,
       ‘B’,
       ‘C’);
    begin
     createbutton(toolbar,Captionlist);
    end;
      

  3.   

    string[] sCaption = new string[3] {"AA", "BB", "CC"};createbutton(Toolbar1, sCaption);