Converting Inno Setup WizardForm.Color to RGB
If I try this:
[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;
 I get: red:15 green:0 blue:0  
 But the result should be: 240 240 240 (grey)  
What is wrong?
 I need to get the proper TColor and convert it to RGB color code.  
 When the first byte is $FF , the last byte is an index in a system color palette.  
 You can get RGB of the system color using GetSysColor function.  
function GetSysColor(nIndex: Integer): DWORD;
  external 'GetSysColor@User32.dll stdcall';
function ColorToRGB(Color: TColor): Cardinal;
begin
  if Color < 0 then
    Result := GetSysColor(Color and $000000FF) else
    Result := Color;
end;
 The ColorToRGB code is copied from Delphi VCL (Vcl.Graphics unit).  
上一篇: 十六进制颜色代码
