Articles   Members Online: 3
-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 add all paper bins of an active printer to a TListBox 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
27-Aug-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
70
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How is it possible to add all paperbins from the active printer in a listbox (like 
in the PrinterSetupDialog)?

Answer:

1   uses
2     WinSpool;
3   
4   procedure GetBinnames(sl: TStrings);
5   type
6     TBinName = array[0..23] of Char;
7     TBinNameArray = array[1..High(Integer) div Sizeof(TBinName)] of TBinName;
8     PBinnameArray = ^TBinNameArray;
9     TBinArray = array[1..High(Integer) div Sizeof(Word)] of Word;
10    PBinArray = ^TBinArray;
11  var
12    Device, Driver, Port: array[0..255] of Char;
13    hDevMode: THandle;
14    i, numBinNames, numBins, temp: Integer;
15    pBinNames: PBinnameArray;
16    pBins: PBinArray;
17  begin
18    Printer.PrinterIndex := -1;
19    Printer.GetPrinter(Device, Driver, Port, hDevmode);
20    numBinNames := WinSpool.DeviceCapabilities(Device, Port, DC_BINNAMES, nil, nil);
21    numBins := WinSpool.DeviceCapabilities(Device, Port, DC_BINS, nil, nil);
22    if numBins <> numBinNames then
23    begin
24      raise Exception.Create('DeviceCapabilities reports different number of bins and 
25  '+ 'bin names!');
26    end;
27    if numBinNames > 0 then
28    begin
29      pBins := nil;
30      GetMem(pBinNames, numBinNames * Sizeof(TBinname));
31      GetMem(pBins, numBins * Sizeof(Word));
32      try
33        WinSpool.DeviceCapabilities(Device, Port, DC_BINNAMES, Pchar(pBinNames), nil);
34        WinSpool.DeviceCapabilities(Device, Port, DC_BINS, Pchar(pBins), nil);
35        sl.clear;
36        for i := 1 to numBinNames do
37        begin
38          temp := pBins^[i];
39          sl.addObject(pBinNames^[i], TObject(temp));
40        end;
41      finally
42        FreeMem(pBinNames);
43        if pBins <> nil then
44          FreeMem(pBins);
45      end;
46    end;
47  end;
48  
49  //Called like this:
50  
51  GetBinnames(listbox1.items);


			
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