Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Landscape mode in printer

rswy
Beginner
342 Views
I'd like to know how to set and retrieve mode settings in a printer.I am having trouble using the PD_SELECTLANDSCAPE option.Also I'd like to know how I can achieve this using the PAGESETUPDLG structure as it is supposed to be used instead of PRINTDLG.
Thanks.
-rswy
0 Kudos
2 Replies
pcurtis
Beginner
342 Views
The att. module shows how to initiate printing.
This is really just standard Win32 code, realized
in Fortran.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
342 Views
Paul's code is working, but it answers only a half of the post -- to predefine contents of PrintDlg is far trickier.
PD_ flags control only few aspects of dialog's contents. Structure DEVMODE actually contains all the stuff relevant for printer driver to set up the printer. Particularly, its member dmOrientation controls the paper orientation (DMORIENT_PORTRAIT/DMORIENT_LANDSCAPE). The tricky part is that DEVMODE contains only settings common for all printers; however, many printer drivers have some specific stuff ("Advanced" options from print dialog) which they put in memory just after DEVMODE structure. Since user can change the printer in the dialog, the API requires you to allocate memory for DEVMODE (+extra bytes) with GMEM_MOVEABLE flag so that it could reallocate it if needed, i.e. the DEVMODE mustn't be a static variable.

Since DEVMODE (+extra stuff) is huge, you'll have to retrieve the DEVMODE with default printer settings, modify it, and pass it to PrintDlg. The following code is written ad-hoc so pardon me for possible errors.

TYPE(T_DEVMODE):: DM; POINTER(pDM, DM)
TYPE(T_PRINTDLG):: PD
!Initialize the rest of PD as in Paul's post
PD%Flags = PD_RETURNDEFAULT
PD%hDevMode = NULL
PD%hDevNames = NULL

!This call will not display the dialog, but fill in
!DEVMODE for the default printer
IF (PrintDlg(PD)) THEN
   !Retrieve the pointer to DM
   pDM = GlobalLock(PD%hDevMode)
   DM%dmOrientation = DMORIENT_LANDSCAPE
   b = GlobalUnlock(PD%hDevMode)
   
   PD%Flags = PD_RETURNDC !+ other PD_ flags as needed
   IF (PrintDlg(PD)) THEN
      !Do the printing on PD%hDC -- StartDoc/StartPage etc.
   END IF
   b = GlobalFree(PD%hDevMode)
   b = GlobalFree(PD%hDevNames)
END IF


HTH
Jugoslav
0 Kudos
Reply