Solved

Setting print dialog defaults

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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