关于Delphi 或BCB中的TFont,究竟是如何表示色彩的
关于Delphi 或BCB中的TFont,究竟是怎么表示色彩的?
在帮助文档中,TFont这样定义:
Delphi syntax:
type TColor = -$7FFFFFFF-1..$7FFFFFFF;
并有这样的解释:
If you specify TColor as a specific 4-byte hexadecimal number instead of using the constants defined in the Graphics unit, the low three bytes represent RGB color intensities for blue, green, and red, respectively. The value $00FF0000 (Delphi) or 0x00FF0000 (C++) represents full-intensity, pure blue, $0000FF00 (Delphi) or 0x0000FF00 (C++) is pure green, and $000000FF (Delphi) or 0x000000FF (C++) is pure red. $00000000 (Delphi) or 0x00000000 (C++) is black and $00FFFFFF (Delphi) or 0x00FFFFFF (C++) is white.
If the highest-order byte is zero, the color obtained is the closest matching color in the system palette. If the highest-order byte is one ($01 or 0x01), the color obtained is the closest matching color in the currently active palette. If the highest-order byte is two ($02 or 0x02), the value is matched with the nearest color in the logical palette of the current device context.
上面的第一段是说4个字节的TFont,低三个字节分别存色彩的RGB值,这个好理解,但关于最高字节,我就实在不明白是什么意思,请哪位讲讲?
------解决方案--------------------
高字节表示操作系统预定义的颜色
比如:
按钮的颜色、标题的颜色、窗体的颜色、菜单的颜色等等
这些用户可以在“显示 属性”-> 外观 里设置
clMenu = TColor(COLOR_MENU or $80000000);
clWindow = TColor(COLOR_WINDOW or $80000000);
clWindowFrame = TColor(COLOR_WINDOWFRAME or $80000000);
clMenuText = TColor(COLOR_MENUTEXT or $80000000);
clWindowText = TColor(COLOR_WINDOWTEXT or $80000000);
如果我的菜单设置为红色
那么clMenu其实就是红色
可以通过ColorToRGB()得到 //api GetSysColor
在帮助文档中,TFont这样定义:
Delphi syntax:
type TColor = -$7FFFFFFF-1..$7FFFFFFF;
并有这样的解释:
If you specify TColor as a specific 4-byte hexadecimal number instead of using the constants defined in the Graphics unit, the low three bytes represent RGB color intensities for blue, green, and red, respectively. The value $00FF0000 (Delphi) or 0x00FF0000 (C++) represents full-intensity, pure blue, $0000FF00 (Delphi) or 0x0000FF00 (C++) is pure green, and $000000FF (Delphi) or 0x000000FF (C++) is pure red. $00000000 (Delphi) or 0x00000000 (C++) is black and $00FFFFFF (Delphi) or 0x00FFFFFF (C++) is white.
If the highest-order byte is zero, the color obtained is the closest matching color in the system palette. If the highest-order byte is one ($01 or 0x01), the color obtained is the closest matching color in the currently active palette. If the highest-order byte is two ($02 or 0x02), the value is matched with the nearest color in the logical palette of the current device context.
上面的第一段是说4个字节的TFont,低三个字节分别存色彩的RGB值,这个好理解,但关于最高字节,我就实在不明白是什么意思,请哪位讲讲?
------解决方案--------------------
高字节表示操作系统预定义的颜色
比如:
按钮的颜色、标题的颜色、窗体的颜色、菜单的颜色等等
这些用户可以在“显示 属性”-> 外观 里设置
clMenu = TColor(COLOR_MENU or $80000000);
clWindow = TColor(COLOR_WINDOW or $80000000);
clWindowFrame = TColor(COLOR_WINDOWFRAME or $80000000);
clMenuText = TColor(COLOR_MENUTEXT or $80000000);
clWindowText = TColor(COLOR_WINDOWTEXT or $80000000);
如果我的菜单设置为红色
那么clMenu其实就是红色
可以通过ColorToRGB()得到 //api GetSysColor