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 print to a specific bin 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
23-Sep-03
Category
Reporting /Printing
Language
Delphi 3.x
Views
138
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Lou Adler

Needed routine to print output to a specific bin on a laser printer. The key to 
this routine is the DevMode structure, there are several other routines that could 
be written using this structure.

Answer:
1   
2   procedure BinToPrintTo(BinNo: Integer);
3   var
4     ADevice, ADriver, APort: string;
5     ADeviceMode: THandle;
6     DevMode: PDeviceMode;
7   begin
8     SetLength(ADevice, 255);
9     SetLength(ADriver, 255);
10    SetLength(APort, 255);
11    if ADeviceMode = 0 then
12    begin
13      Printer.PrinterIndex := Printer.PrinterIndex;
14      Printer.GetPrinter(PChar(ADevice), PChar(ADriver),
15        PChar(APort), ADeviceMode);
16    end;
17    if ADeviceMode <> 0 then
18    begin
19      DevMode := GlobalLock(ADeviceMode);
20      try
21        DevMode^.dmDefaultSource := BinNo;
22      finally
23        GlobalUnlock(ADeviceMode);
24      end;
25    end
26    else
27      raise Exception.Create('Could not set printer copies');
28  end;


The functionality to Query the bin numbers. Setting the bin number must follow the 
query of binnames and the assosiated number the following code  is a brief sample 
how it could be done. 

29  var
30    iPaperTrayCount: Integer;
31    sBinNames: array of array[0..23] of Char;
32    iBinValues: array of Smallint;
33    iNumBins: Integer;
34    sPrinterDev: string;
35  
36  begin
37    //  Get the device name
38    sPrinterDev := TPrinterDevice(Printer.Printers.Objects[PrinterIndex]).Device;
39    // Query the number of Papaerbins
40    iNumBins := DeviceCapabilities(PChar sPrinterDev), '', DC_BINNAMES, nil, nil);
41  
42  if iNumBins >= 0 then
43  begin
44    // Create an array that holds the name of the paper bin
45    // and a second to hold the needed Binnumbers
46  
47    SetLength(sBinNames, iNumBins);
48    SetLength(iBinValues, iNumBins);
49  
50    // get the names
51    DeviceCapabilities(PChar(sPrinterDev), nil, DC_BINNAMES, @sBinNames[0], nil);
52    // get the numbers
53    DeviceCapabilities(PChar(sPrinterDev), nil, DC_BINS, @iBinValues[0], nil);
54  end;
55  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