Solved

Choosing Printer Trays in Delphi

Posted on 1998-07-17
3
775 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
[X]
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
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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