Autor Beitrag
joelrodrigues
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20



BeitragVerfasst: Sa 30.12.06 22:47 
Hi folks,

I have an IMAGELIST1 component which i added 3 images ('1.bmp', '2.bmp' and '3.bmp').

I also have an IMAGE1 component which loads an image from IMAGELIST1 in this way:
=======================================================
image1.Picture.Bitmap.Assign(nil); //clear content first
imagelist1.GetBitmap(0,image1.Picture.Bitmap); //show bitmap from imagelist - where 0 is the 1st image, 1 would be th 2nd and 2 the 3rd.
=======================================================

So, basically, i assigned and image in my IMAGE1 component by selecting an IMAGELIST1 image. Ok.

In some point in my application i need to know what is the image loaded in the IMAGE1 component ('1.bmp', '2.bmp' or '3.bmp'). If is not possible to recognize the filename, at least what is the image order number corresponding in the IMAGELIST1 (for example, if i could detect that the image order number was 1, i know that it corresponds to the '2.bmp' image).

How could i implement this?

Any idea or suggestion will be appreciated.

JOEL RODRIGUES
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 30.12.06 23:02 
I hope I've understood you the right way. ;)
You say it is possible to detect the index of the bitmap in image1:
Zitat:

at least what is the image order number corresponding in the IMAGELIST1

With this index you are able to build the filename:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var index: integer;

image1.Picture.Bitmap.Assign(nil); //clear content first
index := 0;
imagelist1.GetBitmap(index,image1.Picture.Bitmap); //show bitmap from imagelist - where 0 is the 1st image, 1 would be th 2nd and 2 the 3rd. 
showmessage('The filename is '+inttostr(index + 1)+'.bmp');

I hope this is helpful. ;)

Happy new year!

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
joelrodrigues Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20



BeitragVerfasst: So 31.12.06 13:32 
Hi Marco D.,

Your solution is very creative. Thanks man.

I discovered that the IMAGE component has a TAG property...


I assigned a TAG for each image, in this way:

======================================
image1.Picture.Bitmap.Assign(nil); //clear content first
imagelist1.GetBitmap(3,image1.Picture.Bitmap); //show bitmap from imagelist
image1.Tag := 3; // i did it for 0, 1 and 2 too
======================================


Then, in somewhere in my code i used:
======================================
if image1.tag = 3 then
begin
// my code
end;
======================================


Have a happy new year!