Solved

Setting print dialog defaults

Posted on 1998-10-09
5
178 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
[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
  • 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

Industry Leaders: 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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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