Solved

TImage form ImageList

Posted on 2000-03-09
10
1,136 Views
Last Modified: 2012-08-13
Who can i show an image from an imagelist ?
is there a component for it ?
I don't want to load it manually, because i change the icon in the ImageList and want that it is automatically updated in every TreeView, ListView, ... and in my TImage !
0
Comment
Question by:snoopy_Spy
  • 5
  • 4
10 Comments
 
LVL 10

Expert Comment

by:Lischke
ID: 2602118
Hi Snoopy,

do it so: assign an event handler to TImageList.OnChange. In this handler you can retrieve the imagelist bitmap:

  FMyImage.Picture.Bitmap.Handle := FMyImagList.GetImageBitmap;

Ciao, Mike
0
 

Author Comment

by:snoopy_Spy
ID: 2602224
But where can i select the index ?
0
 

Author Comment

by:snoopy_Spy
ID: 2602231
and how can i recognize which image was changed ?
The TImage should only be reainted, when the image with the index was changed !
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 13

Expert Comment

by:Epsylon
ID: 2602307
I don't think you can detect which image in the list has been changed...

Use this to get an image with a specific index:

procedure TForm1.Button1Click(Sender: TObject);
var b: TBitmap;
begin
  b := TBitmap.Create;
  ImageList1.GetBitmap(index, b);
  Image1.Picture.Assign(b);
  b.Free;
end;
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2602311
This is even better:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ImageList1.GetBitmap(index, Image1.Picture.Bitmap);
end;
0
 

Author Comment

by:snoopy_Spy
ID: 2602338
Epsylon,
Are you sure, that the 2nd one is correct ?
I get an EAccessViolation Exception when i close the application !
Can i make it with an Handle ?
I don't want to create every time a TBitmap  
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2602559
I have no problems with it, so I guess it must be something else that causes the exception. I've tested this in Delphi 3 and 5.
0
 

Author Comment

by:snoopy_Spy
ID: 2602586
I found it, why i get the exception ! (I use D5)
This now gets no exception
    if i <> nil then
        i.GetBitmap(0, im.Picture.Bitmap);

But only the first time the OnChange Event is called, the Bitmap is loaded. The other calls doesn't change the Bitmap !

when i use :

    if i <> nil then
    begin
        im.Picture.Bitmap := nil;
        i.GetBitmap(0, im.Picture.Bitmap);
    end;

it works, but the image is "flashing ?" - I change the Image every 250 ms and it's blinking ....
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 50 total points
ID: 2602664
Set form1.doublebuffered to true or put the TImage inside a panel and set panel.doublebuffered to true. Using a panel increases speed and consumes less memory.
0
 

Author Comment

by:snoopy_Spy
ID: 2602684
Thanxs
Now working fine !
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question