Software Archive
Read-only legacy content
17061 Discussions

How do you printing graphics?

davidgraham
Beginner
645 Views
fortran_winprint.f90 is used to print a text file.

How can you print screen graphics?

Thanks, David
0 Kudos
4 Replies
isn-removed200637
645 Views
A quickWin program has menus File and Edit. Under the File menu is a 'Print..' command which will print the current graphics window.
you can also use the 'select graphics' item in the 'Edit menu' and the 'Copy' item to
copy selected graphics to the clipboard. This can then be pasted into Word and printed off.
0 Kudos
davidgraham
Beginner
645 Views
It is Windows API project not QuickWin.

As you say, I could just copy the screen to the clip board and print using Paint, but I would like to get a better resolution.

Thanks, David
0 Kudos
Intel_C_Intel
Employee
645 Views
Since you are using Win32 API already, your subroutine that handles WM_PAINT messages already does most of the work that you need to do. Look at the documentation for the PrintDlg function -- there actually isn't much to it if you don't have to print to network printers.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
645 Views
...to extend James' idea, most of the time you should be able to reuse the code
from WM_PAINT handler; the following steps, however, should be necessary:

1) Call PrintDlg (simplest) to obtain printer hDC;

2) Before drawing you should call:

GetDeviceCaps(LOGPIXELS* to obtain horz & vert. resolution

GetDeviceCaps(PHYSICALWIDTH/HEIGHT to obtain paper dimensions in pixels

SetMapMode() to specify scaling; the default is MM_TEXT, meaning that your

drawing will be a tiny spot in upper left corner. MM_ISOTROPIC arbitrarily scales

the coordinate system, preserving aspect ratio; MM_ANISOTROPIC also arbitrarily
scales but not preserving aspect ratio;

SetViewportOrgEx & SetViewportExtEx to (0,0, PaperWidth, PaperHeight)

SetWindowOrgEx & SetWindowExtEx to (0,0, YourWindowWidth, YourWindowHeight)

StartDoc()

StartPage()


--- WM_PAINT code here --------


EndPage()

EndDoc()


The only thing you should take care of is CreateFont (whose input is in pixels, not in logical units). You should use FontSizePt*GetDeviceCaps(hDC,LOGPIXELSY)/72 as font size argument (note that for screen, the latter value is 72 so you get what you had before; for printer, you get the font of correct value).

See "2-D graphics/Coordinate spaces and transformations" chapter in SDK -- these should give you a good understanding. If you're familiar with QuickWin, Win32 "device units" correspond to QW "Viewport coordinates" while "logical units" correspond to QW "Window coordinates".

HTH

Jugoslav
0 Kudos
Reply