Solved

Printing

Posted on 2003-11-22
1
256 Views
Last Modified: 2010-04-03
Hi,

I need to know how I can set a printers properties to be default at Tractor Feed.
Every time I use my printer the paper source resets itself to Manual Feed. I have disabled Manual and Sheet Feeder in the printer properties but this doesnt work.

When I select my printer using the printerdialog I need the default paper source to be Tractor and paper output to be 8 1/2 x 11.

Is there any way I can set this in code? Im using Delphi 5 Prof and the dialog is TPrinterDialog

Any suggestions would be great,
Thanks
0
Comment
Question by:HotRod40
1 Comment
 
LVL 3

Accepted Solution

by:
Peter_ earned 100 total points
ID: 9805654
Havent tried this yet, but I found the sample on the net and it looks like it could work. Try setting the different properties of pDMode:

//-------------------------------------------------------------------------

procedure TForm1.Button2Click(Sender: TObject);
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^.dmPaperSize:=DMPAPER_LEGAL;
      { There are many more parameters here you can try, and other properties like pDMode^.dmDefaultSource
      for example. }
      GlobalUnlock(hDMode);
    end;
    GlobalFree(hDMode);
  end;
end;

//------------------------------------------------------------------------

If all else fails, then maybe you could try using SendKeys on the dialog?
 
Depends on if you are able to get hold of the right window. Takes some "trial and error programming", but sometimes it does the trick. See http://www.cbuilder.ru/faqs/faqd_en/16500.html http://www.209software.com/Books/p4dp/sendkeys.html for a sample.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 263
Convert Jpg /PNG To GIF 5 120
HTML text in the body of an email (delphi code) 12 96
RESTRequest Parameter 4 12
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

22 Experts available now in Live!

Get 1:1 Help Now