imagelist e listview
Olá
lá vai minha dúvida:
Como posso inserir icones no imagelist em runtime, pois os mesmo estarão com os respectivos caminhos salvos em arquivo *.ini, para posterior carregamento em uma listview
Obrigado!
lá vai minha dúvida:
Como posso inserir icones no imagelist em runtime, pois os mesmo estarão com os respectivos caminhos salvos em arquivo *.ini, para posterior carregamento em uma listview
Obrigado!
Sanses
Curtidas 0
Respostas
Sanses
23/03/2004
sobe
GOSTEI 0
Marcelo Saviski
23/03/2004
Veja se isso funciona:
imagelist.add(´Imagem.bmp´);
GOSTEI 0
Sanses
23/03/2004
não funciona, dá esta mensagem:
incompatible types ´tbitmap´ and ´string´
incompatible types ´tbitmap´ and ´string´
GOSTEI 0
Aroldo Zanela
23/03/2004
Colega,
Tenta esse aqui:
Carregando:
Tenta esse aqui:
procedure SetImageListFromBmp(Bitmap: TBitmap; ImageList: TImageList; Width, Height, Images: integer); var mask, image : TBitmap; R : TRect; cnt : integer; begin Assert( (Bitmap <> nil) and Assigned(ImageList) ); if Width < 1 then Width := Bitmap.Height; if Height < 1 then raise ERangeError.Create(´Height may not be less than 1´); if Bitmap.Width mod Width <> 0 then raise EInvalidOp.Create(´Bitmap width must be a multiple of Width´); if Bitmap.Height mod Height <> 0 then raise EInvalidOp.Create(´Bitmap height must be a multiple of Height´); ImageList.Clear; ImageList.Height := Height; ImageList.Width := Width; mask := TBitmap.Create; image := TBitmap.Create; try mask.Width := Width; mask.Height := Height; image.Width := Width; image.Height := Height; if Images < 1 then cnt := (Bitmap.Width div Width) +(Bitmap.Height div Height) else cnt := Images; R := Rect(0, 0, Width, Height); while (cnt > 0) and (R.Bottom <= Bitmap.Height) do begin R.Left := 0; R.Right := Width; while (cnt > 0) and (R.Right <= Bitmap.Width) do begin image.Canvas.CopyRect(Rect(0,0,Width,Height), Bitmap.Canvas, R); mask.Assign(image); // lower left pixel mask.Canvas.Brush.Color := image.Canvas.Pixels[0, image.Height -1]; mask.Monochrome := true; ImageList.Add(image, mask); Dec(cnt); Inc(R.Left, Width); Inc(R.Right, Width); end; Inc(R.Top, Height); Inc(R.Bottom, Height); end; finally mask.Free; image.Free; end; end;
Carregando:
MyBitmap.LoadFromFile( ´c:\somefile.bmp´ ); SetImageListFromBmp( MyBitmap, ImageList1, 0, MyBitmap.Height, 0 );
GOSTEI 0