From: "Joe C. Hecht" Subject: Re: changing printer orientation [long and technical explanation] Date: 21 Jan 1999 00:00:00 GMT Message-ID: <36A7C0B8.4B95@gte.net> Content-Transfer-Encoding: 7bit References: <36A7B088.6E8087@execpc.com> Content-Type: text/plain; charset=us-ascii Organization: Offshore Technology Mime-Version: 1.0 Reply-To: joehecht@gte.net Newsgroups: borland.public.delphi.graphics Robert Kennedy wrote: > > Using Delphi 3, is there a way to change the orientation of the printer > from portrait to landscape in mid print job? I can stop the job, > reorient, then continue printing in a new job but this is > unsatisfactory. > > Is there a way to do it without producing multiple print jobs? > > Using this statement in mid print job causes an error. > Printer.orientation := poLandscape; > > Thanks for any help or suggestions. > > Robert Kennedy Yes, it is perhaps possible to change many of the settings of between pages a printjob. I thought that I had written a Ti or FAQ detailing how to do this, but I am unable to locate it. Basically, you will need to patch TPrinter to make a callback to a unit that will sit between you and TPrinter. This is an interesting workaround. I have been told (by the father of Delphi himself and other notables) that you cannot make changes to TPrinters interface without risking breaking other VCL code. The workaround is rather simple. Create you intermediate unit, and reference it only from the *implementation* section of TPrinter. You want to create a callback to the intermediate unit that occures *between* every page that is printed. You can assign a callback in the intermediate unit from your application, so that your callback function in your application will get called whenever the callback funcion in the intermediate unit gets called. From there, you can get access to the printers DevMode structure and use API functions like ReSetDc() to attempt to change the printer setup in between pages. ResetDC() is pretty good about reporting if the printer supports this escape, and if the call fails (rarely), your application can seperate the pages into individual print jobs. Note that most print drivers do support changing the settings between jobs. [As a technical side note, the ResetDC() function actually makes an escape call into 16 bit drivers (IMHO, is not well documented for 16 bit dirvers). A further note is that non NT platforms use 16 bit print drivers (although some of them are actuall marked as 32 bit dlls)]. A well implemenated unit can make it very painless to use these features without ever touching the interface section of TPrinter. Sorry to say, I cannot directly post the code, however (and here comes the plug), the code is contined in a book that I took part in authoring called "Delphi 3 Special Edition" published by Que. Please note that I have tried to be specific enough in the general theory for you to implement a suitiable workaround, and that I recieve no royalties should your decide to purchase the book. ie: I have no financial interest in selling you anything. On the other hand, you may find some of the tips and techniques contained in the book to be a valuable asset, especally if you are doing graphics, printing, or wirking with the Windows API. Joe -- Joe C. Hecht http://home1.gte.net/joehecht/index.htm