Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Choosing Printer Trays in Delphi

Posted on 1998-07-17
3
746 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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