home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- Path: sparky!uunet!utcsri!torn!cunews!nrcnet0!emr1!jagrant
- From: jagrant@emr1.emr.ca (John Grant)
- Subject: same code to draw on screen & printer?
- Message-ID: <1992Sep16.043056.4532@emr1.emr.ca>
- Organization: Energy, Mines, and Resources, Ottawa
- References: <1992Sep16.042818.4073@emr1.emr.ca>
- Date: Wed, 16 Sep 1992 04:30:56 GMT
- Lines: 43
-
- Every GDI example I see shows a segment of code designed to
- either print something on the printer OR draw something in the
- client area, but never both. I want to use the same code to do
- both, but I am unsure of the best way to structure the code. The
- picture is not simple, but is quite complex (a map of roads, lakes,
- rivers, etc) which involves reading a selection of files. Copying
- the screen to the clipboard & printing is not a real solution - I
- need full scale control and better quality.
-
- I thought that the following might be a good approach:
-
- (a) to screen (i.e. for WM_PAINT)
- hdc=BeginPaint(...);
- DrawMap(hdc,0,FALSE);
- EndPaint(...);
-
- (b) to printer
- hdc=CreateDC(...);
- StartDoc(hdc,&printinfo);
- DrawMap(hdc,50000,TRUE); //1:50,000 scale
- EndDoc(hdc);
- DeleteDC(...);
-
- void DrawMap(HDC hdc,float mapscale,BOOL printer)
- {
- if(printer) Escape(...);
- ....
- if(printer) Escape(...);
- }
-
- mapscale=0 for the screen means 'scale to fit client area', otherwise
- mapscale might be 1:50000 as for a real map.
-
- The 'if(printer) ...' segments within DrawMap are printer-specific
- things like 'Escape(..)' for 'banding' etc. However it seems to
- get really messy doing it that way, because the code to print using
- banding is driven by the returned rectangle from 'Escape', but
- that wouldn't necessarily be the way to draw in the client area.
-
- Has anyone done something like this? Any geographers out there?
- What's the best way?
-
- Please, no ++ or OWL just yet - I'm still learning API.
-