Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • Last Modified:

TImageLists and TMenuItems - bitmaps

Hi Folks,

I've got a TActionList filled with actions I want to use.  At times, these actions maybe disabled.  If I use a TSpeedButton, and set it's action property to one of my actions, the bitmap changes.  If I set the action to Enabled := false, the bitmap disappears.  This is because I'm using a 16x16 bitmap with only a signle state (and NumGlyphs set to 1 for the SpeedButton).

If I change the ImageList to contain 32x16 glyphs, change the TSpeedButtons to use NumGlpyhs := 2, then all works well when I enable or disable the action.

Except for the menu items.  The menu items show two images - the enabled and disabled state - per item.

My question is, how do you use the same ImageList and Action list to work with both TSpeedButtons and TMenuItems?

Thanks!

Stuart.
0
Stuart_Johnson
Asked:
Stuart_Johnson
  • 3
  • 2
  • 2
1 Solution
 
Wim ten BrinkSelf-employed developerCommented:
Don't! Sorry...
Link the MainMenu component to an imagelist with 16x16 images and the actionlist to the 32x16 imagelist.
It is possible to create the 16x16 imagelist dynamically based upon the other imagelist. All you have to do is walk through the images in the 32x16 imagelist and add those images to the 16x16 imagelist, in the FormCreate event.
0
 
Eddie ShipmanAll-around developerCommented:
How can you tell him to not use the same imagelist?
We currently use 16x16 images in our imagelist and assign the actions to BOTH menus and speedbuttons.
We see no problems with the disabled images on all but one of the glyphs.

Delphi should create the disabled bitmap on the fly when it doesn't have one.

If he "copies" the 32x16 images to the 16x16 imagelist he will need to delete every odd image before being
able to use it effectively because the imagelist will contain disabled bitmaps in the odd indexes.

0
 
Wim ten BrinkSelf-employed developerCommented:
Simple... TMenu can be linked to a different imagelist than the TActionList. His problem is theneed for 32x16 with TBitBtn and 16x16 for TMenu. So NO 16x16 images for the buttons! Of course, Delphi will create the disabled image if it's missing but what if he doesn't want this disabled image???
My suggestion is just one imagelist with the images in 32x16 and a second, empty imagelist which will be filled with 16x16 images in runtime, if some code to do this is written.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Eddie ShipmanAll-around developerCommented:
I was just saying that he doesn't need the 32x16 imagelist due to Delphi creating the disabled images for him.
I would think that having two imagelists with practically the same images is a bit of overhead for any program.
0
 
Stuart_JohnsonAuthor Commented:
The disabled images weren't being created for me automatically which is why I'm using 32x16.  I thought delphi automatically created the disabled glyphs, but it's not.

If I create a TSpeedButton and put a 16x16 _16 COLOUR_ glyph on it, it renders a disabled glyph perfectly.  If I use a 256 colour glyph (which is what I'm using), it doesn't create the disabled glyph.

I'll use Alex's code because that worked perfectly.  I just setup a secondary image list during formcreate.

Thanks for the input guys.

Thanks, Alex.

Stuart
0
 
Stuart_JohnsonAuthor Commented:
Sorry for the delay in getting back to this question.  I've been away.

Thanks again, Alex.

Stu.
0
 
Wim ten BrinkSelf-employed developerCommented:
Don't worry about the delay. Thanks for the points. :-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now