Solved

Changing rule thickness

Posted on 1998-01-19
3
179 Views
Last Modified: 2010-04-10
I'm a VC++ version 5 programmer. I trying to create a 1 point rule with the CPen class. What should I make the nWidth parameter?
0
Comment
Question by:smcinnis011998
  • 3
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1178516
Answer comming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1178517
If you want to work in the default mapping mode, MM_TEXT, then you must determine the number of pixels per point.  A point is approximately 1/72 of an inch.  You can use GetDeviceCaps() to get the number of pixels per inch using LOGPIXELSX or LOGPIXELSY.
then a the pen width should be
(Desired_ointSize)*(pixels_per_inch)/72

Note that if the line is diagonal and the X and Y pixel density is not the same, things get tougher.  However the pixel density is usually the same in both directions.  It can be worked out with a little trig, if necessary.

The other option, however, is to change to a different mapping mode.  In the MM_TWIPS mode a point is 72 units.  (twips are 1/72 of a point, I believe).  Other mapping modes could be used as well.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1178518
I was wrong about the twip size.  A twip is 1/20th of a point.  so a 1 point lines is 20 twips.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question