unit U_InfoBtn;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, DB, ADODB;

type
  TfrmInfoBtn = class(TForm)
    ScrollBox1: TScrollBox;
    btn1: TSpeedButton;
    btn2: TSpeedButton;
    btn3: TSpeedButton;
    btn4: TSpeedButton;
    ADOTmp: TADOQuery;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    SpeedButton10: TSpeedButton;
    SpeedButton11: TSpeedButton;
    SpeedButton12: TSpeedButton;
    SpeedButton13: TSpeedButton;
    SpeedButton14: TSpeedButton;
    SpeedButton15: TSpeedButton;
    SpeedButton16: TSpeedButton;
    SpeedButton17: TSpeedButton;
    SpeedButton18: TSpeedButton;
    SpeedButton19: TSpeedButton;
    SpeedButton20: TSpeedButton;
    SpeedButton21: TSpeedButton;
    SpeedButton22: TSpeedButton;
    SpeedButton23: TSpeedButton;
    SpeedButton24: TSpeedButton;
    SpeedButton25: TSpeedButton;
    SpeedButton26: TSpeedButton;
    SpeedButton27: TSpeedButton;
    SpeedButton28: TSpeedButton;
    SpeedButton29: TSpeedButton;
    SpeedButton30: TSpeedButton;
    SpeedButton31: TSpeedButton;
    SpeedButton32: TSpeedButton;
    SpeedButton33: TSpeedButton;
    SpeedButton34: TSpeedButton;
    SpeedButton35: TSpeedButton;
    SpeedButton36: TSpeedButton;
    SpeedButton37: TSpeedButton;
    SpeedButton38: TSpeedButton;
    SpeedButton39: TSpeedButton;
    SpeedButton40: TSpeedButton;
    SpeedButton41: TSpeedButton;
    SpeedButton42: TSpeedButton;
    SpeedButton43: TSpeedButton;
    SpeedButton44: TSpeedButton;
    procedure FormDestroy(Sender: TObject);

    procedure FormShow(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
     procedure InitBtnInfo();
    { Private declarations }
  public
    FlagStr:String;
    FXSInfo:String;
    FSql:string;
    { Public declarations }
  end;

var
  frmInfoBtn: TfrmInfoBtn;

implementation
uses
  U_DataLink;

{$R *.dfm}

procedure TfrmInfoBtn.FormDestroy(Sender: TObject);
begin
  frmInfoBtn:=nil;
end;
procedure TfrmInfoBtn.InitBtnInfo();
var
  BB:array[0..100] of string;
  i,j:Integer;
begin

  with ADOTmp do
  begin
    Close;
    sql.Clear;
    sql.Add(FSql);
    Open;
  end;
  if ADOTmp.IsEmpty then
  begin
    Application.MessageBox('没有定义数据！','提示',0);
    Exit;
  end;
  with ADOTmp do
  begin
    First;
    i:=0;
    while not Eof do
    begin
      BB[i]:=Trim(fieldbyname('XSInfo').AsString);
      i:=i+1;
      Next;
    end;
  end;
  i:=i-1;
  if i>63 then
  begin
    i:=63;
  end;
  for j:=0 to i do
  begin
    with ScrollBox1 do
    begin
      TSpeedButton(Controls[j]).Visible:=True;
      TSpeedButton(Controls[j]).Caption:=BB[j];
      {TSpeedButton(Controls[j]).Hint:=BB[j];
      if Length(BB[j])>4 then
      begin
        TSpeedButton(Controls[j]).Caption:=Copy(Trim(BB[j]),1,4)+#13+Copy(Trim(BB[j]),5,Length(BB[j])-4);
      end else
        TSpeedButton(Controls[j]).Caption:=BB[j]; }
    end;
  end;
end;

procedure TfrmInfoBtn.FormShow(Sender: TObject);
begin
  InitBtnInfo();
end;

procedure TfrmInfoBtn.btn1Click(Sender: TObject);
begin
  FXSInfo:=Trim(TSpeedButton(Sender).Caption);
  ModalResult:=1;
end;

procedure TfrmInfoBtn.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 // Action:=caHide;

end;

end.
