Compartilhar via


CPen::CreatePenIndirect

Initializes a pen that has the style, width, and color given in the structure pointed to by lpLogPen.

BOOL CreatePenIndirect( 
   LPLOGPEN lpLogPen  
);

Parameters

  • lpLogPen
    Points to the Windows LOGPEN structure that contains information about the pen.

Return Value

Nonzero if the function is successful; otherwise 0.

Remarks

Pens that have a width greater than 1 pixel should always have either the PS_NULL, PS_SOLID, or PS_INSIDEFRAME style.

If a pen has the PS_INSIDEFRAME style and a color that does not match a color in the logical color table, the pen is drawn with a dithered color. The PS_INSIDEFRAME style is identical to PS_SOLID if the pen width is less than or equal to 1.

Example

LOGPEN logpen;
CPen   cMyPen;

// Get the LOGPEN of an existing pen.
penExisting.GetLogPen(&logpen);

// Change the color to red and the width to 2.
logpen.lopnWidth.x = 2;
logpen.lopnColor = RGB(255, 0, 0);

// Create my pen using the new settings.
cMyPen.CreatePenIndirect(&logpen);

Requirements

Header: afxwin.h

See Also

Reference

CPen Class

Hierarchy Chart

CPen::CreatePen

CPen::CPen