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
Solved

Setting print dialog defaults

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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