hiworld 2008-5-4 19:35
Delphi的system color to 普通color 怎么做
Delphi的system color to 普通color
例如 clBtnface 到 真实的RGB
有没有正规的函数
我现在的办法是画到画布上再读回来。
5bxb 2008-5-4 20:06
system color 是什么东西?
经常绘图,也没遇到这个东西!
hiworld 2008-5-4 20:32
system color
32位的高8位,4字节的高字节(其他字节为BGR)
例如 clBtnface代表按纽颜色,具体的RGB由Window设定值决定。
=============================================
TColor is used to specify the color of a Windows-only control. It is used by the Color property of many components and by a number of other properties that specify color values.
The Graphics unit contains definitions of useful constants for TColor. These constants map either directly to the closest matching color in the system palette (for example, clBlue maps to blue) or to the corresponding system screen element color defined in the Color section of the Windows Control panel (for example, clBtnFace maps to the system color for button faces).
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 realized 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.
The following tables lists the color constants from the Graphics unit. The first two columns list the colors that map to the closest matching color in the system palette, while the last two columns list the colors that are defined in the Windows Control panel.
!al(,3,TopicNotFound,main)
Value Meaning Value Meaning
!al(,3,TopicNotFound,main)
clNone White on Windows 9x, Black on NT. clScrollBar Current color for the of scroll bar track.
!al(,3,TopicNotFound,main)
clAqua Aqua clBackground Current background color of the Windows desktop
!al(,3,TopicNotFound,main)
clBlack Black clActiveCaption Current color of the title bar of the active window
!al(,3,TopicNotFound,main)
clBlue Blue clInactiveCaption Current color of the title bar of inactive windows
!al(,3,TopicNotFound,main)
clCream Cream clMenu Current background color of menus
!al(,3,TopicNotFound,main)
clDkGray Dark Gray clWindow Current background color of windows
!al(,3,TopicNotFound,main)
clFuchsia Fuchsia clWindowFrame Current color of window frames
!al(,3,TopicNotFound,main)
clGray Gray clMenuText Current color of text on menus
!al(,3,TopicNotFound,main)
clGreen Green clWindowText Current color of text in windows
!al(,3,TopicNotFound,main)
clLime Lime green clCaptionText Current color of the text on the title bar of the active window
!al(,3,TopicNotFound,main)
clLtGray Light Gray clActiveBorder Current border color of the active window
!al(,3,TopicNotFound,main)
clMaroon Maroon clInactiveBorder Current border color of inactive windows
!al(,3,TopicNotFound,main)
clMedGray Medium Gray clAppWorkSpace Current color of the application workspace
!al(,3,TopicNotFound,main)
clMoneyGreen Mint green clHighlight Current background color of selected text
!al(,3,TopicNotFound,main)
clNavy Navy blue clHightlightText Current color of selected text
!al(,3,TopicNotFound,main)
clOlive Olive green clBtnFace Current color of a button face
!al(,3,TopicNotFound,main)
clPurple Purple clBtnShadow Current color of a shadow cast by a button
!al(,3,TopicNotFound,main)
clRed Red clGrayText Current color of text that is dimmed
!al(,3,TopicNotFound,main)
clSilver Silver clBtnText Current color of text on a button
!al(,3,TopicNotFound,main)
clSkyBlue Sky blue clInactiveCaptionText Current color of the text on the title bar of an inactive window
!al(,3,TopicNotFound,main)
clTeal Teal clBtnHighlight Current color of the highlighting on a button
!al(,3,TopicNotFound,main)
clWhite White cl3DDkShadow Windows 95 or NT 4.0 only: Dark shadow for three-dimensional display elements
!al(,3,TopicNotFound,main)
clYellow Yellow cl3DLight Windows 95 or NT 4.0 only: Light color for three-dimensional display elements (for edges facing the light source)
!al(,3,TopicNotFound,main)
clInfoText Windows 95 or NT 4.0 only: Text color for tool tip controls
!al(,3,TopicNotFound,main)
clInfoBk Windows 95 or NT 4.0 only: Background color for tool tip controls
!al(,3,TopicNotFound,main)
clGradientActiveCaption Windows 98 or Windows 2000: Right side color in the color gradient of an active window's title bar. clActiveCaption specifies the left side color.
!al(,3,TopicNotFound,main)
clGradientInactiveCaption Windows 98 or Windows 2000: Right side color in the color gradient of an inactive window's title bar. clInactiveCaption specifies the left side color.
!al(,3,TopicNotFound,main)
clDefault The default color for the control to which the color is assigned.
[[i] 本帖最后由 hiworld 于 2008-5-4 20:43 编辑 [/i]]
CodeCoolie 2008-5-4 20:35
晕。。。强。。。
unit Graphics[code]function ColorToRGB(Color: TColor): Longint;
begin
if Color < 0 then
Result := GetSysColor(Color and $000000FF)
else
Result := Color;
end;[/code]
hiworld 2008-5-4 21:01
[quote]原帖由 [i]CodeCoolie[/i] 于 2008-5-4 20:35 发表 [url=http://www.cnsw.org/bbs/redirect.php?goto=findpost&pid=353499&ptid=80825][img]http://www.cnsw.org/bbs/images/common/back.gif[/img][/url]
晕。。。强。。。
unit Graphicsfunction ColorToRGB(Color: TColor): Longint;
begin
if Color < 0 then
Result := GetSysColor(Color and $000000FF)
else
Result := Color;
end; [/quote]
多谢,
一直用笨办法,终于明白了,也清楚了SystemColor结构FF0000XX
CodeCoolie 2008-5-4 21:12
[quote]原帖由 [i]hiworld[/i] 于 2008-5-4 21:01 发表 [url=http://www.cnsw.org/bbs/redirect.php?goto=findpost&pid=353516&ptid=80825][img]http://www.cnsw.org/bbs/images/common/back.gif[/img][/url]
多谢,
一直用笨办法,终于明白了,也清楚了SystemColor结构FF0000XX [/quote]
我喜欢Delphi有两个主要原因,一是VCL框架不错,而是提供源代码。。。所以,要好好利用源代码啊,通过看Delphi的源代码,可以学到很多东西。。。