Declare Function CreatePen Lib "gdi32.dll" (ByVal fnPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
CreatePen creates a pen object. The shape of the pen created by the function is always a square having a side length equal to nWidth. After your program is finished using the pen, it must be deleted via the DeleteObject function.
If an error occured, the function returns 0 (Windows NT, 2000: use GetLastError to get the error code). If successful, the function returns a handle to the newly created pen.
None.
Const PS_SOLID = 0
Const PS_DASH = 1
Const PS_DOT = 2
Const PS_DASHDOT = 3
Const PS_DASHDOTDOT = 4
Const PS_NULL = 5
Const PS_INSIDEFRAME = 6
' This code is licensed according to the terms and conditions listed here.
' Draw an ellipse on window Form1 using a one-pixel-wide
' square dashed green pen.
Dim hPen As Long ' handle to the pen created
Dim hOldPen As Long ' handle to Form1's previously selected pen
Dim retval As Long ' return value
' Create the square dashed green pen with a width of zero (always one pixel).
hPen = CreatePen(PS_DASH, 0, RGB(0, 255, 0))
' Select the pen for use by window Form1.
hOldPen = SelectObject(Form1.hDC, hPen)
' Draw an ellipse with bounding rectangle (100,150)-(350,300).
retval = Ellipse(Form1.hDC, 100, 150, 350, 300)
' Select the old pen for use by Form1.
retval = SelectObject(Form1.hDC, hOldPen)
' Delete the pen we created to free up resources.
retval = DeleteObject(hPen)
Go back to the alphabetical Function listing.
Go back to the Reference section index.
Last Modified: October 16, 1999
This page is copyright © 1999 Paul Kuliniewicz.
Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/c/createpen.html