Link to home
Start Free TrialLog in
Avatar of balrom
balrom

asked on

Assign a bitmap to a picture from an imagelist

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
Avatar of kretzschmar
kretzschmar
Flag of Germany image

guess

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

not tested

meikl ;-)
Avatar of balrom
balrom

ASKER

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?



ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of balrom

ASKER

Ok i've tryed this:

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

and works fine.

Thank you kretzschmar.


well, glad you got it work :-))
Avatar of balrom

ASKER

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