Pen::GetPenType method (gdipluspen.h)
The Pen::GetPenType method gets the type currently set for this Pen object.
Syntax
PenType GetPenType();
Return value
Type: PenType
This method returns an element of the PenType enumeration that indicates the style of pen currently set for this Pen object.
Remarks
A Pen object is created with a default pen type of PenTypeSolidColor, which is an element of the PenType enumeration.
Examples
The following example creates a HatchBrush object and then passes the address of that HatchBrush object to a Pen constructor. The code uses the pen, which has a width of 15, to draw a line. The code calls the Pen::GetPenType method to determine the pen's type, and then checks to see whether the type is PenTypeHatchFill.
VOID Example_GetPenType(HDC hdc)
{
Graphics graphics(hdc);
// Create a HatchBrush object.
HatchBrush hatchBrush(
HatchStyleVertical,
Color(255, 255, 0, 0),
Color(255, 0, 0, 255));
// Create a pen based on a hatch brush, and use that
// pen to draw a line.
Pen pen(&hatchBrush, 15);
graphics.DrawLine(&pen, 20, 20, 200, 100);
// Obtain information about the pen.
PenType penType = pen.GetPenType();
if(penType == PenTypeHatchFill)
{
// The pen will draw with a hatch pattern.
}
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP, Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | gdipluspen.h (include Gdiplus.h) |
Library | Gdiplus.lib |
DLL | Gdiplus.dll |