Ja robiłem coś takiego
unit Format;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, ExtCtrls, StdCtrls, DBCtrls, ComCtrls, jpeg;
type
TFormatForm = class(TForm)
ScrollBox: TScrollBox;
DBImage1: TDBImage;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
LiczbaBtn : Integer;
Button : Array of TSpeedButton;
procedure SetDostepne();
procedure Kliknij(Sender: TObject);
public
{ Public declarations }
end;
var
FormatForm: TFormatForm;
implementation
{$R *.DFM}
uses DMod, Main, Splash;
procedure TFormatForm.SetDostepne();
var
i : Integer;
BLeft : Integer;
BTop : Integer;
begin
BLeft := 10;
BTop := 10;
with DMSingle do
begin
FormatyQuery.First;
i := 0;
while not FormatyQuery.Eof do
begin
SetLength(Button, i + 1);
Button[i] := TSpeedButton.Create(ScrollBox);
with Button[i] do
begin
Inc(LiczbaBtn);
Height := 55;
Width := 85;
Flat := True;
Transparent := True;
BitmapyTable.Locate('ID_BITMAPY', FormatyQuery.FieldByName('ID_BITMAPY').Value,[]);
Glyph := DBImage1.Picture.Bitmap;
Caption := '';
if not(i mod 4 = 0 ) then
BLeft := BLeft + 110
else
if (i >= 4)then
begin
BLeft := 10;
BTop := BTop + 60;
end;
Left := BLeft;
Top := BTop;
Name := 'B' + IntToStr(i);
Tag := FormatyQuery.FieldByName('ID_FORMAT').Value;
OnClick := Kliknij;
Parent := ScrollBox;
Inc(i);
FormatyQuery.Next;
end;
end;
end;
end;
//*****************************************************************************
procedure TFormatForm.Kliknij(Sender: TObject);
begin
SplashForm.Klikniecie(0);
DMSingle.FormatyQuery.Locate('ID_FORMAT', TComponent(Sender).Tag, []);
Close;
end;
//*****************************************************************************
procedure TFormatForm.FormCreate(Sender: TObject);
begin
DoubleBuffered := True;
Application.ProcessMessages;
DMSingle.BitmapyTable.First;
SetDostepne;
Top := MainForm.Top + 340;
Left := MainForm.Left + 15;
end;
//*****************************************************************************
procedure TFormatForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
i : Integer;
begin
for i := 0 to LiczbaBtn - 1 do
begin
Button[i].Parent := nil;
FreeAndNil(Button[i]);
end;
Action := caFree;
end;