- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
WinPrintDirect is for writing data directly to a printer, such as Postscript or HP-GL. It does not render text.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]
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]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
WinPrintDirect is for writing data directly to a printer, such as Postscript or HP-GL. It does not render text.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page