Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TImage form ImageList

Posted on 2000-03-09
10
Medium Priority
?
1,149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

636 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