How can I draw in REAL millimeters?

I'm trying to display some fairly simple 2-d drawings in part of a dialog box, using VC++6.  They're schematics of objects (different from instance to instance of the dialog) but always about 60 to 120 mm wide, and somewhere around 50 to 100 mm high.
I'd *really* like it to display at exactly the same size it really is, but am not having conspicuous success.
I first tried setting mapping mode to MM_HIMETRIC, and multiplying all the dimensions of the object by 100.  But, for instance, a circle 70 mm in diameter comes out anywhere from 80 to 90 mm on the display.  The actual displayed size changes when I change my screen resolution.

The next thing I tried was to use GetDeviceCaps to find out the width in mm of the display, height in mm; width in pixels, height in lines... then did some math and mapping mode MM_ANISOTROPIC, thusly:

//(m_Canvas, here is the area in which I'm drawing):

int icx = m_Canvas.left+(m_Canvas.right-m_Canvas.left)/2;
int icy =;
dc.SetViewportOrg(icx, icy);

int iScreenWidthMM = dc.GetDeviceCaps(HORZSIZE);
int iScreenHeightMM = dc.GetDeviceCaps(VERTSIZE);
int iScreenWidthPixels = dc.GetDeviceCaps(HORZRES);
int iScreenHeightPixels = dc.GetDeviceCaps(VERTRES);
dc.SetWindowExt(iScreenWidthMM * 100,
               -iScreenHeightMM * 100);

...the sizing is coming out exactly the same as when I was using MM_HIMETRIC.

I'm a newbe to both VC++ and the Windows graphics API (as is most likely obvious).  If anyone would be so kind as to point me at a resource for this, I'd be most appreciative!  I've looked at many Internet sites, and have 3 or 4 "Beginning Visual C++" books by various authors, and none of them address this particular point.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you might get a fair exact length in one particular screen type with certain dot pitch. But if dot pitch is different for another screen, you won't be succesful.
Imagine the circle drawn at a certain resolution on a 14-inch monitor, then imagine unplugging the cable and plugging it into a 21-inch monitor (no change to the circle or the resolution).  See the problem?  The circle will be much larger.  Now imagine that the user presses some buttons on this monitor to increase the scan width and/or height.  There it is again -- the sizing will be wrong.  Or think af a dual-monitor system with one small and one large monitor.  The user drags your window to the smaller monitor... and oops.  

There is no complete solution to this question.  You will need to make a 'best guess' -- using the factors that you are already using -- and then allow the user to  specify a scaling factor.

-- Dan

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I did not have problems using exact metric coordinates on CRT, the correct scaling is done by windows using the device driver of the painting device. Therefore You could get for example the same result on the screen as on the printer.
What I suggest is, try to use a normal window, not a dialog box (SDI Project in MFC) and make Your experiment with the dc of that window (selecting the MM_*METRIC coordinate system should be sufficient) and let us know (sorry, I do not have the possibility to test it right now ).

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

You have to set the coordinates of the window to 'real coordinates'.

The problem is that a dialogbox uses 'dialog coordinates'. So the best way is to make a panel and inside that panel set the coordinate transformation to real coordinates.

You can set up that transformation by doing a Win32 function to set transformation. Forgot the exact name of the function but it is in the Win32 API. Just use the handle to the panel control (each control is also a window and have a window handle). Set the transformation of that window so that the point (1,1) is exactly 1 cm or 20 mm or whatever scale you want to the right (or left) and above (or below) of the origin (0,0). You can set both origin, orientation and scale factors and other parameters for the transformation but I also think there's an enum that can set to 'real coordinates' and then it will set all the parameters right without you having to figure out the coefficients for the transformation matrix yourself.

Also, remember that the coordinates is then different in that window than in any other window, the outer windows will still use the dialog transformation.

Have a look in your monitor properties.  On Win 9x and XP, there is a "Dots per inch" DPI setting.  You'll have to convert it to metric but if you get that right, then you'll get the correct size metrically.
Everyone seems to be ignoring the more direct physical properties of the monitor as well.  Ever used the vertical or horizontal size adjustments in a modern monitor?  All the other things are directly affected...   There is a reason that noone ever really attempts to do this on a monitor.  If you want life-size drawings, use a printer.  That's the only accurate solution.
Kyle AbrahamsSenior .Net DeveloperCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept dan rollins comment as answer

Please leave any comments here within the next seven days.

EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.