Unicode Controls & Classes for VB6 - Version 4

clsGpPen Class

Represents a GDIPlus Pen object, automatically releases used resources when the class terminates; a Pen is used to stroke shapes

Enums
Name Description
Events
Name Description
Properties
Name Type Description
Alignment (GpPenAlignment) Gets or sets the Pen alignment
Brush (clsGpBrush) Gets or sets the Pen Brush; instead of using a Color you can create a Pen that uses a complex shape
Color (clsGpColor) Gets or sets the Pen Color (using a class)
CustomEndCap (clsGpCustomLineCap) Gets or sets the Pen Custom Ending cap (shape)
CustomStartCap (clsGpCustomLineCap) Gets or sets the Custom Pen Starting cap (shape)
DashCap (GpDashCap) Gets or sets the Pen dash cap
DashStyle (GpDashStyle) Gets or sets the Pen dash style
EndCap (GpLineCap) Gets or sets the Pen Ending cap (shape)
hPen (Long) Gets or Sets the associated Pen handle from/to this class, this method automatically disposes the previous handle when you assign a new handle
isValid (Boolean) Verify if the current Pen object is valid
LineJoin (GpLineJoin) Gets or sets the Pen line join
RawColor (Long) Gets or sets the Pen Color (using a ARGB value)
StartCap (GpLineCap) Gets or sets the Pen Starting cap (shape)
Width (Single) Gets or sets the Pen width
Methods
Name Type Description
Clone (clsGpPen) Retuns a new instance of the current object
Create1_Color (GpStatus) Create a new Pen using the clsGpColor instance
Create1_RawColor (GpStatus) Create a Pen using the specified ARGB Color
Create2_Brush (GpStatus)
Dispose Release resources used by the Pen object, called automatically when the class terminates
SetLineCap (GpStatus) Sets in one function the Start, End and Line cap
Remarks
Check the Pen object on MSDN.

In this sample we'll draw an Ellipse using a Pen and a Brush and we'll obtain a Picture object
Option Explicit

'
'Draw a ctlUniImage control on a form before trying this sample
'

Dim moHexWrapper As New clsCommonWrapper

Private Sub Form_Load()
'This object contains useful GDI Plus conversion functions
Dim oSes As clsGpSession
Set oSes = moHexWrapper.GetGDIPlusSession()

'Create a new bitmap
Dim oBmp As New clsGpBitmap
oBmp.Create ctlUniImageWL1.ClientWidth, ctlUniImageWL1.ClientHeight, PixelFormat32bppARGB

Dim oGr As New clsGpGraphics

'Create the Pen for drawing the ellipse
Dim oP As New clsGpPen
oP.Create1_RawColor oSes.ColorFromRGB(vbRed, 128)

'Create the brush for filling the ellipse
Dim oBr As New clsGpBrush
oBr.CreateHatchBrush_RawColor HatchStyle50Percent, oSes.ColorFromRGB(vbWhite), oSes.ColorFromRGB(vbYellow)

'Create an instance of the Graphics object that contains drawing functions
Set oGr = oBmp.CreateGraphics(, PixelOffsetModeHighQuality, SmoothingModeAntiAlias)

'Fills the ellipse with the brush
oGr.FillEllipseI oBr, 0, 0, oBmp.GetWidth(), oBmp.GetHeight()

'Draws the ellipse border
oGr.DrawEllipseI oP, 0, 0, oBmp.GetWidth(), oBmp.GetHeight()

'Get a Picture object from our GDIPlus bitmap
Dim oPic As StdPicture
Set oPic = oBmp.Picture(vbWhite)

'Set to our UniImage widget
Set ctlUniImageWL1.Picture = oPic

End Sub

Another sample that uses a clsGpColor class for colors
Option Explicit

'
'Draw a ctlUniImage control on a form
'

Private Sub Form_Load()

'Create a new bitmap
Dim oBmp As New clsGpBitmap
oBmp.Create ctlUniImageWL1.ClientWidth, ctlUniImageWL1.ClientHeight, PixelFormat32bppARGB

Dim oGr As New clsGpGraphics

Dim oColor As New clsGpColor
oColor.CreateFromVBColor (vbRed)

'Create the Pen for drawing the ellipse
Dim oP As New clsGpPen
oP.Create1_Color oColor

Dim oColor1 As New clsGpColor
oColor1.CreateFromVBColor vbRed

Dim oColor2 As New clsGpColor
oColor2.CreateFromVBColor vbYellow

'Create the brush for filling the ellipse
Dim oBr As New clsGpBrush
oBr.CreateHatchBrush_Color HatchStyleCross, oColor1, oColor2

'Create an instance of the Graphics object that contains drawing functions
Set oGr = oBmp.CreateGraphics(, PixelOffsetModeHighQuality, SmoothingModeAntiAlias)

'Fills the ellipse with the brush
oGr.FillEllipseI oBr, 0, 0, oBmp.GetWidth(), oBmp.GetHeight()

'Draws the ellipse border
oGr.DrawEllipseI oP, 0, 0, oBmp.GetWidth(), oBmp.GetHeight()

'Get a Picture object from our GDIPlus bitmap
Dim oPic As StdPicture
Set oPic = oBmp.Picture(vbWhite)

'Set to our UniImage widget
Set ctlUniImageWL1.Picture = oPic

End Sub