an.der.son Colaborador


Registrado: Quarta-Feira, 26 de Mai de 2004 Mensagens: 2275 Localização: Itaocara - RJ
|
Enviada: Qua Mai 09, 2007 9:18 am Assunto: [Dica] Listar glyphs do ImageList para usuário |
|
|
Código: |
function GetIndexFromImageList(ImgLst : TImageList; nCol, nRow: Word): Integer;
var
Frm : TForm;
SpdBtn : TBitBtn;
nL, nC : Word;
nIdx : Word;
begin
Frm := TForm.Create(Nil);
with Frm do
begin
Width := ImgLst.Width * nCol + 04;
Height := ImgLst.Height * nRow + 04;
BorderStyle := bsNone;
Left := Mouse.CursorPos.X;
Top := Mouse.CursorPos.Y;
AutoSize := True;
end;
nIdx := 0;
for nL := 1 to nRow do
begin
for nC := 1 to nCol do
begin
SpdBtn := TBitBtn.Create(Frm);
with SpdBtn do
begin
Parent := Frm;
Kind := bkClose;
Glyph := nil;
Caption := '';
NumGlyphs := 1;
SetBounds(nC * (ImgLst.Width +6) - (ImgLst.Width +6) + 1,
nL * (ImgLst.Height+6) - (ImgLst.Height+6) + 1,
ImgLst.Width + 6, ImgLst.Height + 6);
ImgLst.GetBitmap(nIdx,SpdBtn.Glyph);
Tag := nIdx;
Inc(nIdx);
end;
end;
end;
try
Frm.ShowModal;
finally
Result := Frm.ActiveControl.Tag;
FreeAndNil(Frm);
end;
end;
|
Este código é de minha autoria, veja se te serve. Eu a uso da seguinte maneira:
Código: |
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
BitBtn1.Glyph := nil;
ImageList1.GetBitmap(GetIndexFromImageList(ImageList1,9,9),BitBtn1.Glyph);
end;
|
Espero que sirva para alguem um dia  _________________ Estou de volta!!! |
|