home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / misc / 5317 < prev    next >
Encoding:
Text File  |  1993-01-24  |  2.7 KB  |  67 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. From: chris@chrism.demon.co.uk (Chris Marriott)
  3. Path: sparky!uunet!europa.asd.contel.com!gatech!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!pipex!demon!chrism.demon.co.uk!chris
  4. Subject: Re: DPtoLP question 
  5. Distribution: world
  6. References: <1993Jan24.011013.6436@crd.ge.com>
  7. Organization: None
  8. Reply-To: chris@chrism.demon.co.uk
  9. X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
  10. Lines: 52
  11. Date: Sun, 24 Jan 1993 17:40:33 +0000
  12. Message-ID: <727897233snz@chrism.demon.co.uk>
  13. Sender: usenet@demon.co.uk
  14.  
  15. In article <1993Jan24.011013.6436@crd.ge.com> deitsch@sol.crd.ge.com writes:
  16.  
  17. >I'm trying to do something very simple.  I want to create a grid in
  18. >a window.  I'm using the MM_LOENGLISH map mode because I want the
  19. >space between grid lines to be the same no matter what the screen 
  20. >resolution.  The following is an excerpt from the code:
  21. >
  22. > [ source code deleted ]
  23. >
  24. >The first loop works fine, and the vertical lines are drawn correctly.
  25. >The problem is that DPtoLP is converting rect.bottom to a negative
  26. >number!  This obviously causes the second loop to next execute.  When
  27. >I look at rect in the debugger, rect.bottom is a positive number.  Why
  28. >is it getting translated to a negative?
  29. >
  30. >If I comment out SetMapMode, then the grid is created, but it won't be
  31. >the same size on any screen.
  32. >
  33. >Any help would be greatly appreciated.
  34. >
  35. >-- 
  36. >_________________________________________________________________________
  37. >Andy Deitsch                             email    : deitsch@crd.ge.com  
  38. >GE Corporate Research & Development      phone    : (518) 387-7207   
  39. >Schenectday, NY 12301                    dial comm: 833-7207     
  40. >
  41.  
  42. It's because the Y-axis in the *device* coordinate system increases
  43. downwards, whereas it increases *upwards* in the MM_LOENGLISH coordinate
  44. system.  Because the bottom your rectangle is below the top, it's at a
  45. negative Y-coordinate.
  46.  
  47. There's a much easier way to do what you want, by the way.  Just use
  48. "GetDeviceCaps" to find the resolution of the device (in pixels per inch),
  49. and scale your grid that way.  If you do this, you can stay with the MM_TEXT
  50. mapping mode.
  51.  
  52. eg, if you want lines spaced 1/4 of a logical inch apart, just say:
  53.  
  54.     int space = GetDeviceCaps( hDC, LOGPIXELS)/4;
  55.  
  56. Best wishes,
  57.  
  58. Chris
  59. -- 
  60. --------------------------------------------------------------------------
  61. | Chris Marriott                           | chris@chrism.demon.co.uk    |
  62. | Warrington, UK                           | BIX: cmarriott              |
  63. |                                          | CIX: cmarriott              |
  64. | Save the whales.  Collect the whole set. | CompuServe: 100113,1140     |
  65. --------------------------------------------------------------------------
  66.  
  67.