Skip to content

Syscolors being lost using VCL Style Utils #321

@willisnou

Description

@willisnou

Hi! I using Vcl.Styles.Utils.ComCtrls, Vcl.Styles.Ext, Vcl.Styles.Hooks and noticed that some colors just got black instead... the syscolor in question is clMenuHighlight.

With Vcl.Styles.Utils.ComCtrls:
Image

Without Vcl.Styles.Utils.ComCtrls:
Image

Using Delphi 12, tried to debug the problem and got into Detour_GetSysColor of Vcl.Styles.Hooks, then just tried to add another condition:

function Detour_GetSysColor(nIndex: Integer): DWORD; stdcall;
begin
  if not (ExecutingInMainThread) or StyleServices.IsSystemStyle or not (TSysStyleManager.Enabled) then
    Result := Trampoline_user32_GetSysColor(nIndex)
  else if nIndex = COLOR_HOTLIGHT then
    Result := DWORD(StyleServices.GetSystemColor(clHighlight))
  else if nIndex = COLOR_MENUHILIGHT then
    Result:= DWORD(StyleServices.GetSystemColor(clMenulHighlight))
else
    Result := DWORD(StyleServices.GetSystemColor(TColor(nIndex or Integer($FF000000))));
end;

But it seems that in some way the const clMenulHighlight defined in Delphi units was changed to black, the only way was returning the color hex or rgb itself, which isnt usefull as I would have to map every color which take into this problem.

This is a problem or I doing something wrong? Does have a workaround? I found #192, but its pretty old tho.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions