Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Dialog Controls/TPageSetupDialog    [ Add a report in this area ]  
Report #:  67694   Status: Closed
Printer dialogs shown for wrong printer
Project:  Delphi Build #:  12.0.3168.16970
Version:    12.0 Submitted By:   Jordan Russell
Report Type:  Basic functionality failure Date Reported:  10/8/2008 9:48:03 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   265756
Resolution: Fixed (Resolution Comments) Resolved in Build: : 12.0.3208.17503
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 25
Description
Printer dialog components (e.g. TPageSetupDialog) do not respect Printer.PrinterIndex. This is a new regression in Delphi 2009.

Cause:

The GetPrinter function in Dialogs incorrectly initializes the Offset fields of the returned DeviceNames record as byte offsets, when, according to MSDN, they should be character offsets:

"wDriverOffset
Offset, in characters, from the beginning of this structure..."

Fix:

Replace Longint() casts with character pointer subtraction:

        wDriverOffset := Longint(Offset) - Longint(DevNames);
   ->
        wDriverOffset := Offset - PChar(DevNames);
Steps to Reproduce:
1. Set up two printers in Windows.

2. Drop a TPageSetupDialog component.

3. Run this code:

  Printer.PrinterIndex := 0;
  PageSetupDialog1.Execute;
  Printer.PrinterIndex := 1;
  PageSetupDialog1.Execute;

Expected result:
It should show two Page Setup dialogs in succession, one for the first printer, then another for the second printer.
(Click the "Printer..." button to see which printer each dialog is associated with.)

Actual result:
It shows two Page Setup dialogs *for the same printer*. The setting of PrinterIndex is effectively ignored.
Workarounds
None
Attachment
None
Comments

Pasquale Rubano at 10/22/2008 11:51:26 PM -
Jordan,
what can we do for this problem? We are beginning a people with this serious problem and CodeGear do not answer. If you know samething mail to me.
Thankyou
   Pasquale Rubano
   prubano@studiorubano.it

Server Response from: ETNACODE01