OK, I give up. I'm trying to change the printer's orentitation to landscape. For good. DocumentProperties only seems to work until I close the printer, then it reverts back to Portrate. I'm trying to print an HTM file, an Envelope, so it needs to be able to set it to landscape and make it stick until ShellExecute returns. Any ideas? I'm fresh out of things to try. Thanks! - Danny.
Announcement
Collapse
No announcement yet.
Chang Printer Properties
Collapse
X
-
If the print is actually being done by a shelled program (code not shown), that shelled program probably picks up the printer defaults rather than the settings in the parent program.
So, it must be something you have to set by opening the PRINTERS folder and finding some settings rather than the DOCUMENT.
If it's your program which is ShellExecuted, of course, you can programmatically set the orientation before you print and put it back before you exit.
i.e., we need more info about what progam is ShellExecuting what other program.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
-
Sorry Michael. I want to do something like this
Code:Function PbMain SetPrinterOrientation %DmOrient_Landscape ShellExecute %Null, "PRINT", "C:\Envelope.htm", ByVal %Null, CurDir$, 0) 'The program then scans for the print window, and clicks Print on it when it comes up. After the job is printed, you guessed it ... SetPrinterOrientation %DmOrient_Portrate End Function
Comment
-
Well, we'd have to guess what program prints "*.htm" files on your system, but whatever it is, that's the program you have to control. Maybe there is a command-line option you can try, something like..
Code:ShellExecute %NULL, "PRINT", "C:\Envelope.htm /LANDSCAPE "....
When Windows programs print things, they get the orientation and other printer settings from within the calling program.
When you opt for the 'ease' of calling another program to do the dirty work (ShellExecute) , you have made the decision to live with any limitations or restrictions that program might contain.
There may be a way to reset the printer's defaults, shell the print, then put back the defaults, but I can't find it with a quick trip to the SDK.
You might be better off in the long run to issue the printing commands yourself. The "XPRINT" functions added in Pb/Win 7x are not that complicated, and I know there are plenty of code samples here for both that and for parsing HTML.
For that matter, you might find here or elsewhere "code to print HMTL files"Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
The printer settings you can configure are local to your app only - all new instances of other applications (ie. started via Shell, ShellExecute, CreateProcess, etc) are given the default printer settings as chosen by the user. Off hand, I cannot think of any way to change these default settings, other than manually via control panel.
However, some apps will have pre-stored printer settings that are kept between instances in the registry or an INI file, depending on how the app was written. The default HTML processor - Internet Explorer - supports this. To change IE printer settings, it can be done via the registry:
Perhaps you could try changing the required key(s) and restore after the shell? Personally, I would think about using a dedicated library that can print HTML, or use XPRINT, then you would have all the control you need. Perhaps IE's COM interface supports this directly?
Comment
-
Thank you, Kev and Michael. I think I'll revert to a Word Macro, or something like that. Eventually, yes, I'll just draw the text on the DC myself, but for now (need to get invoices out today) I'll get by with a macro. Thanks again for all your help, never imagined there wasn't a way to adjust printer properties programatically. Take care. - Danny.
Comment
Comment