calling GDI api to set paper orientation

Hi All,

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
Dim rpt As New ContainerEntryReport
dim g As  Graphics
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
  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?

Thank you

lpOutData is a pointer to a block of memory that you provide. Windows will fill the memory with one of several data structures depending on the other parameters used.

Change lpOutData from an Integer to a Ptr, and then pass a MemoryBlock big enough to contain the data being requested.

And do the same thing with lpInData.