vcl-styles-utils icon indicating copy to clipboard operation
vcl-styles-utils copied to clipboard

Syscolors being lost using VCL Style Utils

Open willisnou opened this issue 6 months ago • 0 comments

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.

willisnou avatar Jul 10 '25 11:07 willisnou