Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>createpen()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
CreatePen()
Create a pen with a specified style, width and colour
------------------------------------------------------------------------------

Syntax
CreatePen( <nPenStyle>, <nWidth>, <nColour> )   -->   hPen

Arguments
<nPenStyle> is one of the PS_* styles (defined in WINDOWS.CH).

<nWidth> is the thickness of the pen in logical units.  (But
zero is taken to mean one pixel.)

<nColour> is the colour to use for the pen.  Use one of the
pre-defined colours (COLOR_* in WINDOWS.CH), or specify your
own using the RGB() macro.

Returns
If successful, a handle to the pen is returned (a non-zero
numeric), otherwise  zero is returned.

Description
The pen is created and a handle returned to the application.
To use the pen, use SelectObject() to select it, then use the
Windows drawing functions such as Ellipse() and Rectangle().
The borders of these shapes are drawn with the currently
selected pen.  Finally, you can free the resources associated
with the pen using DeleteObject(), BUT don't call
DeleteObject() until you have selected a different object or
released the device context.

Example
// Draw a red box
     . . .
hRedPen = CreatePen( PS_SOLID, 5, RGB( 255, 0, 0 ) )
hOldPen = SelectObject( hDC, hRedPen )
Rectangle( hDC, 100, 100, 50, 50 )
SelectObject( hDC, hOldPen )
DeleteObject( hRedPen )
     . . .


See Also: DeleteObject() GetStockObject() SelectObject()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson