Solved

Changing rule thickness

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

746 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

12 Experts available now in Live!

Get 1:1 Help Now