RRUZ / vcl-styles-utils

Extend and improve the Delphi VCL Styles
https://theroadtodelphi.wordpress.com/
329 stars 115 forks source link

Color out of range #260

Open lchris789 opened 4 years ago

lchris789 commented 4 years ago

With delphi 25th anniversary new theme "Material Patterns Blue" (use Getit to download)

https://community.idera.com/developer-tools/b/blog/posts/new-vcl-windows-theme-material-patterns-blue

I get a range check error inside Vcl.Styles.Hooks.Detour_GetSysColorBrush

LColor := StyleServices.GetSystemColor(TColor(nIndex or Integer($FF000000)));

LBrush := CreateSolidBrush(LColor);

Can you check if you are able to reproduce it ?

StyleServices.GetSystemColor returns Lcolor = -1 and this crashes CreateSolidBrush(LColor)

Thank you very much Chris

lchris789 commented 4 years ago

Addendum : I also get a second range check error with this style when I call TOpenDialog.execute

in unit Vcl.Styles.FontAwesome

Inside procedure TFontAwesome.DrawChar(DC: HDC; const AChar: Char; DestRect: TRect; AFontHeight: Integer; AColor: TColor; Orientation: Integer; ImageAlignment: TImageAlignment);

at line LColor := ColorToRGB(AColor);

rickard67 commented 4 years ago

I downloaded the VCL style and tried to reproduce this using Delphi 10.3.3 running on Windows 10, range checking enabled. But I'm not able to reproduce any of your range check errors.

I'm using this version of VCL styles utils though https://github.com/salvadordf/vcl-styles-utils

/Rickard

rickard67 commented 4 years ago

I tried again building a Win64 application and now I was able to reproduce it.

I think there is something wrong with that theme file. E.g. try creating a new application. Put a button on a form with the following event:

procedure TDialogTestForm.btnShowButtonTextColorClick(Sender: TObject);
var
  LColor: TColor;
begin
  LColor := StyleServices.GetSystemColor(clBtnText);
  ShowMessage('Button text color = ' + IntToStr(LColor));
end;

The returned button text color from the vcl style is -1. Not sure that is a valid color.

/Rickard

lchris789 commented 4 years ago

Hi Rickard, Thank you for testing the issue. I came to the same conclusion, "something is, wrong with the style", but this is worrying because if future styles have the same issue and people experience random crash they will drop using them.

I have to find a way to tell Sarina or someone a Embarcadero.

What I found sofar is that if you open this style in delphi "bitmap style editor" you'll see that clbtntext is black, and if you change it to another color and back to black and save you can get rid of the error.

my guess is that clBtntext value is $FFFFFFFF aka -1 , and maybe other constants have the same issue, but no way to now because the raw value is not visible.

PS: I have the pb in Win32, did not try Win64 yet.