Solved

Choosing Printer Trays in Delphi

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now