home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / mswindo / programm / misc / 1868 < prev    next >
Encoding:
Text File  |  1992-09-15  |  1.9 KB  |  54 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!utcsri!torn!cunews!nrcnet0!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: same code to draw on screen & printer?
  5. Message-ID: <1992Sep16.043056.4532@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. References: <1992Sep16.042818.4073@emr1.emr.ca>
  8. Date: Wed, 16 Sep 1992 04:30:56 GMT
  9. Lines: 43
  10.  
  11. Every GDI example I see shows a segment of code designed to
  12. either print something on the printer OR draw something in the
  13. client area, but never both.  I want to use the same code to do
  14. both, but I am unsure of the best way to structure the code.  The
  15. picture is not simple, but is quite complex (a map of roads, lakes,
  16. rivers, etc) which involves reading a selection of files.  Copying 
  17. the screen to the clipboard & printing is not a real solution - I
  18. need full scale control and better quality.
  19.         
  20. I thought that the following might be a good approach:
  21.  
  22. (a) to screen (i.e. for WM_PAINT)
  23.     hdc=BeginPaint(...);
  24.     DrawMap(hdc,0,FALSE);
  25.     EndPaint(...);
  26.         
  27. (b) to printer
  28.     hdc=CreateDC(...);
  29.     StartDoc(hdc,&printinfo);
  30.     DrawMap(hdc,50000,TRUE);  //1:50,000 scale
  31.     EndDoc(hdc);
  32.     DeleteDC(...);
  33.  
  34. void DrawMap(HDC hdc,float mapscale,BOOL printer)
  35. {
  36.     if(printer) Escape(...);
  37.     ....
  38.     if(printer) Escape(...);
  39. }
  40.  
  41. mapscale=0 for the screen means 'scale to fit client area', otherwise
  42. mapscale might be 1:50000 as for a real map.
  43.  
  44. The 'if(printer) ...' segments within DrawMap are printer-specific
  45. things like 'Escape(..)' for 'banding' etc.  However it seems to 
  46. get really messy doing it that way, because the code to print using 
  47. banding is driven by the returned rectangle from 'Escape', but
  48. that wouldn't necessarily be the way to draw in the client area.
  49.  
  50. Has anyone done something like this?  Any geographers out there?
  51. What's the best way?
  52.  
  53. Please, no ++ or OWL just yet - I'm still learning API.
  54.