可以考虑自己生成类似的东西。
我用ScrollBox生成了一个按钮的容器。
procedure TForm1.showresent;
const
leftsi: Integer = 5;
topsi: Integer = 5;
btnwidth: Integer = 80;
btnheight: Integer = 70;
var
bbtt: array of TSpeedButton;
i, j, curleft, curtop, dbtncount: Integer;
mstream: TMemoryStream;
frmComponent: Tcomponent;
begin
LockWindowUpdate(Application.MainFormHandle);
{ 遍历Form组件 }
dbtncount := 0;
for i := 0 to ComponentCount - 1do
begin
frmComponent := Components;
if (frmComponent is TSpeedButton) then
if ((frmComponent as TSpeedButton).parent = ScrollBox1) then
{ 如果组件为Tlabel型则当作Tlabel处理,以下同 }
Inc(dbtncount);
end;
SetLength(bbtt, dbtncount);
j := 0;
for i := 0 to ComponentCount - 1do
begin
frmComponent := Components;
if (frmComponent is TSpeedButton) then
if ((frmComponent as TSpeedButton).parent = ScrollBox1) then
{ 如果组件为Tlabel型则当作Tlabel处理,以下同 }
begin
bbtt[j] := (frmComponent as TSpeedButton);
Inc(j);
end;
end;
for I := 0 to j - 1do
bbtt.Free;
Resentquery.Close;
Resentquery.Open;
SetLength(bbtt, Resentquery.RecordCount);
Resentquery.First;
curleft := leftsi;
curtop := topsi;
i := 0;
while not Resentquery.eofdo
begin
bbtt := TSpeedButton.Create(Self);
bbtt.Parent := ScrollBox1;
bbtt.Layout := blGlyphTop;
bbtt.Width := btnwidth;
bbtt.Height := btnheight;
bbtt.flat := True;
bbtt.Top := curtop;
bbtt.Left := curleft;
bbtt.Hint := Resentquery.FieldByName('filename').AsString;
bbtt.ShowHint := True;
bbtt.name := 'spbtn' + inttostr(i + 1);
bbtt.Caption := Resentquery.FieldByName('name').AsString;
bbtt.OnClick := dynamicbtClick;
bbtt.PopupMenu := resentPopup;
if not Resentquery.FieldByName('ico').IsNull then
begin
mstream := TMemoryStream.Create;
TBlobField(Resentquery.FieldByName('ico')).SaveToStream(mStream);
;
mstream.Position := 0;
bbtt.Glyph.LoadFromStream(mstream);
mstream.Free;
end;
curleft := curleft + leftsi + btnwidth;
if curleft + leftsi + btnwidth > ScrollBox1.Width then
begin
curleft := leftsi;
curtop := curtop + topsi + btnheight;
end;
Inc(i);
Resentquery.Next;
end;
bbtt := nil;
LockWindowUpdate(0);
end;