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

3D 項目的系統定義表面色彩。

ButtonHighlight 169

系統定義的色彩,其為 3D 項目的反白色彩。 這個色彩會套用至面對光源的 3D 項目部分。

ButtonShadow 170

系統定義的色彩,其為 3D 項目的陰影色彩。 這個色彩會套用至背對光源的 3D 項目部分。

CadetBlue 41

系統定義的色彩。

Chartreuse 42

系統定義的色彩。

Chocolate 43

系統定義的色彩。

Control 5

3D 項目的系統定義表面色彩。

ControlDark 6

3D 項目的系統定義陰影色彩。 陰影色彩會套用至背對光源的 3D 項目部分。

ControlDarkDark 7

系統定義的色彩,其為 3D 項目的深色陰影色彩。 深色陰影色彩會套用至色彩最深的 3D 項目部分。

ControlLight 8

系統定義的色彩,其為 3D 項目的淺色色彩。 淺色色彩會套用至面對光源的 3D 項目部分。

ControlLightLight 9

3D 項目的系統定義反白色彩。 反白色彩會套用至色彩最亮的 3D 項目部分。

ControlText 10

3D 項目中文字的系統定義色彩。

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

暗灰色之 (Dimmed) 文字的系統定義色彩。 清單中停用的項目會以暗灰色的文字來顯示。

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

視窗工作區 (Client Area) 中背景的系統定義色彩。

WindowFrame 25

視窗框架的系統定義色彩。

WindowText 26

視窗工作區中文字的系統定義色彩。

Yellow 166

系統定義的色彩。

YellowGreen 167

系統定義的色彩。

範例

下列程式碼範例示範如何使用 KnownColor 列舉來列印其所有值的名稱和色彩。 此範例的設計目的是要與Windows Forms搭配使用。 建立表單,並將下列程式碼貼到其中。 DisplayKnownColors在表單的事件 Paint 處理方法中呼叫 方法,傳遞 ePaintEventArgs

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

適用於