Help Center

CGpPen.GetPenTypemethod

Gets the type currently set for this **Pen** object.

GraphicsmethodCGpPen.incdocumented

Syntax

FUNCTION GetPenType () AS PenType

Return value

This method returns an element of the PenType enumeration that indicates the style of pen currently set for this Pen object.

Description

Gets the type currently set for this Pen object.

Example

' ======================================================================================== ' 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. ' ======================================================================================== SUB Example_GetPenType (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi

' // Create a HatchBrush object. DIM hatchBrush AS CGpHatchBrush = CGpHatchBrush(HatchStyleVertical, ARGB_RED, ARGB_BLUE)

' // Create a pen based on a hatch brush, and use that pen to draw a line. DIM pen AS CgpPen = CgpPen(@hatchBrush, 15) graphics.DrawLine(@pen, 20, 20, 200, 100)

' // Obtain information about the pen. DIM nPenType AS PenType = pen.GetPenType

IF nPenType = PenTypeHatchFill THEN

' // The pen will draw with a hatch pattern.
  PRINT "Pen type", nPenType

END IF

END SUB ' ========================================================================================

Reference

  • Include file CGpPen.inc
  • Defined in AfxNova/CGpPen.inc:297
  • Documented in Graphics/GdiPlus Classes/CGpPen Class.md
  • Topic: CGpPen Class