Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Choosing Printer Trays in Delphi

Posted on 1998-07-17
3
Medium Priority
?
789 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 100 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

610 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