Pen Class Reference

Class for control of a pens lifetime. More...

List of all members.

Public Member Functions

CanvasgetCanvas ()
 Returns the Canvas the pen belongs to.
HPEN getPenHandle ()
 Returns the Handle to the pen.
 Pen (Canvas &canvas, COLORREF color, int width=0)
 Constructor taking a Canvas, a COLORREF, and optionally a width.
 ~Pen ()
 Automatically resets the pen back to the former pen and frees the given pen.


Detailed Description

Class for control of a pens lifetime.

Constructor takes a COLORREF which can be obtained by using e.g. the RGB macro.
Class ensures that when finished with your pen your pen is released and the former one is reactivated.
Automatically resets back to the former used pen when object is destroyed.
The hdc parameter to the Constructor is the Device Context you wish to create the pen in.
Related classes


Constructor & Destructor Documentation

Pen ( Canvas canvas,
COLORREF  color,
int  width = 0 
)

Constructor taking a Canvas, a COLORREF, and optionally a width.

Build a COLORREF argument with windows.h's RGB( red, green, blue ). The optional width is the width in pixels of the line drawn by the pen.

~Pen (  ) 

Automatically resets the pen back to the former pen and frees the given pen.

Freeing the current pen and resetting back to the former pen. Note that the Pen object cannot have a longer lifetime than the Canvas it belongs to (given to the Constructor) since this will cause undefined behaviour.


Member Function Documentation

Canvas & getCanvas (  ) 

Returns the Canvas the pen belongs to.

Normally this would be the same as the "parent" object used to construct the Pen

HPEN getPenHandle (  ) 

Returns the Handle to the pen.

Returns the Handle to the pen

Back to SmartWin website
SourceForge.net Logo