Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to change the page orientation in the middle of a print job Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
07-Oct-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
67
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

Is it possible to change the printer orientation from portrait to landscape in the 
middle of a print job?

Answer:
1   
2   procedure TForm1.Button2Click(Sender: TObject);
3   var
4     Device: array[0..255] of char;
5     Driver: array[0..255] of char;
6     Port: array[0..255] of char;
7     hDeviceMode: THandle;
8     pDevMode: PDeviceMode;
9   begin
10    with Printer do
11    begin
12      BeginDoc;
13      try
14        Canvas.font.size := 20;
15        Canvas.font.name := 'Arial';
16        Canvas.TextOut(50, 50, 'This is portait');
17        GetPrinter(Device, Driver, Port, hDeviceMode);
18        pDevMode := GlobalLock(hDevicemode);
19        with pDevMode^ do
20        begin
21          dmFields := dmFields or DM_ORIENTATION;
22          dmOrientation := DMORIENT_LANDSCAPE;
23        end;
24        { Cannot use NewPage here since the ResetDc will only work between EndPage
25        and StartPage. As a consequence the Printer.PageCount is not updated. }
26        Windows.EndPage(Printer.Handle);
27        if ResetDC(canvas.Handle, pDevMode^) = 0 then
28          ShowMessage('ResetDC failed, ' + SysErrorMessage(GetLastError));
29        GlobalUnlock(hDeviceMode);
30        Windows.StartPage(Printer.Handle);
31        Printer.Canvas.Refresh;
32        Canvas.font.size := 20;
33        Canvas.font.name := 'Arial';
34        Canvas.TextOut(50, 50, 'This is landscape');
35      finally
36        EndDoc;
37      end;
38    end;
39  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC