将Inno Setup WizardForm.Color转换为RGB [英] Converting Inno Setup WizardForm.Color to RGB
本文介绍了将Inno Setup WizardForm.Color转换为RGB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我尝试这样做:
[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(灰色)
I get: red:15 green:0 blue:0
But the result should be: 240 240 240 (grey)
怎么了?
我需要获取正确的TColor
并将其转换为RGB颜色代码.
I need to get the proper TColor
and convert it to RGB color code.
推荐答案
当第一个字节为$FF
时,最后一个字节为系统调色板中的索引.
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;
ColorToRGB
代码是从Delphi VCL(Vcl.Graphics单元).
这篇关于将Inno Setup WizardForm.Color转换为RGB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文