问题遇到的现象和发生背景
我在Delphi编程的时候,遇到了一个很严重的问题,如果我尝试使用别的方式,可能会有大不妥。
我的程序需要获取【默认】窗口颜色,在窗口刚刚创建的时候,左边属性栏中的Color属性是【clBtnFace】,然后我做了一个可以改变窗口颜色的程序。由于是通过RGB的,然后我还想弄个还原操作,也就是使背景颜色变回原值,惊讶的我发现这个clBtnFace变量我无法获取其的RGB值!
我的RGB都像配置文件一样保存在本地目录,如果有人能够告诉我其RGB的值,那我会不胜感激!或者能否告诉一下该如何操作才能达到获取RGB值呢?
我看网上有很多别的代码可以参考,首先是这个:
https://zhidao.baidu.com/question/689487719057087004.html
然后是这个:
https://www.likecs.com/show-307422273.html
这些几乎输出的都是【15, 0, 0】
但是用足想都知道这不可能是15,0,0的啊!所以我该如何获取clBtnFace的真实RGB值?
问题相关代码,请勿粘贴截图
我找了找相关的代码,发现了以下:
type
TColorRef = UInt32;
PColor = ^TColor;
TColor = -$7(省略7个F)-1..$7(省略7个F); //这里自然是TColor的范围啦
{$IF NOT DEFINED(CLR)}
{$NODEFINE TColor}
{$OBJTYPENAME TColor 'NTColor'}
(*$HPPEMIT OPENNAMESPACE*)
(*$HPPEMIT ' enum DECLSPEC_DENUM TColor : int {clMin=-0x7(省略7个f)-1, clMax=0x7(省略7个f)};'*)
(*$HPPEMIT CLOSENAMESPACE*)
{$ENDIF}
PColorRec = ^TColorRec;
TColorRec = record
const
SystemColor = $(省略2个F)000000;
// System Colors (Windows only)
cSCROLLBAR = 0;
cBACKGROUND = 1;
cACTIVECAPTION = 2;
cINACTIVECAPTION = 3;
cMENU = 4;
cWINDOW = 5;
cWINDOWFRAME = 6;
cMENUTEXT = 7;
cWINDOWTEXT = 8;
cCAPTIONTEXT = 9;
cACTIVEBORDER = 10;
cINACTIVEBORDER = 11;
cAPPWORKSPACE = 12;
cHIGHLIGHT = 13;
cHIGHLIGHTTEXT = 14;
cBTNFACE = 15; //然后这个是数值
cBTNSHADOW = $10;
cGRAYTEXT = 17;
cBTNTEXT = 18;
cINACTIVECAPTIONTEXT = 19;
cBTNHIGHLIGHT = 20;
c3DDKSHADOW = 21;
c3DLIGHT = 22;
cINFOTEXT = 23;
cINFOBK = 24;
cHOTLIGHT = 26;
cGRADIENTACTIVECAPTION = 27;
cGRADIENTINACTIVECAPTION = 28;
cMENUHILIGHT = 29;
cMENUBAR = 30;
cENDCOLORS = cMENUBAR;
cDESKTOP = cBACKGROUND;
c3DFACE = cBTNFACE;
c3DSHADOW = cBTNSHADOW;
c3DHIGHLIGHT = cBTNHIGHLIGHT;
c3DHILIGHT = cBTNHIGHLIGHT;
cBTNHILIGHT = cBTNHIGHLIGHT;
SysScrollBar = TColor(SystemColor or cSCROLLBAR);
SysBackground = TColor(SystemColor or cBACKGROUND);
SysActiveCaption = TColor(SystemColor or cACTIVECAPTION);
SysInactiveCaption = TColor(SystemColor or cINACTIVECAPTION);
SysMenu = TColor(SystemColor or cMENU);
SysWindow = TColor(SystemColor or cWINDOW);
SysWindowFrame = TColor(SystemColor or cWINDOWFRAME);
SysMenuText = TColor(SystemColor or cMENUTEXT);
SysWindowText = TColor(SystemColor or cWINDOWTEXT);
SysCaptionText = TColor(SystemColor or cCAPTIONTEXT);
SysActiveBorder = TColor(SystemColor or cACTIVEBORDER);
SysInactiveBorder = TColor(SystemColor or cINACTIVEBORDER);
SysAppWorkSpace = TColor(SystemColor or cAPPWORKSPACE);
SysHighlight = TColor(SystemColor or cHIGHLIGHT);
SysHighlightText = TColor(SystemColor or cHIGHLIGHTTEXT);
SysBtnFace = TColor(SystemColor or cBTNFACE); //这里是找到后的代码
SysBtnShadow = TColor(SystemColor or cBTNSHADOW);
SysGrayText = TColor(SystemColor or cGRAYTEXT);
SysBtnText = TColor(SystemColor or cBTNTEXT);
SysInactiveCaptionText = TColor(SystemColor or cINACTIVECAPTIONTEXT);
SysBtnHighlight = TColor(SystemColor or cBTNHIGHLIGHT);
Sys3DDkShadow = TColor(SystemColor or c3DDKSHADOW);
Sys3DLight = TColor(SystemColor or c3DLIGHT);
SysInfoText = TColor(SystemColor or cINFOTEXT);
SysInfoBk = TColor(SystemColor or cINFOBK);
SysHotLight = TColor(SystemColor or cHOTLIGHT);
SysGradientActiveCaption = TColor(SystemColor or cGRADIENTACTIVECAPTION);
SysGradientInactiveCaption = TColor(SystemColor or cGRADIENTINACTIVECAPTION);
SysMenuHighlight = TColor(SystemColor or cMENUHILIGHT);
SysMenuBar = TColor(SystemColor or cMENUBAR);
运行结果及报错内容
没有,这是技术性问题
我的解答思路和尝试过的方法
我尝试着用进制转换的问题,找到clBtnFace的数值15在-$7(省略7个F)-1~7(省略7个F)范围内的所有有关的关联性,但我失败了。
我想要达到的结果
成功获取RGB值