Some printdlg enhancements

Huw D M Davies h.davies1 at physics.ox.ac.uk
Mon Feb 12 06:10:18 CST 2001


	Huw D M Davies <hdavies at codeweavers.com>
	Add an updown control to the copy count entry.
	Disable the collate button if no. of copies is 1.
	Add Landscape/Portrait icons.
	Get rid of the "Dummy Comment" line.
	Fix the English of some of the error messages.
-- 
   Dr. Huw D M Davies              | Clarendon Laboratory
   h.davies1 at physics.ox.ac.uk      | Parks Road
   Tel: +44 1865 272390            | Oxford OX1 3PU
   Fax: +44 1865 272400            | UK
-------------- next part --------------
Index: dlls/commdlg/cdlg_En.rc
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/cdlg_En.rc,v
retrieving revision 1.17
diff -u -r1.17 cdlg_En.rc
--- dlls/commdlg/cdlg_En.rc	2000/07/23 14:21:38	1.17
+++ dlls/commdlg/cdlg_En.rc	2001/02/12 11:49:20
@@ -335,24 +335,25 @@
     PD32_PRINT_TITLE       "Print"
 
     PD32_VALUE_UREADABLE                  "Unreadable Entry"
-    PD32_INVALID_PAGE_RANGE "This value lies not within Page range\n\
-Please enter a value between %d and %d"
-    PD32_FROM_NOT_ABOVE_TO                "The FROM entry cannot exceed TO:"
+    PD32_INVALID_PAGE_RANGE "This value does not lie within the page range.\n\
+Please enter a value between %d and %d."
+    PD32_FROM_NOT_ABOVE_TO                "The 'from' entry cannot exceed the \
+'to' entry."
     PD32_MARGINS_OVERLAP                  "Margins overlap or fall outside \
-Paper boundaries.\nPlease reenter margins"
-    PD32_NR_OF_COPIES_EMPTY               "The NumberOfCopies entry cannot \
-be empty"
-    PD32_TOO_LARGE_COPIES                 "This large amount of prints is not \
-supported by your printer.\nPlease enter a value between 1 and %d"
-    PD32_PRINT_ERROR                      "A printer error occurred"
-    PD32_NO_DEFAULT_PRINTER               "There is not default printer"
-    PD32_CANT_FIND_PRINTER                "Cannot find the printer"
-    PD32_OUT_OF_MEMORY                    "Out of memory"
-    PD32_GENERIC_ERROR                    "Some error occurred"
-    PD32_DRIVER_UNKNOWN                   "Unknown printer driver"
+Paper boundaries.\nPlease reenter margins."
+    PD32_NR_OF_COPIES_EMPTY               "The number of 'Number of copies' \
+value cannot be empty."
+    PD32_TOO_LARGE_COPIES                 "This large nmuber of copies is not \
+supported by your printer.\nPlease enter a value between 1 and %d."
+    PD32_PRINT_ERROR                      "A printer error occurred."
+    PD32_NO_DEFAULT_PRINTER               "There is not default printer."
+    PD32_CANT_FIND_PRINTER                "Cannot find the printer."
+    PD32_OUT_OF_MEMORY                    "Out of memory."
+    PD32_GENERIC_ERROR                    "Some error occurred."
+    PD32_DRIVER_UNKNOWN                   "Unknown printer driver."
 
     PD32_DEFAULT_PRINTER                  "Default Printer; "
-    PD32_NR_OF_DOCUMENTS_IN_QUEUE         "There are %d documents in queue"
+    PD32_NR_OF_DOCUMENTS_IN_QUEUE         "There are %d documents in the queue"
     PD32_PRINT_ALL_X_PAGES                "&All %d pages"
     PD32_MARGINS_IN_INCHES                "Margins [inches]"
     PD32_MARGINS_IN_MILIMETERS            "Margins [mm]"
Index: dlls/commdlg/printdlg.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/printdlg.c,v
retrieving revision 1.35
diff -u -r1.35 printdlg.c
--- dlls/commdlg/printdlg.c	2001/02/12 03:38:14	1.35
+++ dlls/commdlg/printdlg.c	2001/02/12 11:49:20
@@ -44,6 +44,7 @@
   HICON             hNoCollateIcon;  /* PrintDlg only */
   HICON             hPortraitIcon;   /* PrintSetupDlg only */
   HICON             hLandscapeIcon;  /* PrintSetupDlg only */
+  HWND              hwndUpDown;
 } PRINT_PTRA;
 
 /* Debugiging info */
@@ -76,6 +77,9 @@
   {-1, NULL}
 };
 
+/* Yes these constants are the same, but we're just copying win98 */
+#define UPDOWN_ID 0x270f
+#define MAX_COPIES 9999
 
 /***********************************************************************
  *    PRINTDLG_GetDefaultPrinterName
@@ -473,7 +477,8 @@
         SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pLocation);
     else
         SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pPortName);
-    SendDlgItemMessageA(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)pi->pComment);
+    SendDlgItemMessageA(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)(pi->pComment ?
+			pi->pComment : ""));
     return;
 }
 
@@ -584,10 +589,16 @@
 	}
 
 	/* nCopies */
-	if (lppd->hDevMode == 0)
-	    SetDlgItemInt(hDlg, edt3, lppd->nCopies, FALSE);
-	else
-	    SetDlgItemInt(hDlg, edt3, lpdm->dmCopies, FALSE);
+	{
+	  INT copies;
+	  if (lppd->hDevMode == 0)
+	      copies = lppd->nCopies;
+	  else
+	      copies = lpdm->dmCopies;
+	  if(copies == 0) copies = 1;
+	  else if(copies < 0) copies = MAX_COPIES;
+	  SetDlgItemInt(hDlg, edt3, copies, FALSE);
+	}
 
 	if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
 	  /* if printer doesn't support it: no nCopies */
@@ -605,6 +616,8 @@
             ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
 
     } else { /* PD_PRINTSETUP */
+      BOOL bPortrait = (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT);
+
       PRINTDLG_SetUpPaperComboBox(hDlg, cmb2,
 				  PrintStructures->lpPrinterInfo->pPrinterName,
 				  PrintStructures->lpPrinterInfo->pPortName,
@@ -613,9 +626,11 @@
 				  PrintStructures->lpPrinterInfo->pPrinterName,
 				  PrintStructures->lpPrinterInfo->pPortName,
 				  lpdm);
-      CheckRadioButton(hDlg, rad1, rad2,
-		       (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT) ?
-		       rad1: rad2);
+      CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
+      SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
+                          (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
+                                   PrintStructures->hLandscapeIcon));
+      
     }
 
     /* help button */
@@ -645,16 +660,22 @@
       LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0);
     PrintStructures->hNoCollateIcon = 
       LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0);
+
+    /* These can be done with LoadIcon */
+    PrintStructures->hPortraitIcon =
+      LoadIconA(COMDLG32_hInstance, "PD32_PORTRAIT");
+    PrintStructures->hLandscapeIcon =
+      LoadIconA(COMDLG32_hInstance, "PD32_LANDSCAPE");
+
     if(PrintStructures->hCollateIcon == 0 ||
-       PrintStructures->hNoCollateIcon == 0) {
+       PrintStructures->hNoCollateIcon == 0 ||
+       PrintStructures->hPortraitIcon == 0 ||
+       PrintStructures->hLandscapeIcon == 0) {
         ERR("no icon in resourcefile\n");
 	COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
 	EndDialog(hDlg, FALSE);
     }
 
-    /* load Paper Orientation ICON */
-    /* FIXME: not implemented yet */
-
     /*
      * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
      * must be registered and the Help button must be shown.
@@ -668,6 +689,15 @@
     } else
         PrintStructures->HelpMessageID = 0;
 
+    if(!(lppd->Flags &PD_PRINTSETUP)) {
+        PrintStructures->hwndUpDown =
+	  CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER |
+			      UDS_NOTHOUSANDS | UDS_ARROWKEYS |
+			      UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
+			      hDlg, UPDOWN_ID, COMDLG32_hInstance,
+			      GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
+    }
+
     /* FIXME: I allow more freedom than either Win95 or WinNT,
      *        which do not agree to what errors should be thrown or not
      *        in case nToPage or nFromPage is out-of-range.
@@ -857,6 +887,17 @@
 	        CheckRadioButton(hDlg, rad1, rad3, rad3);
 	}
         break;
+
+    case edt3:
+        if(HIWORD(wParam) == EN_CHANGE) {
+	    INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
+	    if(copies <= 1)
+	        EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
+	    else
+	        EnableWindow(GetDlgItem(hDlg, chx2), TRUE);
+	}
+	break;
+
      case psh2:                       /* Properties button */
        {
          HANDLE hPrinter;
@@ -904,6 +945,28 @@
       }
       break; 
     }
+    if(lppd->Flags & PD_PRINTSETUP) {
+        switch (LOWORD(wParam)) {
+	case rad1:                         /* orientation */
+	case rad2:
+	    if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
+	        if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {
+		    lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
+		    SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
+					(WPARAM)IMAGE_ICON,
+					(LPARAM)PrintStructures->hPortraitIcon);
+		}
+	    } else {
+	        if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {
+	            lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
+		    SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
+					(WPARAM)IMAGE_ICON,
+					(LPARAM)PrintStructures->hLandscapeIcon);
+		}
+	    }
+	    break;
+	}
+    }
     return FALSE;
 }    
 
@@ -945,8 +1008,10 @@
     case WM_DESTROY:
 	DestroyIcon(PrintStructures->hCollateIcon);
 	DestroyIcon(PrintStructures->hNoCollateIcon);
-    /* FIXME: don't forget to delete the paper orientation icons here! */
-
+        DestroyIcon(PrintStructures->hPortraitIcon);
+        DestroyIcon(PrintStructures->hLandscapeIcon);
+	if(PrintStructures->hwndUpDown)
+	    DestroyWindow(PrintStructures->hwndUpDown);
         return FALSE;
     }    
     return res;


More information about the wine-patches mailing list