### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: [Solved] Query an image in a TPopupMenu  (Read 371 times)

#### petevick

• Full Member
• Posts: 197
##### [Solved] Query an image in a TPopupMenu
« on: January 30, 2023, 06:57:54 pm »
I know that you'd add an image to a TPopupMenu by this code snippet....
Code: Pascal  [Select][+][-]
2.   bmp:= TBitmap.Create;
4.      try
5.         imgList.GetBitmap(idx, bmp);
6.         bmp.Canvas.Brush.Color := clBlue;
7.         bmp.Canvas.Brush.Style := bsSolid;
8.         bmp.Canvas.Rectangle(0, 0, bmp.Width, bmp.Height);
9.         bmp.TransparentColor := clWhite;
10.         bmp.TransparentMode := tmFixed;
11.         bmp.Transparent := true;
13.         finally
14.         bmp.Free;
16.      end;

....but how would you query what the Canvas.Brush.Color is for any particular image in the TPopupMenu ?
I was originally thinking it'd probably be a similar code structure to the above, but now I'm not so sure
It might not even be possible of course
« Last Edit: January 30, 2023, 08:51:57 pm by petevick »
Pete Vickerstaff
Linux Mint 20.3 Cinnamon, Lazarus 2.2.0, FPC 3.2.2

#### GetMem

• Hero Member
• Posts: 4031
##### Re: Query an image in a TPopupMenu
« Reply #1 on: January 30, 2023, 08:17:54 pm »
Since Idx represents a unique image in the ImageList, save the Brush.Color to a dynamic array. Retrieve with FBrushColor(idx).

#### petevick

• Full Member
• Posts: 197
##### Re: Query an image in a TPopupMenu
« Reply #2 on: January 30, 2023, 08:51:26 pm »
Since Idx represents a unique image in the ImageList, save the Brush.Color to a dynamic array. Retrieve with FBrushColor(idx).
Thanks for the reply GetMem. I get an
Quote