Pen::GetAlignment method (gdipluspen.h)

The Pen::GetAlignment method gets the alignment currently set for this Pen object.

Syntax

PenAlignment GetAlignment();

Return value

Type: PenAlignment

This method returns an element of the PenAlignment enumeration that indicates the current alignment setting for this Pen object.

Remarks

The default value of PenAlignment is PenAlignmentCenter.

Examples

The following example creates a Pen object, sets the alignment, draws a line, and then gets the pen alignment settings.

VOID Example_GetAlignment(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a Pen object and set its alignment.
   Pen pen(Color(255, 0, 255, 0), 15);
   pen.SetAlignment(PenAlignmentCenter);

   // Draw a line.
   graphics.DrawLine(&pen, 0, 0, 100, 50);

   // Obtain information about the Pen object.
   PenAlignment penAlignment;
   penAlignment = pen.GetAlignment();

   if(penAlignment == PenAlignmentCenter)
      ;  // The pixels will be centered on the theoretical line.
   else if(penAlignment == PenAlignmentInset)
      ;  // The pixels will lie inside the filled area  of the theoretical line.
}

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

See also

Pen

Pen::SetAlignment

PenAlignment

Pens, Lines, and Rectangles

Setting Pen Width and Alignment