KnownColor 枚举

定义

指定已知的系统颜色。

public enum class KnownColor
public enum KnownColor
type KnownColor = 
Public Enum KnownColor
继承
KnownColor

字段

ActiveBorder 1

活动窗口边框的系统定义颜色。

ActiveCaption 2

活动窗口标题栏背景的系统定义颜色。

ActiveCaptionText 3

活动窗口标题栏中文本的系统定义颜色。

AliceBlue 28

系统定义的颜色。

AntiqueWhite 29

系统定义的颜色。

AppWorkspace 4

应用程序工作区的系统定义颜色。 应用程序工作区是多文档视图中未被文档占据的区域。

Aqua 30

系统定义的颜色。

Aquamarine 31

系统定义的颜色。

Azure 32

系统定义的颜色。

Beige 33

系统定义的颜色。

Bisque 34

系统定义的颜色。

Black 35

系统定义的颜色。

BlanchedAlmond 36

系统定义的颜色。

Blue 37

系统定义的颜色。

BlueViolet 38

系统定义的颜色。

Brown 39

系统定义的颜色。

BurlyWood 40

系统定义的颜色。

ButtonFace 168

三维元素的系统定义表面颜色。

ButtonHighlight 169

系统定义的颜色,是三维元素的高光点颜色。 此颜色应用于三维元素面向光源的部分。

ButtonShadow 170

系统定义的颜色,是三维元素的阴影颜色。 此颜色应用于三维元素背向光源的部分。

CadetBlue 41

系统定义的颜色。

Chartreuse 42

系统定义的颜色。

Chocolate 43

系统定义的颜色。

Control 5

三维元素的系统定义表面颜色。

ControlDark 6

三维元素的系统定义阴影颜色。 阴影颜色应用于三维元素背向光源的部分。

ControlDarkDark 7

系统定义的颜色,是三维元素的暗阴影颜色。 暗阴影颜色应用于三维元素颜色最深的部分。

ControlLight 8

系统定义的颜色,是三维元素的亮色。 亮色应用于三维元素面向光源的部分。

ControlLightLight 9

三维元素的系统定义高光点颜色。 高光点颜色应用于三维元素的颜色最亮的部分。

ControlText 10

三维元素中文本的系统定义颜色。

Coral 44

系统定义的颜色。

CornflowerBlue 45

系统定义的颜色。

Cornsilk 46

系统定义的颜色。

Crimson 47

系统定义的颜色。

Cyan 48

系统定义的颜色。

DarkBlue 49

系统定义的颜色。

DarkCyan 50

系统定义的颜色。

DarkGoldenrod 51

系统定义的颜色。

DarkGray 52

系统定义的颜色。

DarkGreen 53

系统定义的颜色。

DarkKhaki 54

系统定义的颜色。

DarkMagenta 55

系统定义的颜色。

DarkOliveGreen 56

系统定义的颜色。

DarkOrange 57

系统定义的颜色。

DarkOrchid 58

系统定义的颜色。

DarkRed 59

系统定义的颜色。

DarkSalmon 60

系统定义的颜色。

DarkSeaGreen 61

系统定义的颜色。

DarkSlateBlue 62

系统定义的颜色。

DarkSlateGray 63

系统定义的颜色。

DarkTurquoise 64

系统定义的颜色。

DarkViolet 65

系统定义的颜色。

DeepPink 66

系统定义的颜色。

DeepSkyBlue 67

系统定义的颜色。

Desktop 11

桌面的系统定义颜色。

DimGray 68

系统定义的颜色。

DodgerBlue 69

系统定义的颜色。

Firebrick 70

系统定义的颜色。

FloralWhite 71

系统定义的颜色。

ForestGreen 72

系统定义的颜色。

Fuchsia 73

系统定义的颜色。

Gainsboro 74

系统定义的颜色。

GhostWhite 75

系统定义的颜色。

Gold 76

系统定义的颜色。

Goldenrod 77

系统定义的颜色。

GradientActiveCaption 171

活动窗口标题栏的颜色渐变中最亮色的系统定义颜色。

GradientInactiveCaption 172

非活动窗口标题栏的颜色渐变中最亮色的系统定义颜色。

Gray 78

系统定义的颜色。

GrayText 12

浅灰色文本的系统定义颜色。 列表中已禁用的项用浅灰色文本显示。

Green 79

系统定义的颜色。

GreenYellow 80

系统定义的颜色。

Highlight 13

选定项背景的系统定义颜色。 选定项包括选定菜单项和选定文本。

HighlightText 14

选定项文本的系统定义颜色。

Honeydew 81

系统定义的颜色。

HotPink 82

系统定义的颜色。

HotTrack 15

用于指定热跟踪项的系统定义颜色。 单击一个热跟踪项会执行该项。

InactiveBorder 16

非活动窗口边框的系统定义颜色。

InactiveCaption 17

非活动窗口标题栏背景的系统定义颜色。

InactiveCaptionText 18

非活动窗口标题栏文本的系统定义颜色。

IndianRed 83

系统定义的颜色。

Indigo 84

系统定义的颜色。

Info 19

工具提示背景的系统定义颜色。

InfoText 20

工具提示文本的系统定义颜色。

Ivory 85

系统定义的颜色。

Khaki 86

系统定义的颜色。

Lavender 87

系统定义的颜色。

LavenderBlush 88

系统定义的颜色。

LawnGreen 89

系统定义的颜色。

LemonChiffon 90

系统定义的颜色。

LightBlue 91

系统定义的颜色。

LightCoral 92

系统定义的颜色。

LightCyan 93

系统定义的颜色。

LightGoldenrodYellow 94

系统定义的颜色。

LightGray 95

系统定义的颜色。

LightGreen 96

系统定义的颜色。

LightPink 97

系统定义的颜色。

LightSalmon 98

系统定义的颜色。

LightSeaGreen 99

系统定义的颜色。

LightSkyBlue 100

系统定义的颜色。

LightSlateGray 101

系统定义的颜色。

LightSteelBlue 102

系统定义的颜色。

LightYellow 103

系统定义的颜色。

Lime 104

系统定义的颜色。

LimeGreen 105

系统定义的颜色。

Linen 106

系统定义的颜色。

Magenta 107

系统定义的颜色。

Maroon 108

系统定义的颜色。

MediumAquamarine 109

系统定义的颜色。

MediumBlue 110

系统定义的颜色。

MediumOrchid 111

系统定义的颜色。

MediumPurple 112

系统定义的颜色。

MediumSeaGreen 113

系统定义的颜色。

MediumSlateBlue 114

系统定义的颜色。

MediumSpringGreen 115

系统定义的颜色。

MediumTurquoise 116

系统定义的颜色。

MediumVioletRed 117

系统定义的颜色。

Menu 21

菜单背景的系统定义颜色。

MenuBar 173

菜单栏背景的系统定义颜色。

MenuHighlight 174

当出现的是展开菜单时,用于突出显示菜单项的系统定义颜色。

MenuText 22

菜单文本的系统定义颜色。

MidnightBlue 118

系统定义的颜色。

MintCream 119

系统定义的颜色。

MistyRose 120

系统定义的颜色。

Moccasin 121

系统定义的颜色。

NavajoWhite 122

系统定义的颜色。

Navy 123

系统定义的颜色。

OldLace 124

系统定义的颜色。

Olive 125

系统定义的颜色。

OliveDrab 126

系统定义的颜色。

Orange 127

系统定义的颜色。

OrangeRed 128

系统定义的颜色。

Orchid 129

系统定义的颜色。

PaleGoldenrod 130

系统定义的颜色。

PaleGreen 131

系统定义的颜色。

PaleTurquoise 132

系统定义的颜色。

PaleVioletRed 133

系统定义的颜色。

PapayaWhip 134

系统定义的颜色。

PeachPuff 135

系统定义的颜色。

Peru 136

系统定义的颜色。

Pink 137

系统定义的颜色。

Plum 138

系统定义的颜色。

PowderBlue 139

系统定义的颜色。

Purple 140

系统定义的颜色。

RebeccaPurple 175

表示 ARGB 值 #663399的系统定义颜色。

Red 141

系统定义的颜色。

RosyBrown 142

系统定义的颜色。

RoyalBlue 143

系统定义的颜色。

SaddleBrown 144

系统定义的颜色。

Salmon 145

系统定义的颜色。

SandyBrown 146

系统定义的颜色。

ScrollBar 23

滚动条背景的系统定义颜色。

SeaGreen 147

系统定义的颜色。

SeaShell 148

系统定义的颜色。

Sienna 149

系统定义的颜色。

Silver 150

系统定义的颜色。

SkyBlue 151

系统定义的颜色。

SlateBlue 152

系统定义的颜色。

SlateGray 153

系统定义的颜色。

Snow 154

系统定义的颜色。

SpringGreen 155

系统定义的颜色。

SteelBlue 156

系统定义的颜色。

Tan 157

系统定义的颜色。

Teal 158

系统定义的颜色。

Thistle 159

系统定义的颜色。

Tomato 160

系统定义的颜色。

Transparent 27

系统定义的颜色。

Turquoise 161

系统定义的颜色。

Violet 162

系统定义的颜色。

Wheat 163

系统定义的颜色。

White 164

系统定义的颜色。

WhiteSmoke 165

系统定义的颜色。

Window 24

窗口的工作区中背景的系统定义颜色。

WindowFrame 25

窗口框架的系统定义颜色。

WindowText 26

窗口的工作区中文本的系统定义颜色。

Yellow 166

系统定义的颜色。

YellowGreen 167

系统定义的颜色。

示例

下面的代码示例演示如何使用 KnownColor 枚举输出其所有值的名称和颜色。 此示例旨在与Windows 窗体一起使用。 创建窗体并将以下代码粘贴到其中。 DisplayKnownColors在窗体Paint的事件处理方法中调用该方法,并作为传递e方式PaintEventArgs

private:
   void DisplayKnownColors( PaintEventArgs^ e )
   {
      this->Size = System::Drawing::Size( 650, 550 );

      // Get all the values from the KnownColor enumeration.
      System::Array^ colorsArray = Enum::GetValues( KnownColor::typeid );
      array<KnownColor>^allColors = gcnew array<KnownColor>(colorsArray->Length);
      Array::Copy( colorsArray, allColors, colorsArray->Length );

      // Loop through printing out the values' names in the colors 
      // they represent.
      float y = 0;
      float x = 10.0F;
      for ( int i = 0; i < allColors->Length; i++ )
      {
         // If x is a multiple of 30, start a new column.
         if ( i > 0 && i % 30 == 0 )
         {
            x += 105.0F;
            y = 15.0F;
         }
         else
         {
            // Otherwise, increment y by 15.
            y += 15.0F;
         }

         // Create a custom brush from the color and use it to draw
         // the brush's name.
         SolidBrush^ aBrush = gcnew SolidBrush( Color::FromName( allColors[ i ].ToString() ) );
         e->Graphics->DrawString( allColors[ i ].ToString(), this->Font, aBrush, x, y );

         // Dispose of the custom brush.
         delete aBrush;
      }
   }
private void DisplayKnownColors(PaintEventArgs e)
{
    this.Size = new Size(650, 550);
    
    // Get all the values from the KnownColor enumeration.
    System.Array colorsArray = Enum.GetValues(typeof(KnownColor));
    KnownColor[] allColors = new KnownColor[colorsArray.Length];

    Array.Copy(colorsArray, allColors, colorsArray.Length);

    // Loop through printing out the values' names in the colors 
    // they represent.
    float y = 0;
    float x = 10.0F;

    for(int i = 0; i < allColors.Length; i++)
    {

        // If x is a multiple of 30, start a new column.
        if (i > 0 && i % 30 == 0)
        {
            x += 105.0F;
            y = 15.0F;
        }
        else
        {
            // Otherwise, increment y by 15.
            y += 15.0F;
        }

        // Create a custom brush from the color and use it to draw
        // the brush's name.
        SolidBrush aBrush = 
            new SolidBrush(Color.FromName(allColors[i].ToString()));
        e.Graphics.DrawString(allColors[i].ToString(), 
            this.Font, aBrush, x, y);

        // Dispose of the custom brush.
        aBrush.Dispose();
    }
}
Private Sub DisplayKnownColors(ByVal e As PaintEventArgs)
    Me.Size = New Size(650, 550)
    Dim i As Integer

    ' Get all the values from the KnownColor enumeration.
    Dim colorsArray As System.Array = _
        [Enum].GetValues(GetType(KnownColor))
    Dim allColors(colorsArray.length) As KnownColor

    Array.Copy(colorsArray, allColors, colorsArray.Length)

    ' Loop through printing out the value's name in the colors 
    ' they represent.
    Dim y As Single
    Dim x As Single = 10.0F

    For i = 0 To allColors.Length - 1

        ' If x is a multiple of 30, start a new column.
        If (i > 0 And i Mod 30 = 0) Then
            x += 105.0F
            y = 15.0F
        Else
            ' Otherwise increment y by 15.
            y += 15.0F
        End If

        ' Create a custom brush from the color and use it to draw
        ' the brush's name.
        Dim aBrush As New SolidBrush(Color.FromName( _
            allColors(i).ToString()))
        e.Graphics.DrawString(allColors(i).ToString(), _
            Me.Font, aBrush, x, y)

        ' Dispose of the custom brush.
        aBrush.Dispose()
    Next

End Sub

适用于