Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Pen.GetColor method

Applies to: desktop apps only

The Pen::GetColor method gets the color currently set for this Pen object.

Syntax

Status GetColor(
  [out]  Color *color
);

Parameters

color [out]

Type: Color*

Pointer to a Color object that receives the color of this Pen object.

Return value

Type:

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Examples

The following example creates a Pen object and draws a line. The code then gets the color of the pen and creates a Brush object based on that color. Finally, the code uses the Brush object to fill a rectangle.


VOID Example_GetColor(HDC hdc
{
   Graphics graphics(hdc);
   
   // Create a pen, and use it to draw a line.

   Pen pen(Color(255, 200, 150, 100), 5);
   graphics.DrawLine(&pen, 0, 0, 200, 100);

   // Get the pen's color, and use that color to create a brush.
   Color color;
   pen.GetColor(&color);
   SolidBrush solidBrush(color);

   // Use the brush to fill a rectangle.
   graphics.FillRectangle(&solidBrush, 0, 100, 200, 100);
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdipluspen.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Pen
Color
Pen::SetColor
Filling a Shape with a Solid Color

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

Show:
© 2014 Microsoft