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 get 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
106
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Shkolnik

How can I receive a current printer settings?

Answer:

At first, you must open the printer device: 

1   var
2     FDevice: PChar;
3     FDriver: PChar;
4     FPort: PChar;
5     DeviceMode: THandle;
6     DevMode: PDeviceMode;
7   
8   procedure OpenThePrinterDevice;
9   var
10    Driver_Info2: PDriverInfo2;
11    Retrieved: dword;
12    hPrinter: THandle;
13  begin
14    Printer().GetPrinter(FDevice, FDriver, FPort, DeviceMode);
15    if DeviceMode = 0 then
16      Printer().GetPrinter(FDevice, FDriver, FPort, DeviceMode);
17    OpenPrinter(FDevice, hPrinter, nil);
18    GetMem(Driver_Info2, 255);
19    GetPrinterDriver(hPrinter, nil, 2, Driver_info_2, 255, Retrieved);
20    StrLCopy(FDriver, PChar(ExtractFileName(StrPas(Driver_Info2^.PDriverPath))
21      + #0), 63);
22    FreeMem(Driver_info_2, 255);
23    DevMode := GlobalLock(DeviceMode);
24  end;


And now you can get the information from printer. For example, the orientation 
settings: 
25  
26  if ((DevMode^.dmFields and DM_ORIENTATION) = DM_ORIENTATION) and
27    (DevMode^.dmOrientation = DMORIENT_LANDSCAPE) then
28    //Landscape
29  else
30    //Portrait


Also you can detect a paper size, paper source, print duplex and quality etc. View 
a const description in Windows.pas. 

At last, don't forget to unlock a device: 

GlobalUnlock(DeviceMode);

			
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