Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
29302 Discussions

Can/How use Windows Common Print Dialog to gather printer connect name for Fortran Open

David_Caruthers
Beginner
1,185 Views
Can I and How would I use the Windows Common Print Dialog to capture selected printer device for writing the printed output. I have been able to bring up the dialog and get at some of the data but not the data needed to effect a FORTRAN file open.

This routine does a bunch of calculations and then delivers a printed report but needs to have user selectable printers. Since it is dialog driven the print dialog would help.

Thanks

David
0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,185 Views
There are two complete worked examples provided with the product - WinPrint and WinPrintDirect. You will find these in the "Miscellaneous" samples ZIP file. Fortran_WinPrint is probably the one you want - it provides a PRINT_UNIT routine to which you pass an open Fortran unit to which you have written text - it uses Windows printing facilities to send the output to a printer. There are many options, including the ability to bring up the printer selection dialog, font, copies and more.

WinPrintDirect is for writing data directly to a printer, such as Postscript or HP-GL. It does not render text.

View solution in original post

0 Kudos
2 Replies
Paul_Curtis
Valued Contributor I
1,185 Views
In Windows, you start (printer) output by getting a handle to a (printer) device context and then you send your output to that device context. These are distinct steps.

If your program involves opening and reading a file, fortran or whatever, and then reading/sending that content to a printer, that is completely independent of the "select a printer and get its device context" step, which is handled by the common print dialog. The common print dialog does not provide a means of selecting a (text?) file as source material for dumping to a printer in a single integrated step. This can easily be done, but you would have to create your own dialog to select the file and separately to select the printer, and also create your own code to read the file and send its content (with explicit formatting information) to the printer device.

The select-an-available-printer-device portion of the common print dialog may require setting the initial flags correctly, particular PD_PRINTSETUP; here is how I do this:

[bash]TYPE(T_PRINTDLG) :: pd pd%lStructSize = SIZEOF(pd) pd%hwndOwner = hwin pd%hDevMode = NULL pd%hDevNames = NULL pd%hDC = NULL pd%Flags = IOR(PD_RETURNDC, PD_PRINTSETUP) pd%nFromPage = 0 pd%nToPage = 0 pd%nMinPage = 0 pd%nMaxPage = 0 pd%nCopies = 1 pd%hInstance = NULL pd%lCustData = 0 pd%lpfnPrintHook = NULL pd%lpfnSetupHook = NULL pd%lpPrintTemplateName = NULL pd%lpSetupTemplateName = NULL pd%hPrintTemplate = NULL pd%hSetupTemplate = NULL

! common printer dialog
ok = PrintDlg (pd)
[/bash]
0 Kudos
Steven_L_Intel1
Employee
1,186 Views
There are two complete worked examples provided with the product - WinPrint and WinPrintDirect. You will find these in the "Miscellaneous" samples ZIP file. Fortran_WinPrint is probably the one you want - it provides a PRINT_UNIT routine to which you pass an open Fortran unit to which you have written text - it uses Windows printing facilities to send the output to a printer. There are many options, including the ability to bring up the printer selection dialog, font, copies and more.

WinPrintDirect is for writing data directly to a printer, such as Postscript or HP-GL. It does not render text.
0 Kudos
Reply