Solved

TImage form ImageList

Posted on 2000-03-09
10
1,138 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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