65.9K
CodeProject is changing. Read more.
Home

Creating a True Dotted Pen

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.05/5 (18 votes)

Jun 24, 2004

viewsIcon

59517

A fix for creating pens using PS_DOT.

Introduction

I found that creating a pen using PS_DOT ...

COLORREF c_colorGridLine = RGB(190,190,190);
CPen penDotted(PS_DOT, 0, c_colorGridLine);

...really looked more like a dash. In my application, I wanted to draw very light weight grid lines. I found the following works very nicely, and hope you may find it useful as well:

    LOGBRUSH LogBrush;

    LogBrush.lbColor = c_colorGridLine;

    LogBrush.lbStyle = PS_SOLID;

    penDotted.CreatePen( PS_COSMETIC | PS_ALTERNATE , 1, &LogBrush, 0, NULL );

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.