Solved

Choosing Printer Trays in Delphi

Posted on 1998-07-17
3
738 Views
Last Modified: 2010-04-03
How can I select between multiple printer trays in Delphi?  I can't find a property of the TPrinter that tells me (1) does the printer have multiple trays, or (2) which one is selected.

The particular application is printing to an HP-6P using the latest version of QuickReports.

TIA
0
Comment
Question by:saintcyr
3 Comments
 

Expert Comment

by:kashif063098
ID: 1358127
WHAT ABOUT I TELL YOU WIN32 API FUNCTION TO SOLVE YOUR PROBLEM(S)
?
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1358128
Hi saintcyr,

from inprise Q&A :

Getting bin names from your printer
Question:
How do I retrieve the bin names of all bins for a particular printer using DeviceCapabilities?
Answer:
Here's a very simple app to do this. Just start a brand new
project in Delphi and drop down a TButton and a TMemo. Then
double click the button and paste this code snippet over the
corresponding code in the implementation of Unit1.

uses
  WinSpool;

const
  PName = 'DELPHI III';
  PPort = '\\CONAN\DELPHI_III';

procedure TForm1.Button1Click(Sender: TObject);
var
  i : Integer;
  p : PChar;
begin
  GetMem(p,24*DeviceCapabilities(PName,PPort,DC_BINNAMES,nil,nil));
  with Memo1, Lines do begin
    Clear;
    for i:=1 to DeviceCapabilities(PName,PPort,DC_BINNAMES,p,nil) do
      Add(p+24*(i-1));
  end;
  FreeMem(p);
end;

and changing it :

Changing Printer Bins


> Anyone know how to easily change printer bins on the fly. Any assistance
> would be much appreciated.
> Howard

One way to change printer settings at the start
of a print job is to change the printers devicemode.

See: TDEVMODE in the Delphi 1.02 help file or DEVMODE
in the Delphi 2.01 help file for other settings you can
change (providing the print driver supports the change).


Here is an example of changing paper sizes:

var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port   : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.GetPrinter(Device, Driver, Port, hDMode);
  if hDMode <> 0 then begin
    pDMode := GlobalLock(hDMode);
    if pDMode <> nil then begin
      pDMode^.dmFields := pDMode^.dmFields or  dm_PaperSize;
      pDMode^.dmPaperSize := DMPAPER_LEGAL;
      GlobalUnlock(hDMode);
    end;
  end;
  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.BeginDoc;
  Printer.Canvas.TextOut(100,100, 'Test 1');
  Printer.EndDoc;
end; (Joe Hecht)



Greetings, Zif.
0
 

Author Comment

by:saintcyr
ID: 1358129
Thanks for the lead.  The key I presume is to study the structure of DEVMODE.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question