Board index » cppbuilder » Transferring bitmap from TImageList to TMenuItem->Bitmap

Transferring bitmap from TImageList to TMenuItem->Bitmap


2003-11-23 07:52:26 PM
cppbuilder98
Currently I am using a TImageList to provide the images for TMenuItem
(by setting the imageindex value).
This works great... Except that when a TMenuItem is disabled Builder
will use its own algoritm to show the images greyed out. Unfortunately
these grey images look horrible.
I noticed that when I use TMenuItem's Bitmap I can also specify a
bitmap to be used. But unlike images that come from TImageList,
Builder leaves these bitmaps alone when you disable a TMenuItem.
That's a bit better. Yes, they're still in colour. But at least they
still look OK.
Apparently I cannot disable the automatic greying when using
TImageList bitmaps for TMenuItems (if I were able to disable that
behaviour, I can simply change the imageindex to reflect a grey or
coloured image depending on the enabled status of the MenuItem).
So I was looking for some way to change the TMenuItem's Bitmap during
runtime. If I enable the menu-item then I put in my colour bitmap,
When I disable the menu-item I put in my own 256-colour grey scale
image.
Currently I'm using something like this :
MenuItem->Bitmap->LoadFromResourceName((int)HInstance,"MENU_PICTURE");
But this requires me to compile the bitmap as a resource.
I was wondering, since I'm storing all the other TMenuItem bitmaps in
a TimageList anyway if there's a way to transfer a bitmap from a
TImageList to the Bitmap in a TMenuItem ?
An example :
How can I take e.g. the 3rd image in a TImageList and transfer it to
TMenuItem->Bitmap ?
Thanks,
 
 

Re:Transferring bitmap from TImageList to TMenuItem->Bitmap

"Kris" < XXXX@XXXXX.COM >wrote in message
Quote
Apparently I cannot disable the automatic greying when using
TImageList bitmaps for TMenuItems (if I were able to disable that
behaviour, I can simply change the imageindex to reflect a grey or
coloured image depending on the enabled status of the MenuItem).
For what you ask, you would have to OwnerDraw the menu in order to draw your
own images regardless of the menu's state.
Quote
How can I take e.g. the 3rd image in a TImageList and transfer
it to TMenuItem->Bitmap ?
You can use the ImageList's GetBitmap() method to update the menu item's
Bitmap when needed, ie:
ImageList1->GetBitmap(2, MenuItem1->Bitmap);
Gambit