- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The FORPRINT sample application does this and more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!

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