Solved

Setting print dialog defaults

Posted on 1998-10-09
5
173 Views
Last Modified: 2010-04-06
I've managed to find out how to set my printer default to portrait or landscape, as needed, but how would I:

Set the printer dialog box to default to legal size paper, and 150dpi instead of the printer default 300dpi?
0
Comment
Question by:oneeye
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 1342433
Hi,
  Try the following:
   Printer.PageWidth:=your page width;
    Printer.PageHeight:=your page height;
   Printer.Canvas.Font.PixelsPerInch:=150;

 KEEP ON THE DELPHI
0
 

Author Comment

by:oneeye
ID: 1342434
Those are read only properties: they give you the number of pixels in the canvas you are printing. Attempting to assign a property to pageheight and pagewidth gives an error...
0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 1342435
hi again
 found this it might be of more help
it contains code to change the papersize and
the paper bin that is used:

procedure TForm1.Button1Click(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
 
{Set to legal}
 
 pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
 pDMode^.dmPaperSize := DMPAPER_LEGAL;

{Set to custom size}

 pDMode^.dmFields := pDMode^.dmFields or
 DM_PAPERSIZE or
 DM_PAPERWIDTH or
 DM_PAPERLENGTH;
 pDMode^.dmPaperSize := DMPAPER_USER;
 pDMode^.dmPaperWidth := 100 {SomeValueInTenthsOfAMillimeter};
 pDMode^.dmPaperLength := 100 {SomeValueInTenthsOfAMillimeter};

{Set the bin to use}
 pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
 pDMode^.dmDefaultSource := DMBIN_MANUAL;
 GlobalUnlock(hDMode);
   end;
  end;
Printer.PrinterIndex := Printer.PrinterIndex;
 Printer.BeginDoc;
 Printer.Canvas.TextOut(100,100, 'Test 1');
 Printer.EndDoc;
end;
0
 

Author Comment

by:oneeye
ID: 1342436
That's got it! Much obliged.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1342437
wayhay glad to be of assistance
printing can be a real *****  
and thankyou for my first points
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

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…
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…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

21 Experts available now in Live!

Get 1:1 Help Now