Article View: comp.os.ms-windows.programmer.misc
Article #2291DPtoLP question
From: Andy Deitsch
Date: Sun, 24 Jan 1993 01:10
Date: Sun, 24 Jan 1993 01:10
51 lines
2149 bytes
2149 bytes
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:
SetMapMode(hDC, MM_LOENGLISH);
GetClientRect(hDC, &rect);
POINT PointsArray[2];
PointsArray[0].x = rect.left;
PointsArray[0].y = rect.top;
PointsArray[1].x = rect.right;
PointsArray[1].y = rect.bottom;
DPtoLP(hDC, PointsArray, 2);
const int space = 20;
for (int x = PointsArray[0].x * space;
x < PointsArray[1].x * space; x += space)
{
MoveTo(hDC, x, PointsArray[0].y;
LineTo(hDC, x, PointsArray[1].y;
}
for (int y = PointsArray[0].y * space;
y < PointsArray[1].y * space; y += space)
{
MoveTo(hDC, PointsArray[0].x, y);
LineTo(hDC, PointsArray[1].x, y);
}
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
Technical Details
Message-ID:
<1993Jan24.011013.6436@crd.ge.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!rpi!crdgw1!rdsunx.crd.ge.com!sol.crd.ge.com!deitschShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!rpi!crdgw1!rdsunx.crd.ge.com!sol.crd.ge.com!deitsch From: deitsch@sol.crd.ge.com (Andy Deitsch) Newsgroups: comp.os.ms-windows.programmer.misc Subject: DPtoLP question Message-ID: <1993Jan24.011013.6436@crd.ge.com> Date: 24 Jan 93 01:10:13 GMT Sender: deitsch@alkaid (Andy Deitsch) Reply-To: deitsch@sol.crd.ge.com Organization: GE Research & Development Lines: 51 Nntp-Posting-Host: alkaid.crd.ge.com