View Issue Details

IDProjectCategoryView StatusLast Update
0014186LazarusOtherpublic2013-05-10 21:26
ReporterClaudio RomeroAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.27 (SVN)Product Build 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0014186: TPrintDialog.Title, doesn't show the title
DescriptionTitle property is published in TPrinterDialog, but not work.

TPrinterDialog is descendent from TCommonDialog.

Some relationship with http://bugs.freepascal.org/view.php?id=1740 (Merge Dialogs and PrintersDlgs) ??

Tested in Lazarus 0.9.27 svn 20917, fpc 2.3.1 svn 13383
in Windows XP SP3.
Tagsprinter
Fixed in Revision41082, 41116, 41117, 41118
LazTarget1.2
WidgetsetGTK 2, Win32/Win64, QT
Attached Files
  • printers_title.patch (3,189 bytes)
    Index: components/printers/win32/winprndialogs.inc
    ===================================================================
    --- components/printers/win32/winprndialogs.inc	(revision 20934)
    +++ components/printers/win32/winprndialogs.inc	(working copy)
    @@ -1,6 +1,5 @@
     {%MainUnit ../printersdlgs.pp}
     
    -function PrintHookProc(hdlg: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): PtrUInt; stdcall;
     
       // update from win32wsdialogs.pp
       procedure Reposition(ADialogWnd: Handle);
    @@ -29,12 +28,37 @@
         SetWindowPos(ADialogWnd, HWND_TOP, Left, Top, 0, 0, SWP_NOSIZE);
       end;
     
    +
    +
    +function PrintHookProc(hdlg: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): PtrUInt; stdcall;
    +var
    + lpp : PtagPD;
     begin
       if uiMsg = WM_INITDIALOG then
    +  begin
    +    lpp := PtagPD(lParam);
    +    if (lParam<>0) and (lpp^.lCustData<>0) then
    +      SetWindowText(hdlg,pChar(lpp^.lCustData));
         Reposition(hdlg);
    +  end;
       Result := 0;
     end;
     
    +function PageSetupHookProc(hdlg: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): PtrUInt; stdcall;
    +var
    + lpp : PtagPSD;
    +begin
    +  if uiMsg = WM_INITDIALOG then
    +  begin
    +    lpp := PtagPSD(lParam);
    +    if (lParam<>0) and (lpp^.lCustData<>0) then
    +      SetWindowText(hdlg,pChar(lpp^.lCustData));
    +    Reposition(hdlg);
    +  end;
    +  Result := 0;
    +end;
    +
    +
     { TPageSetupDialog }
     
     function TPageSetupDialog.Execute: Boolean;
    @@ -54,7 +78,10 @@
         with lpp do begin
           lStructSize:=SizeOf(lpp);
           hInstance:=LCLType.HInstance;
    -      lpfnPageSetupHook := @PrintHookProc;
    +      lpfnPageSetupHook := @PageSetupHookProc;
    +      if Title<>'' then lCustData := LPARAM(pChar(Utf8ToAnsi(Title)))
    +      else
    +      lCustData := 0;
           Flags := PSD_MARGINS or PSD_ENABLEPAGESETUPHOOK;
           hWndOwner:=Widgetset.AppHandle;
           rtMargin := fMargins;
    @@ -130,6 +157,9 @@
           lStructSize:=SizeOf(lpp);
           hInstance:=LCLType.HInstance;
           lpfnSetupHook := @PrintHookProc;
    +      if Title<>'' then lCustData := LPARAM(pChar(Utf8ToAnsi(Title)))
    +      else
    +      lCustData := 0;
           Flags:= PD_PRINTSETUP or PD_RETURNDC or PD_ENABLESETUPHOOK;
           hWndOwner:=Widgetset.AppHandle;
           PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
    @@ -203,6 +233,9 @@
           hInstance:=LCLType.HInstance;
           lpfnPrintHook := @PrintHookProc;
           lpfnSetupHook := @PrintHookProc;
    +      if Title<>'' then lCustData := LPARAM(pChar(Utf8ToAnsi(Title)))
    +      else
    +      lCustData := 0;
           Flags := PD_ENABLEPRINTHOOK or PD_ENABLESETUPHOOK;
           if not Printer.RawMode then
             Flags := Flags or PD_RETURNDC;
    Index: components/printers/win32/winutilprn.pas
    ===================================================================
    --- components/printers/win32/winutilprn.pas	(revision 20934)
    +++ components/printers/win32/winutilprn.pas	(working copy)
    @@ -66,6 +66,7 @@
       TFcntHook = function(Wnd: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): UINT_PTR; stdcall;
     
     
    +  PtagPSD = ^tagPSD;
       tagPSD= packed record
         lStructSize : DWORD;
         hWndOwner   : HWND;
    @@ -86,6 +87,8 @@
     
     
     
    +
    +  PtagPD = ^tagPD;
       tagPD=packed Record
         lStructSize  : DWORD;
         hWndOwner    : HWND;
    
    printers_title.patch (3,189 bytes)

Activities

2009-07-24 17:49

 

printers_title.patch (3,189 bytes)
Index: components/printers/win32/winprndialogs.inc
===================================================================
--- components/printers/win32/winprndialogs.inc	(revision 20934)
+++ components/printers/win32/winprndialogs.inc	(working copy)
@@ -1,6 +1,5 @@
 {%MainUnit ../printersdlgs.pp}
 
-function PrintHookProc(hdlg: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): PtrUInt; stdcall;
 
   // update from win32wsdialogs.pp
   procedure Reposition(ADialogWnd: Handle);
@@ -29,12 +28,37 @@
     SetWindowPos(ADialogWnd, HWND_TOP, Left, Top, 0, 0, SWP_NOSIZE);
   end;
 
+
+
+function PrintHookProc(hdlg: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): PtrUInt; stdcall;
+var
+ lpp : PtagPD;
 begin
   if uiMsg = WM_INITDIALOG then
+  begin
+    lpp := PtagPD(lParam);
+    if (lParam<>0) and (lpp^.lCustData<>0) then
+      SetWindowText(hdlg,pChar(lpp^.lCustData));
     Reposition(hdlg);
+  end;
   Result := 0;
 end;
 
+function PageSetupHookProc(hdlg: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): PtrUInt; stdcall;
+var
+ lpp : PtagPSD;
+begin
+  if uiMsg = WM_INITDIALOG then
+  begin
+    lpp := PtagPSD(lParam);
+    if (lParam<>0) and (lpp^.lCustData<>0) then
+      SetWindowText(hdlg,pChar(lpp^.lCustData));
+    Reposition(hdlg);
+  end;
+  Result := 0;
+end;
+
+
 { TPageSetupDialog }
 
 function TPageSetupDialog.Execute: Boolean;
@@ -54,7 +78,10 @@
     with lpp do begin
       lStructSize:=SizeOf(lpp);
       hInstance:=LCLType.HInstance;
-      lpfnPageSetupHook := @PrintHookProc;
+      lpfnPageSetupHook := @PageSetupHookProc;
+      if Title<>'' then lCustData := LPARAM(pChar(Utf8ToAnsi(Title)))
+      else
+      lCustData := 0;
       Flags := PSD_MARGINS or PSD_ENABLEPAGESETUPHOOK;
       hWndOwner:=Widgetset.AppHandle;
       rtMargin := fMargins;
@@ -130,6 +157,9 @@
       lStructSize:=SizeOf(lpp);
       hInstance:=LCLType.HInstance;
       lpfnSetupHook := @PrintHookProc;
+      if Title<>'' then lCustData := LPARAM(pChar(Utf8ToAnsi(Title)))
+      else
+      lCustData := 0;
       Flags:= PD_PRINTSETUP or PD_RETURNDC or PD_ENABLESETUPHOOK;
       hWndOwner:=Widgetset.AppHandle;
       PDev:=TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
@@ -203,6 +233,9 @@
       hInstance:=LCLType.HInstance;
       lpfnPrintHook := @PrintHookProc;
       lpfnSetupHook := @PrintHookProc;
+      if Title<>'' then lCustData := LPARAM(pChar(Utf8ToAnsi(Title)))
+      else
+      lCustData := 0;
       Flags := PD_ENABLEPRINTHOOK or PD_ENABLESETUPHOOK;
       if not Printer.RawMode then
         Flags := Flags or PD_RETURNDC;
Index: components/printers/win32/winutilprn.pas
===================================================================
--- components/printers/win32/winutilprn.pas	(revision 20934)
+++ components/printers/win32/winutilprn.pas	(working copy)
@@ -66,6 +66,7 @@
   TFcntHook = function(Wnd: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): UINT_PTR; stdcall;
 
 
+  PtagPSD = ^tagPSD;
   tagPSD= packed record
     lStructSize : DWORD;
     hWndOwner   : HWND;
@@ -86,6 +87,8 @@
 
 
 
+
+  PtagPD = ^tagPD;
   tagPD=packed Record
     lStructSize  : DWORD;
     hWndOwner    : HWND;
printers_title.patch (3,189 bytes)

Boguslaw Brandys

2009-07-24 17:50

developer   ~0029236

Attached patch printers_title.patch resolves problem under win32/64. this is partial solution as I don't know how it works under other platforms.

Claudio Romero

2009-07-25 00:49

reporter   ~0029238

Yes, in Slax Linux TPrintDialog.Title not work
I tested in Lazarus 0.9.27 GTK2 svn 20932 fpc 2.2.4

But your patch work fine under Windows 98, Windows 2000 SP4 and Windows XP sp3.
Thanks

Juha Manninen

2013-04-29 14:17

developer   ~0067267

There is a patch. I think it should be either accepted or rejected.

Jesus Reyes

2013-05-09 07:49

developer   ~0067600

Updated patch and applied.

Claudio Romero

2013-05-10 14:27

reporter   ~0067628

Last edited: 2013-05-10 14:28

View 2 revisions

Reopen issue because this patch only work for Windows.
Under linux not work.

Retest under
Lazarus 1.1 svn 41103 fpc 2.6 64 bits.

PrintDialog1.Title:='Hello lazarus';
PrintDialog1.Execute;

Regards

PD: Please change the Widgetset to Linux Gtk/Qt

Claudio Romero

2013-05-10 21:26

reporter   ~0067631

Tested Under Linux 64 bits Qt/Gtk2

Work Fine

Thanks !!

Issue History

Date Modified Username Field Change
2009-07-24 03:09 Claudio Romero New Issue
2009-07-24 03:09 Claudio Romero Widgetset => Win32/Win64
2009-07-24 17:49 Boguslaw Brandys LazTarget => -
2009-07-24 17:49 Boguslaw Brandys Assigned To => Jesus Reyes
2009-07-24 17:49 Boguslaw Brandys Status new => acknowledged
2009-07-24 17:49 Boguslaw Brandys File Added: printers_title.patch
2009-07-24 17:50 Boguslaw Brandys Note Added: 0029236
2009-07-25 00:49 Claudio Romero Note Added: 0029238
2010-03-15 04:06 Jesus Reyes Tag Attached: printer
2013-04-29 14:17 Juha Manninen Note Added: 0067267
2013-05-09 07:49 Jesus Reyes Fixed in Revision => 41082
2013-05-09 07:49 Jesus Reyes LazTarget - => 1.2
2013-05-09 07:49 Jesus Reyes Note Added: 0067600
2013-05-09 07:49 Jesus Reyes Status acknowledged => resolved
2013-05-09 07:49 Jesus Reyes Fixed in Version => 1.1 (SVN)
2013-05-09 07:49 Jesus Reyes Resolution open => fixed
2013-05-09 07:49 Jesus Reyes Target Version => 1.2.0
2013-05-10 14:27 Claudio Romero Note Added: 0067628
2013-05-10 14:27 Claudio Romero Status resolved => assigned
2013-05-10 14:27 Claudio Romero Resolution fixed => reopened
2013-05-10 14:28 Claudio Romero Note Edited: 0067628 View Revisions
2013-05-10 18:08 Juha Manninen Widgetset Win32/Win64 => GTK 2, Win32/Win64, QT
2013-05-10 20:41 Jesus Reyes Fixed in Revision 41082 => 41082, 41116, 41117, 41118
2013-05-10 20:41 Jesus Reyes Status assigned => resolved
2013-05-10 20:41 Jesus Reyes Resolution reopened => fixed
2013-05-10 21:26 Claudio Romero Note Added: 0067631
2013-05-10 21:26 Claudio Romero Status resolved => closed