Printing Orientation

Discussions specific to Team Developer 5.2.

Printing Orientation

Postby christian.damilot » Wed Jan 04, 2012 2:04 am

[ Team Developer version 5.2-SP2 Build 21679]

I have a problem with a OCX called ‘TX TEXT CONTROL’
I do not know how to make a print in landscape !
There is no function in this OCX who tell to the printer to print in landscape.

Here is my example:

Form variables
whDCPrinter wsPrinter wsDriver wsPort
Function: PalPrintDoc
Description:
Returns
Parameters
String: psDocName
Number: pnFromPage
Number: pnToPage
Number: pnCopies
Static Variables
Local variables
Number: lnIndexPage
Number: lnIndexCopie
Number: lnDoc
Number: lnPage
Number: lnOrientation
Actions
!
Call SalPrtGetDefault( wsPrinter, wsDriverC, wsPort )
!
Set whDCPrinter = SalPrtDeviceOpen( wsPrinter, wsDriver, wsPort )
!
If pnFromPage < 1
Set pnFromPage = 1
If pnToPage < 1
Set pnToPage = 1
If pnCopies < 1
Set pnCopies = 1
!
Set lnDoc = StartDocW(whDCPrinter, 20, GetFileName(), STRING_Null, STRING_Null, 0)
!
Set lnIndexCopie = 0
!
While (lnIndexCopie < pnCopies)
Set lnIndexPage = pnFromPage
While (lnIndexPage <= pnToPage)
!
If whDCPrinter > 0
Call axTxTextControl.PropSetPrintDevice( whDCPrinter )
!
! New page
Set lnPage = StartPage(whDCPrinter)
! Take the orientation of the page
Call axTxTextControl.PropGetPageOrientation( lnOrientation )
!
(*) ??? Escape function from the win32api ???
!
Call axTxTextControl.PrintPage( lnIndexPage)
!
! End of page > printing page
Call EndPage(whDCPrinter)
Set lnIndexPage = lnIndexPage + 1
Set lnIndexCopie = lnIndexCopie + 1
!
Call EndDoc(whDCPrinter)


(*) I think I have to use the <Escape> function but I have no idea how to make !

In VB, here is the example:

Declare Function Escape% Lib "GDI" (ByVal hDC%, ByVal nEsc%, ByVal
nLen%,
|lpData As Any, lpOut As Any)

Sub Command1_Click ()
Const PORTRAIT = 1
Const LANDSCAPE = 2
Const GETSETPAPERORIENT = 30
Dim Orient As OrientStructure
Printer.Print ""
Orient.Orientation = LANDSCAPE
x% = Escape(Printer.hDC, GETSETPAPERORIENT, Len(Orient), "", Null)
Print x%
End Sub

Thanks for your reply
Chris.
christian.damilot
 
Posts: 3
Joined: Wed Jan 04, 2012 1:54 am

Re: Printing Orientation

Postby lrcuess » Wed Jan 04, 2012 2:10 am

Hello,

you call the following function:
Call axTxTextControl.PropGetPageOrientation( lnOrientation )

There should also be a
Call axTxTextControl.PropSetPageOrientation( lnOrientation )

Max
Markus Eßmayr
RACON Software GmbH
http://www.racon.at
User avatar
lrcuess
 
Posts: 1163
Joined: Mon May 07, 2007 5:58 am
Location: Linz, Austria

Re: Printing Orientation

Postby christian.damilot » Tue Jan 10, 2012 6:15 am

The function :

Call axTxTextControl.PropSetPageOrientation( lnOrientation )

does not have effect on the printer, it has effect on the document orientation on the screen !

Citation :
" It doesn't make sense, if TX Text Control will set these settings, as a word processor should be as flexible as possible. Very often developers want to make their own dialog boxes which contains other settings for the printer.
The settings WON'T be send automatically to the printer. They have to be set in the printer object. (VB)
Björn Meyer, TX Text Control"

Is there a printer object in team developer 5.2 ?

Chris.
christian.damilot
 
Posts: 3
Joined: Wed Jan 04, 2012 1:54 am

Re: Printing Orientation

Postby lrcuess » Wed Jan 11, 2012 2:38 am

Hi,

I'm not a VB developer thus I don't know, what the printer object in VB is.
Do you know that?

In fact, TD doesn't have a special printer object.
There are only a bunch of SalPrt* functions but you could try if they affect printing from the TX Text Control in any way.

Which version of the TX Text Control do you use?
As there was a change in Page Orientation in version 14, maybe this affects you.
http://www.textcontrol.com/en_US/suppor ... 00.new.htm

If I'd build a document using this control having one page portrait and one in landscape, I'd expect that the TX Text Control will print them correctly without the need to additionally send special codes to the printer from my application.

Max
Markus Eßmayr
RACON Software GmbH
http://www.racon.at
User avatar
lrcuess
 
Posts: 1163
Joined: Mon May 07, 2007 5:58 am
Location: Linz, Austria

Re: Printing Orientation

Postby christian.damilot » Thu Jan 29, 2015 3:21 am

I have found a solution :

Function: PalInitialiseLPT
Description:
Returns
Parameters

Static Variables
Local variables
Number: nOrientationOffset
Number: hPrinter
Number: nBufferLength
Number: nFlags
Number: lnOrientation
Number: nOrientation
Actions
! TxTextControl.Orientation = 1 >Landscape / = 0 > Portrait => Windows = 1 > Portrait / = 2 => Paysage
Call ax4.PropGetPageOrientation( lnOrientation )
If lnOrientation = 1
Set nOrientation = 2
Else
Set nOrientation = 1
!
Call DeleteDC( whDCPrinter )
If OpenPrinterW( gsPrinterChoix , hPrinter, 0)
Set nBufferLength = 156 * 2
Call SalStrSetBufferLength(wsDevModeOut, nBufferLength)
Set nBufferLength = DocumentPropertiesA( hWndForm, hPrinter, gsPrinterChoix, wsDevModeOut, wsDevModeIn, 0 )
Call SalStrSetBufferLength(wsDevModeOut, nBufferLength)
!
If SalStrGetBufferLength( wsDevModeOutSave ) > 0
Set nFlags = DM_IN_BUFFER | DM_OUT_BUFFER
Call SalStrSetBufferLength( wsDevModeIn, nBufferLength )
Call RtlMoveMemory( wsDevModeIn, wsDevModeOutSave, nBufferLength )
Set wsDevModeIn = wsDevModeOutSave
Else
Set nFlags = DM_IN_BUFFER | DM_OUT_BUFFER
!
Call DocumentPropertiesW( hWndNULL, hPrinter, gsPrinterChoix, wsDevModeOut, wsDevModeIn, nFlags )
!
Set nOrientationOffset = 32 * 2 + 2*4 + 4
Call CStructPutWord(wsDevModeOut, nOrientationOffset, nOrientation )
Set wsDevModeOutSave = wsDevModeOut
Call SalStrSetBufferLength( wsDevModeOutSave, nBufferLength )
Call RtlMoveMemory( wsDevModeOutSave, wsDevModeOut, nBufferLength )
!
Set whDCPrinter = CreateDCW( gsDriverChoix, gsPrinterChoix , STRING_Null, wsDevModeOutSave )
Call ResetDCW( whDCPrinter, wsDevModeOutSave )
Call ClosePrinter(hPrinter)
christian.damilot
 
Posts: 3
Joined: Wed Jan 04, 2012 1:54 am


Return to Team Developer 5.2

Who is online

Users browsing this forum: No registered users and 4 guests