Extract icon from VCL style and use as menu icon, not working for all styles

226 views Asked by At

I need to replace a main menu icon (specifically, the help icon) with an icon from the current VCL style being used (our application shows this icon on the right hand side of the menu-bar, and it looks odd to use an icon that is pulled from a resource file which doesn't match the active theme).

I can't find a way of extracting an image from the style and then using that as the menu icon. Has anyone done this?


Update: This isn't drawing the styled icon (as per previous question), but getting the main menu to have the themed icon (rather than an unthemed resource or a standard icon).


Update2: If I get the style element and draw that into a TBitmap, it works when the Style is 'Windows', but not for other themes.

  // Need to populate the image from the theme
  LDetails := StyleServices.GetElementDetails(twHelpButtonNormal);

  bitmap := Tbitmap.Create;
  bitmap.Height := 16;
  bitmap.width := 16;
  StyleServices.DrawElement(bitmap.Canvas.Handle, LDetails, bitmap.Canvas.ClipRect);

  HelpMenuItem.Bitmap := bitmap;

The element is there, but it has no icon.

Default Windows style With a style

0

There are 0 answers