Click here to Skip to main content
15,886,770 members
Articles / Multimedia / GDI

Creating a True Dotted Pen

Rate me:
Please Sign up or sign in to vote.
3.05/5 (18 votes)
23 Jun 2004 58.5K   10   7
A fix for creating pens using PS_DOT.

Introduction

I found that creating a pen using PS_DOT ...

C++
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:

C++
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.


Written By
Web Developer
United States United States
Industrial strength automation programmer;

Comments and Discussions

 
GeneralMy vote of 5 Pin
Mike Angel Martin11-Sep-18 4:48
Mike Angel Martin11-Sep-18 4:48 
GeneralMy vote of 5 Pin
nv317-Jul-12 5:46
nv317-Jul-12 5:46 
GeneralAnother suggestion Pin
Franz Brunner27-Sep-04 4:58
Franz Brunner27-Sep-04 4:58 
GeneralRe: Another suggestion Pin
Alexandre GRANVAUD4-Apr-06 4:25
Alexandre GRANVAUD4-Apr-06 4:25 
GeneralIncorrect parameter Pin
Rob Caldecott24-Jun-04 5:40
Rob Caldecott24-Jun-04 5:40 
GeneralPS_ALTERNATE not available on Win9x Pin
Rob Caldecott24-Jun-04 5:36
Rob Caldecott24-Jun-04 5:36 
GeneralRe: PS_ALTERNATE not available on Win9x Pin
MaxHacker24-Jun-04 7:07
MaxHacker24-Jun-04 7:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.