Solved

TImage form ImageList

Posted on 2000-03-09
10
1,133 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now