Converting Inno Setup WizardForm.Color to RGB
如果我尝试这样做:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [Setup] AppName=MyApp AppVerName=MyApp DefaultDirName={pf}\\MyApp DefaultGroupName=MyApp OutputDir=. [Code] function ColorToRGBstring(Color: TColor): string; var R,G,B : Integer; begin R := Color and $ff; G := (Color and $ff00) shr 8; B := (Color and $ff0000) shr 16; result := 'red:' + inttostr(r) + ' green:' + inttostr(g) + ' blue:' + inttostr(b); end; procedure InitializeWizard(); begin MsgBox(ColorToRGBstring(WizardForm.Color),mbConfirmation, MB_OK); end; |
我得到:红色:15绿色:0蓝色:0
但结果应为:240 240 240(灰色)
怎么了?
我需要获取正确的
当第一个字节为
您可以使用
1 2 3 4 5 6 7 8 9 | function GetSysColor(nIndex: Integer): DWORD; external '[email protected] stdcall'; function ColorToRGB(Color: TColor): Cardinal; begin if Color < 0 then Result := GetSysColor(Color and $000000FF) else Result := Color; end; |