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 set a printer settings 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
08-Jun-03
Category
Reporting /Printing
Language
Delphi 2.x
Views
137
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Shkolnik

How can I set a some printer settings?

Answer:

At first, of course, you must open the printer device (as I described in previous 
tip " to get a printer settings"). 

Now you can set the any settings (supported only, of course) in properties of 
DevMode^ variable and add a "assigned" flag in DevMode^.dmFields. 
After that you need call a SetPrinter procedure and unlock device. 

View small example: 
1   
2   procedure SetPrinterSettings(FPrinter: TPrinter);
3   var
4     FDevice: PChar;
5     FDriver: PChar;
6     FPort: PChar;
7     DeviceMode: THandle;
8     DevMode: PDeviceMode;
9   begin
10    {to get a current printer settings}
11    FPrinter.GetPrinter(FDevice, FDriver, FPort, DeviceMode);
12    {lock a printer device}
13    DevMode := GlobalLock(DeviceMode);
14  
15    {set a paper size as A4-Transverse}
16    if ((DevMode^.dmFields and DM_PAPERSIZE) = DM_PAPERSIZE) then
17    begin
18      DevMode^.dmFields := DevMode^.dmFields or DM_PAPERSIZE;
19      DevMode^.dmPaperSize := DMPAPER_A4_TRANSVERSE;
20    end;
21  
22    {set a paper source as Tractor bin}
23    if ((DevMode^.dmFields and DM_DEFAULTSOURCE) = DM_DEFAULTSOURCE) then
24    begin
25      DevMode^.dmFields := DevMode^.dmFields or DM_DEFAULTSOURCE;
26      DevMode^.dmDefaultSource := DMBIN_TRACTOR;
27    end;
28  
29    {set a Landscape orientation}
30    if ((DevMode^.dmFields and DM_ORIENTATION) = DM_ORIENTATION) then
31    begin
32      DevMode^.dmFields := DevMode^.dmFields or DM_ORIENTATION;
33      DevMode^.dmOrientation := DMORIENT_LANDSCAPE;
34    end;
35  
36    {set a printer settings}
37    FPrinter.SetPrinter(FDevice, FDriver, FPort, DeviceMode);
38  
39    {unlock a device}
40    GlobalUnlock(DeviceMode);
41  end;


If you need to change the paper size to custom size for example, 100mm x 100mm, you 
must assign the custom width and height to dmPaperWidth and dmPaperLength and 
include the DM_PAPERWIDTH/DM_PAPERLENGTH flags to dmFields property: 
42  
43  DevMode^.dmPaperWidth := PaperSizeWidth;
44  DevMode^.dmPaperLength := PaperSizeHeight;
45  DevMode^.dmFields := DevMode^.dmFields or DM_PAPERWIDTH or DM_PAPERLENGTH;




			
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