Article View: comp.os.ms-windows.programmer.misc
Article #2299Re: DPtoLP question
From: Chris Marriott
Date: Sun, 24 Jan 1993 17:40
Date: Sun, 24 Jan 1993 17:40
52 lines
2805 bytes
2805 bytes
In article <1993Jan24.011013.6436@crd.ge.com> deitsch@sol.crd.ge.com writes:
>I'm trying to do something very simple. I want to create a grid in
>a window. I'm using the MM_LOENGLISH map mode because I want the
>space between grid lines to be the same no matter what the screen
>resolution. The following is an excerpt from the code:
>
> [ source code deleted ]
>
>The first loop works fine, and the vertical lines are drawn correctly.
>The problem is that DPtoLP is converting rect.bottom to a negative
>number! This obviously causes the second loop to next execute. When
>I look at rect in the debugger, rect.bottom is a positive number. Why
>is it getting translated to a negative?
>
>If I comment out SetMapMode, then the grid is created, but it won't be
>the same size on any screen.
>
>Any help would be greatly appreciated.
>
>--
>_________________________________________________________________________
>Andy Deitsch email : deitsch@crd.ge.com
>GE Corporate Research & Development phone : (518) 387-7207
>Schenectday, NY 12301 dial comm: 833-7207
>
It's because the Y-axis in the *device* coordinate system increases
downwards, whereas it increases *upwards* in the MM_LOENGLISH coordinate
system. Because the bottom your rectangle is below the top, it's at a
negative Y-coordinate.
There's a much easier way to do what you want, by the way. Just use
"GetDeviceCaps" to find the resolution of the device (in pixels per inch),
and scale your grid that way. If you do this, you can stay with the MM_TEXT
mapping mode.
eg, if you want lines spaced 1/4 of a logical inch apart, just say:
int space = GetDeviceCaps( hDC, LOGPIXELS)/4;
Best wishes,
Chris
--
--------------------------------------------------------------------------
| Chris Marriott | chris@chrism.demon.co.uk |
| Warrington, UK | BIX: cmarriott |
| | CIX: cmarriott |
| Save the whales. Collect the whole set. | CompuServe: 100113,1140 |
--------------------------------------------------------------------------
Technical Details
Message-ID:
<727897233snz@chrism.demon.co.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!gatech!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!pipex!demon!chrism.demon.co.uk!chrisReferences:
<1993Jan24.011013.6436@crd.ge.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc From: chris@chrism.demon.co.uk (Chris Marriott) Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!gatech!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!pipex!demon!chrism.demon.co.uk!chris Subject: Re: DPtoLP question Distribution: world References: <1993Jan24.011013.6436@crd.ge.com> Organization: None Reply-To: chris@chrism.demon.co.uk X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19) Lines: 52 Date: Sun, 24 Jan 1993 17:40:33 +0000 Message-ID: <727897233snz@chrism.demon.co.uk> Sender: usenet@demon.co.uk