TAdvMenu Glyphs are always drawn in black

Hi Folks,
in TMS AdvMenu (Version 2.6.5.) the glyphs for submenu etc are always drawn in black. This is fine for a light menu background, but makes the glyphs nearly invisible on a dark background.
I tried to replace the glyphs at runtime and at design time, but neither of them worked.
How can I swap the glyphs at run time? I want my application to be able to switch between dark/light designs and to use the menu font color also for the glyphs.

Cheers
L?bbe

Do you use .BMP glyphs with the transparency color set as bottom-left pixel in the BMP?

Thanks for the hint. I thought so. I tried Images
- generated from SVG at run time and loaded from an imagelist via Imagelist.GetBitmap()
- the original glyphs re-colored using paint.net and loaded at design time

I'll check for the transparency.

Hi Bruno,
after a month I finally found time to get back to the subject. There must be something wrong with the drawing routine, because when I added a new glyph for the submenu triangle to the AdvMenuStyler at design time, two glyphs were drawn at slightly different locations.

I solved the problem in the following way.
  • Step 1
    Delete *all* three glyphs from the AdvMenuStyler assigned to the menu at design time.
    After this, at run time, the checkmark glyph properly uses the font color of the menu, but the submenu triangle stays black.
  • Step 2
    find the place in where the submenu is drawn in AdvMenus.pas. (procedure DrawSubmenuTriangle;)
  • Step 3
    Replace the line:
    ACanvas.Font.Color := TriangleColor; with
    Canvas.Font.Color := clBtnText; as it is done in procedure DrawCheckMark just above. The Todo comment in DrawCheckmark indicates that the person who wrote this code didn't know why this was necessary.
  • Step 4
    Delete the definition of TriangleColor = clBlack in AdvMenus.pas
When I now change between dark and light design, the menu glyphs are drawn in clBtnText and are well visible in both cases.
That solves the problem for me, but I didn't investigate what is wrong when glyphs are assigned at design time or run time. It looks like the LoadBitmap() calls in TMenuGlyphs.UpdateResources() are doing the right thing.

Cheers
L?bbe

Thanks for this extra information.
This is helpful to understand and address the issue.
We have now improved the code to detect the use of VCL styles and when this is the case, the triangle is drawn in color clBtnText; This improvement will be included in the next update.

Hi Folks,
I have downloaded and tested TMS components v8.9.0.0 and I think that your fix for the menu glyph is just the wrong way round.

In AdvMenus.pas -> procedure DrawSubmenuTriangle, the line:

      {$IFDEF DELPHIXE2_LVL}
      LStyle := StyleServices;
      if LStyle.Enabled and (LStyle.Name <> 'Windows') then
        ACanvas.Font.Color := TriangleColor
      else
        ACanvas.Font.Color := clBtnText;
      {$ELSE}
      ACanvas.Font.Color := TriangleColor;
      {$ENDIF}

should be:

      {$IFDEF DELPHIXE2_LVL}
      LStyle := StyleServices;
      if LStyle.Enabled and (LStyle.Name = 'Windows') then
        ACanvas.Font.Color := TriangleColor
      else
        ACanvas.Font.Color := clBtnText;
      {$ELSE}
      ACanvas.Font.Color := TriangleColor;
      {$ENDIF}

TriangleColor is basically a constant set to clBlack, so it's ok to use clBlack in default windows style, but it's wrong for any other case, especially for dark styles.

You're correct about this oversight. 
We'll have this fixed for the next scheduled update.

I wonder if this could be simplified to just:

      {$IFDEF DELPHIXE2_LVL}
      ACanvas.Font.Color := clBtnText;
      {$ELSE}
      ACanvas.Font.Color := TriangleColor;
      {$ENDIF}

The If condition as is right now doesn't really make sense to me.

We'll check if there aren't any corner cases requiring this and when not, simplify.

Another small thing. The lines:

  {$IFDEF DELPHIXE2_LVL}
  LStyle: TCustomStyleServices;
  {$ENDIF}

are not needed anymore.

We can confirm this was already cleaned up internally.