#Printer Orientation
7 messages in this thread
As we've discussed via Email, the routine you posted in a message for
changing the orientation of the printer between Landscape and Portrait
works, but I have to print a page to get it to take effect. I fixed some
typos in the code and added it to the new VBTIPS file on DL1, but here it
is again:
GLOBAL:
Type ORIENT
Orientation as Long
Pad as string * 16
End Type
Declare Function PrtOrient% Lib "GDI" Alias "Escape" (ByVal hDc%,
ByVal nEsc%,
ByVal nLen%,
lpData as ORIENT,
lpOut as Any)
Global prtO as Orient
Sub Form_Click
prtO.Orientation = n 'n=1 for portrait or 2 for landscape
x% = PrtOrient%(Printer.hDC, 30, len(prtO), prtO, 0&)
Printer.Print "whatever text you want to print goes here"
Printer.EndDoc
End Sub
It's like the change doesn't take effect until after an EndDoc has been
issued, which isn't very desirable. If anyone can shed any light on this,
I would appreciate it.
There are 4 Replies.
Nelson,
re: Setting printer Orientation
As I indicated in my Email reply, I was only able to test this routine by
running it and checking to see what settings were set in the printer setup
dialog through control panel. Escape may only be changing the settings in
the printer driver and not also making the change in the environment block
associated with the printer. Thus, the first page is required to get the
driver information copied to the environment block. Perhaps one of the more
informed gurus could lend a hand here.
–dennis
Nelson,
This is just a guess but have you tried sending a WM_WININICHANGE to the
Form?
Costas
Nelson,
I also used the routine that Dennis posted to switch back and
forth between Portrait and Landscape modes. However, being more
of a conservationist, I use a simple Printer.EndDoc to affect the
change (rather than printing a "setup page") saving a piece of
processed tree pulp at each iteration… 🙂
john k
There is 1 Reply.
I'm trying to get out of having to print an extra page. That's the point of
this thread. Can you show me the routine that you use to avoid it?
Hi Nelson,
You may have to open a link to the printer first. There was some
problems with printing the bitmaps where you had to throw in a
Printer.Print "" first to "wake" up the printer. Try this.
Don Funk
There is 1 Reply.
Nope, that didn't help either. The only thing I've gotten to work is to do
an EndDoc after setting the orientation and before printing. Of course that
wastes a sheet of paper.