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 on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Initializing the Page Setup Dlg box

ahasan
Beginner
654 Views
CVF 6.6, Win32 program -- I would like to initialize the paper orientation in the Page Setup Dlg box to landscape. The default orientation appears to be portrait.

I beleive the way to do this is with a hook function, but I am not sure--the PAGESETUPDLG structure and PageSetUpHook function follow. However, this code generates a run time error when the
PageSetupDlg(pageSetUp) function is executed.

If I remove the references to the hook procedure in the PAGESETUPDLG structure (flag and pointer), and the hook function, the program runs normally.

Is there a more direct way to initialize the paper orientation to landscape? If not, any help with the hook function is appreciated.

integer(4) function InitializePageStructure(hWnd)
! intitialize page setup structure

use MODELGlobals
use comctl32
implicit none

interface
integer(4) function PageSetUpHook(hDlg, Mesg, wParam, lParam)
integer(4) hDlg, Mesg, wParam, lParam
end function
end interface

integer(4) hWnd
type(T_DEVMODE):: DEVMODE_Struct
!pointer(p_dmode,DEVMODE_Struct) ! cause run time error here?????


! initialize DEVMODE structure

! DEVMODE_Struct%dmFields = dm_Orientation
! DEVMODE_Struct%Field1%dmOrientation = DMORIENT_LANDSCAPE
! DEVMODE_Struct%Field1%dmPapersize = DMPAPER_LETTER
! DEVMODE_Struct%Field1%dmPaperLength = NULL
! DEVMODE_Struct%Field1%dmPaperwidth = NULL

! set up page defaults for printer
rtMinMargin%left = 500
rtMinMargin%top = 500
rtMinMargin%right = 500
rtMinMargin%bottom = 500
rtMargins%left = 1000
rtMargins%top = 1000
rtMargins%right = 1000
rtMargins%bottom = 1000

pageSetUp%lStructSize = sizeof(pageSetUp)
pageSetUp%hwndOwner = hwnd
pageSetUp%hDevMode = NULL
pageSetUp%hDevNames = NULL
pageSetUp%Flags = ior(PSD_DISABLEPRINTER , &
ior(PSD_INTHOUSANDTHSOFINCHES , &
ior(PSD_MARGINS,ior(PSD_MINMARGINS,&
ior(PSD_ENABLEPAGESETUPHOOK, PSD_NONETWORKBUTTON)))))
pageSetUp%ptPaperSize = ptPaperSize
pageSetUp%rtMinMargin = rtMinMargin
pageSetUp%rtMargin = rtMargins
pageSetUp%hInstance = ghInstance
pageSetUp%lCustData = NULL
pageSetUp%lpfnPageSetupHook = LOC(PageSetUpHook)
pageSetUp%lpfnPagePaintHook = NULL
pageSetUp%lpPageSetupTemplateName = NULL
pageSetUp%hPageSetupTemplate = NULL


InitializePageStructure = 1
end


integer(4) function PageSetUpHook(hDlg, Message, wParam, lParam)

use dfwin
use MODELGlobals
implicit none

integer(4) hDlg, Message, wParam, lParam
integer(4) hrad1, hrad2, iret

select case (Message)

case (WM_INITDIALOG)

hrad1 = GetDlgItem(hDlg, rad1)
hrad2 = GetDlgItem(hDlg, rad2)

! iret = SendMessage(hrad1, BM_SETCHECK, BST_UNCHECKED, 0)
! iret = SendMessage(hrad2, BM_SETCHECK, BST_CHECKED, 0)

return
end select

PageSetUpHook = 0

return

end
0 Kudos
2 Replies
Steven_L_Intel1
Employee
654 Views
The FORPRINT sample application does this and more.
0 Kudos
ahasan
Beginner
654 Views
Thank you!
0 Kudos
Reply