Xojo 2014 r2.1 - Windows 7 and 8
I have a report which requires printing in landscape… Whilst I have no problem with the printing part I am also trying to create a print preview and have a problem of getting the report to output in landscape size without using OpenPrinterDialog(ps). It seems that settings such as ps.Landscape=true are not set for the report to see until this is called. I have been told that using calls to windows API should achieve this but I’m getting bogged down as this is the first time I have tried this.
Using the following code allows me to call the OpenPrinterDialog and calling AbortDoc stops the printer spitting out a blank page:
Dim ps As New PrinterSetup ps.MaxHorizontalResolution=75 ps.MaxVerticalResolution=75 ps.Landscape=true Dim rpt As New ContainerEntryReport dim g As Graphics g=OpenPrinterDialog(ps) Declare Function AbortDoc Lib "GDI32" ( hDC As Integer) As Integer Dim hDC As Integer = g.Handle(Graphics.HandleTypeHDC) call AbortDoc(hDC) If rpt.Run(lbResult, ps) Then If rpt.Document <> Nil Then Dim rptWindow As New ReportWindow rptWindow.RptDoc = rpt.Document rptWindow.Show End If End If
I believe I should be able to use the Escape function i.e. Declare Function Escape Lib “GDI” (hDC As Integer, nEscape As Integer, nCount As Integer, lpInData As Orient, lpOutData As Integer) As Integer (orient in this instance is a data structure.) but can’t get it to work.
Does anyone have any experience of this and able to give me any pointers?