Solved

Changing rule thickness

Posted on 1998-01-19
3
171 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now