?
Solved

Assign a bitmap to a picture from an imagelist

Posted on 2005-05-17
6
Medium Priority
?
452 Views
Last Modified: 2010-04-05
Hi Experts,
I have an imagelist with some preloaded images.
At runtime i want to show different status of my application using a Timage component.

What is the correct way to assign to the TPicture an image from the imagelist?

Best regards
0
Comment
Question by:balrom
  • 3
  • 3
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 14017408
guess

imagelist1.GetBitmap(Index, image1.picture.bitmap);

not tested

meikl ;-)
0
 

Author Comment

by:balrom
ID: 14017466
Oh, a solution from the top expert....

Thank you  kretzschmar, i've done the assignment suggested, it work but the new image is not repainted, this happen only when i force the redraw of the form (eg. by minimising/maximizing form).

Any idea?



0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 500 total points
ID: 14017489
well, no delphi on hand yet,
thats why guessing and no testing ;-)

try to set the tpicture to nil first like

image1.picture := NIL;
imagelist1.GetBitmap(Index, image1.picture.bitmap);

or just paint afterwards like

imagelist1.GetBitmap(Index, image1.picture.bitmap);
image1.refresh; //or repaint or simple paint

hope my guess helps :-))

meikl ;-)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:balrom
ID: 14017534
Ok i've tryed this:

  imagelist1.GetBitmap(Index, image1.picture.bitmap);
  image1.refresh;

and works fine.

Thank you kretzschmar.


0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 14017549
well, glad you got it work :-))
0
 

Author Comment

by:balrom
ID: 14129986
In some cases, using the solution posted above, i've verified that the images are not drawn correctly.
The best solution is a mix of the solutions gived by kretzschmar:

   image1.picture := nil;
   imagelist1.GetBitmap(Index, image1.picture.bitmap);
   image1.refresh;

This works always.

Regards
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

829 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