Solved

Setting print dialog defaults

Posted on 1998-10-09
5
172 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

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