View Issue Details

IDProjectCategoryView StatusLast Update
0023771LazarusPrinterpublic2013-06-24 16:13
ReporterPetr-KAssigned ToJesus Reyes 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Platformwin32OSOS Version
Product Version1.1 (SVN)Product Build 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0023771: TPrintDialog in win32 does not work
DescriptionIf PrintDialog is compiled with USEUNICODE define, then for example Copies settings does not work.

It is caused by bad type cast.
Object TPrinterDevice has member DevMode: PDeviceModeW, but in program are used
variables with bad type DevMode: PDeviceMode;

Patch against trunk #39991 is in the attachement.


Steps To ReproduceOpen PrinterDialog, change number of copies and close.
PrinterDialog.Copies does not corespond with your settings.
TagsNo tags attached.
Fixed in Revision40016
LazTarget1.2
WidgetsetWin32/Win64
Attached Files
  • patch (3,751 bytes)
    Index: components/printers/win32/winprndialogs.inc
    ===================================================================
    --- components/printers/win32/winprndialogs.inc	(revision 39991)
    +++ components/printers/win32/winprndialogs.inc	(working copy)
    @@ -41,12 +41,13 @@
     var
       lpp        : tagPSD;
       PDev       : TPrinterDevice;
    -  DevMode    : PDeviceMode;
       DeviceMode : THandle;
       DevNames   : PDevNames;
       {$IFDEF USEUNICODE}
    +  DevMode    : PDeviceModeW;
       St         : PWidechar;
       {$ELSE}
    +  DevMode    : PDeviceMode;
       St         : PChar;
       {$ENDIF}
     begin
    @@ -67,7 +68,7 @@
           // Pdev.DevMode has the required size, just copy to the global memory
           DeviceMode := GLobalAlloc(GHND, PDev.DevModeSize);
           try
    -        DevMode := PDeviceMode(GlobalLock(DeviceMode));
    +        DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(DeviceMode));
             try
               CopyMemory(DevMode, PDev.DevMode, Pdev.DevModeSize);
             finally
    @@ -107,7 +108,7 @@
     
               if lpp.hDevMode <> 0 then
               begin
    -            DevMode := PDeviceMode(GlobalLock(lpp.hDevMode));
    +            DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(lpp.hDevMode));
                 try
                   //Set the properties for the selected printer
                   PDev := TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
    @@ -131,12 +132,13 @@
     var
       lpp        : tagPD;
       PDev       : TPrinterDevice;
    -  DevMode    : PDeviceMode;
       DeviceMode : THandle;
       DevNames   : PDevNames;
       {$IFDEF USEUNICODE}
    +  DevMode    : PDeviceModeW;
       St         : PWidechar;
       {$ELSE}
    +  DevMode    : PDeviceMode;
       St         : PChar;
       {$ENDIF}
     begin
    @@ -156,7 +158,7 @@
           // Pdev.DevMode has the required size, just copy to the global memory
           DeviceMode := GlobalAlloc(GHND, PDev.DevModeSize);
           try
    -        DevMode := PDeviceMode(GlobalLock(DeviceMode));
    +        DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(DeviceMode));
             try
               CopyMemory(DevMode, Pdev.DevMode, Pdev.DevModeSize);
             finally
    @@ -192,7 +194,7 @@
     
               if lpp.hDevMode <> 0 then
               begin
    -            DevMode := PDeviceMode(GlobalLock(lpp.hDevMode));
    +            DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(lpp.hDevMode));
                 try
                   //Set the properties for the selected printer
                   PDev := TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
    @@ -217,12 +219,13 @@
     var
       lpp        : tagPD;
       PDev       : TPrinterDevice;
    -  DevMode    : PDeviceMode;
       DeviceMode : THandle;
       DevNames   : PDevNames;
       {$IFDEF USEUNICODE}
    +  DevMode    : PDeviceModeW;
       St         : PWidechar;
       {$ELSE}
    +  DevMode    : PDeviceMode;
       St         : PChar;
       {$ENDIF}
     begin
    @@ -260,7 +263,7 @@
           // Pdev.DevMode has the required size, just copy to the global memory
           DeviceMode := GlobalAlloc(GHND, PDEV.DevModeSize);
           try
    -        DevMode := PDeviceMode(GlobalLock(DeviceMode));
    +        DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(DeviceMode));
             try
               CopyMemory(DevMode, PDev.DevMode, PDev.DevModeSize);
             finally
    @@ -306,7 +309,7 @@
               PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
               if (lpp.hDevMode<>0) and (Pdev.DevMode<>nil) then
               begin
    -            DevMode:=PDeviceMode(GlobalLock(lpp.hDevMode));
    +            DevMode:={$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(lpp.hDevMode));
                 try
                   CopyMemory(PDev.DevMode,DevMode,PDev.DevModeSize);
                   
    
    patch (3,751 bytes)

Activities

Petr-K

2013-01-28 09:46

reporter  

patch (3,751 bytes)
Index: components/printers/win32/winprndialogs.inc
===================================================================
--- components/printers/win32/winprndialogs.inc	(revision 39991)
+++ components/printers/win32/winprndialogs.inc	(working copy)
@@ -41,12 +41,13 @@
 var
   lpp        : tagPSD;
   PDev       : TPrinterDevice;
-  DevMode    : PDeviceMode;
   DeviceMode : THandle;
   DevNames   : PDevNames;
   {$IFDEF USEUNICODE}
+  DevMode    : PDeviceModeW;
   St         : PWidechar;
   {$ELSE}
+  DevMode    : PDeviceMode;
   St         : PChar;
   {$ENDIF}
 begin
@@ -67,7 +68,7 @@
       // Pdev.DevMode has the required size, just copy to the global memory
       DeviceMode := GLobalAlloc(GHND, PDev.DevModeSize);
       try
-        DevMode := PDeviceMode(GlobalLock(DeviceMode));
+        DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(DeviceMode));
         try
           CopyMemory(DevMode, PDev.DevMode, Pdev.DevModeSize);
         finally
@@ -107,7 +108,7 @@
 
           if lpp.hDevMode <> 0 then
           begin
-            DevMode := PDeviceMode(GlobalLock(lpp.hDevMode));
+            DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(lpp.hDevMode));
             try
               //Set the properties for the selected printer
               PDev := TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
@@ -131,12 +132,13 @@
 var
   lpp        : tagPD;
   PDev       : TPrinterDevice;
-  DevMode    : PDeviceMode;
   DeviceMode : THandle;
   DevNames   : PDevNames;
   {$IFDEF USEUNICODE}
+  DevMode    : PDeviceModeW;
   St         : PWidechar;
   {$ELSE}
+  DevMode    : PDeviceMode;
   St         : PChar;
   {$ENDIF}
 begin
@@ -156,7 +158,7 @@
       // Pdev.DevMode has the required size, just copy to the global memory
       DeviceMode := GlobalAlloc(GHND, PDev.DevModeSize);
       try
-        DevMode := PDeviceMode(GlobalLock(DeviceMode));
+        DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(DeviceMode));
         try
           CopyMemory(DevMode, Pdev.DevMode, Pdev.DevModeSize);
         finally
@@ -192,7 +194,7 @@
 
           if lpp.hDevMode <> 0 then
           begin
-            DevMode := PDeviceMode(GlobalLock(lpp.hDevMode));
+            DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(lpp.hDevMode));
             try
               //Set the properties for the selected printer
               PDev := TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
@@ -217,12 +219,13 @@
 var
   lpp        : tagPD;
   PDev       : TPrinterDevice;
-  DevMode    : PDeviceMode;
   DeviceMode : THandle;
   DevNames   : PDevNames;
   {$IFDEF USEUNICODE}
+  DevMode    : PDeviceModeW;
   St         : PWidechar;
   {$ELSE}
+  DevMode    : PDeviceMode;
   St         : PChar;
   {$ENDIF}
 begin
@@ -260,7 +263,7 @@
       // Pdev.DevMode has the required size, just copy to the global memory
       DeviceMode := GlobalAlloc(GHND, PDEV.DevModeSize);
       try
-        DevMode := PDeviceMode(GlobalLock(DeviceMode));
+        DevMode := {$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(DeviceMode));
         try
           CopyMemory(DevMode, PDev.DevMode, PDev.DevModeSize);
         finally
@@ -306,7 +309,7 @@
           PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
           if (lpp.hDevMode<>0) and (Pdev.DevMode<>nil) then
           begin
-            DevMode:=PDeviceMode(GlobalLock(lpp.hDevMode));
+            DevMode:={$IFDEF USEUNICODE}PDeviceModeW{$ELSE}PDeviceMode{$ENDIF}(GlobalLock(lpp.hDevMode));
             try
               CopyMemory(PDev.DevMode,DevMode,PDev.DevModeSize);
               
patch (3,751 bytes)

Jesus Reyes

2013-01-29 09:23

developer   ~0065272

Applied, thanks.

Petr-K

2013-06-24 16:13

reporter   ~0068491

Works ok.

Issue History

Date Modified Username Field Change
2013-01-28 09:46 Petr-K New Issue
2013-01-28 09:46 Petr-K File Added: patch
2013-01-28 18:54 Jesus Reyes Assigned To => Jesus Reyes
2013-01-28 18:54 Jesus Reyes Status new => assigned
2013-01-29 09:23 Jesus Reyes Fixed in Revision => 40016
2013-01-29 09:23 Jesus Reyes LazTarget => 1.2
2013-01-29 09:23 Jesus Reyes Note Added: 0065272
2013-01-29 09:23 Jesus Reyes Status assigned => resolved
2013-01-29 09:23 Jesus Reyes Fixed in Version => 1.1 (SVN)
2013-01-29 09:23 Jesus Reyes Resolution open => fixed
2013-01-29 09:23 Jesus Reyes Target Version => 1.2.0
2013-06-24 16:13 Petr-K Note Added: 0068491
2013-06-24 16:13 Petr-K Status resolved => closed