home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / misc / 5308 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  2.0 KB

  1. Path: sparky!uunet!usc!rpi!crdgw1!rdsunx.crd.ge.com!sol.crd.ge.com!deitsch
  2. From: deitsch@sol.crd.ge.com (Andy Deitsch)
  3. Newsgroups: comp.os.ms-windows.programmer.misc
  4. Subject: DPtoLP question
  5. Message-ID: <1993Jan24.011013.6436@crd.ge.com>
  6. Date: 24 Jan 93 01:10:13 GMT
  7. Sender: deitsch@alkaid (Andy Deitsch)
  8. Reply-To: deitsch@sol.crd.ge.com
  9. Organization: GE Research & Development
  10. Lines: 51
  11. Nntp-Posting-Host: alkaid.crd.ge.com
  12.  
  13. I'm trying to do something very simple.  I want to create a grid in
  14. a window.  I'm using the MM_LOENGLISH map mode because I want the
  15. space between grid lines to be the same no matter what the screen 
  16. resolution.  The following is an excerpt from the code:
  17.  
  18.    SetMapMode(hDC, MM_LOENGLISH);
  19.    GetClientRect(hDC, &rect);
  20.  
  21.    POINT PointsArray[2];
  22.  
  23.    PointsArray[0].x = rect.left;
  24.    PointsArray[0].y = rect.top;
  25.    PointsArray[1].x = rect.right;
  26.    PointsArray[1].y = rect.bottom;
  27.  
  28.    DPtoLP(hDC, PointsArray, 2);
  29.  
  30.    const int space = 20;
  31.  
  32.    for (int x = PointsArray[0].x * space; 
  33.          x < PointsArray[1].x * space; x += space)
  34.    {
  35.       MoveTo(hDC, x, PointsArray[0].y;
  36.       LineTo(hDC, x, PointsArray[1].y;
  37.    }
  38.  
  39.  
  40.    for (int y = PointsArray[0].y * space;
  41.          y < PointsArray[1].y * space; y += space)
  42.    {
  43.       MoveTo(hDC, PointsArray[0].x, y);
  44.       LineTo(hDC, PointsArray[1].x, y);
  45.    }
  46.  
  47.  
  48. The first loop works fine, and the vertical lines are drawn correctly.
  49. The problem is that DPtoLP is converting rect.bottom to a negative
  50. number!  This obviously causes the second loop to next execute.  When
  51. I look at rect in the debugger, rect.bottom is a positive number.  Why
  52. is it getting translated to a negative?
  53.  
  54. If I comment out SetMapMode, then the grid is created, but it won't be
  55. the same size on any screen.
  56.  
  57. Any help would be greatly appreciated.
  58.  
  59. -- 
  60. _________________________________________________________________________
  61. Andy Deitsch                             email    : deitsch@crd.ge.com  
  62. GE Corporate Research & Development      phone    : (518) 387-7207   
  63. Schenectday, NY 12301                    dial comm: 833-7207     
  64.