procedure TFFinalizarMesa.CriarBotoes;
var
Botoes: array of TSpeedButton;
x, Altura, Largura, Espaco, LarguraTotal, Esquerda, Topo: SmallInt;
i, cont, areapan, areabot :Integer;
img: string;
labelmesa: TLabel;
Evento: TNotifyEvent;
begin
SetLength(Botoes,5);
x := High(Botoes);
Altura := 70;
Largura := 70;
Espaco := 5;
LarguraTotal := (Largura*x)+(Espaco*x)-(Largura);
Esquerda := ((pBotoes.Width) - LarguraTotal) div 2;
Topo := (Altura + espaco) div 2;
begin
img := dsEmpresas.DataSet.FieldByName('pasta_img').AsString;
I := 1;
cont := 0;
dsMesas.DataSet.First;
while not dsMesas.DataSet.Eof do
begin
Botoes[I] := TSpeedButton.Create(pBotoes);
Botoes[I].Parent := pBotoes;
Botoes[I].Left := esquerda-largura;
Botoes[I].Top := Topo;
Botoes[I].Width := Largura;
Botoes[I].Height := Altura;
Esquerda := Esquerda + Largura + Espaco;
Botoes[i].Name := 'btnMESA' + dsMesas.DataSet.FieldByName('CODIGO').AsString;
Botoes[I].OnClick := btPadraoClick;
Botoes[I].ShowHint := true;
Botoes[I].Hint := dsMesas.DataSet.FieldByName('DESCRICAO').AsString;
Botoes[I].Layout := blGlyphTop;
Botoes[I].Caption := dsMesas.DataSet.FieldByName('DESCRICAO').AsString;
if DmPrincipal.ConsultaDB.ExecAsBoolean('SELECT OCUPADA FROM MESAS WHERE CODIGO = ' + IntToStr(I))
then
begin
Botoes[I].Glyph.LoadFromFile(img + 'true.bmp');
Botoes[I].Font.Size := 7;
Botoes[I].ParentFont := false;
Botoes[I].Font.Style := [fsBold];
Botoes[I].Font.Color := clRed;
end
else
begin
Botoes[I].Glyph.LoadFromFile(img + 'false.bmp');
Botoes[I].Font.Size := 7;
Botoes[I].ParentFont := false;
Botoes[I].Font.Color := clGreen;
end;
if I mod 5 = 0 then
begin
cont := cont + 1;
end;
if I > 5 then
begin
if not (I mod 5 = 0) then
begin
Botoes[I].Top := (((espaco * cont) - (espaco * 3)) + Altura * (cont + 1));
end
else
begin
Botoes[I].Top := (((espaco * cont) - (espaco * 4)) + (Altura * cont));
end;
http://www.activedelphi.com.br/forum/viewtopic.php?t=73851&sid=ecbbd8cb0af8af54f90f53e12b4f49db 1/2
31/08/2018 ActiveDelphi :: Exibir tópico - Trocar cor da fonte de speedbutton em runtime
if i - 5 = 0 then
begin
Botoes[I].Left := Botoes[1].Left;
end
else
begin
Botoes[I].Left := Botoes[i - 5].Left;
end;
end;
I := I+1;
dsMesas.DataSet.Next;
end;
end;
end;
http://www.activedelphi.com.br/forum/viewtopic.php?t=73851&sid=ecbbd8cb0af8af54f90f53e12b4f49db 2/2