Add PrintSetup dialog and support for hooks and templates.
Move 16 bit api definitions out of commdlg.h to cdlg.h

diff --git a/dlls/commdlg/cdlg.h b/dlls/commdlg/cdlg.h
index 8e8fdfa..4b1f33a 100644
--- a/dlls/commdlg/cdlg.h
+++ b/dlls/commdlg/cdlg.h
@@ -116,5 +116,132 @@
 extern DWORD (WINAPI *COMDLG32_PathRemoveFileSpecA)(LPSTR fn);
 extern BOOL (WINAPI *COMDLG32_PathMatchSpecW)(LPCWSTR x, LPCWSTR y);
 extern LPSTR (WINAPI *COMDLG32_PathAddBackslashA)(LPSTR path);
-#endif
+
+
+extern BOOL  WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType);
+extern BOOL  WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType);
+
+/* 16 bit api */
+
+#include "pshpack1.h"
+
+typedef UINT16 (CALLBACK *LPOFNHOOKPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
+
+typedef struct {
+	DWORD		lStructSize;
+	HWND16		hwndOwner;
+	HINSTANCE16	hInstance;
+	SEGPTR	        lpstrFilter;
+	SEGPTR          lpstrCustomFilter;
+	DWORD		nMaxCustFilter;
+	DWORD		nFilterIndex;
+	SEGPTR          lpstrFile;
+	DWORD		nMaxFile;
+	SEGPTR		lpstrFileTitle;
+	DWORD		nMaxFileTitle;
+	SEGPTR 		lpstrInitialDir;
+	SEGPTR 		lpstrTitle;
+	DWORD		Flags;
+	UINT16		nFileOffset;
+	UINT16		nFileExtension;
+	SEGPTR		lpstrDefExt;
+	LPARAM 		lCustData;
+	LPOFNHOOKPROC16 lpfnHook;
+	SEGPTR 		lpTemplateName;
+}   OPENFILENAME16,*LPOPENFILENAME16;
+
+typedef UINT16 (CALLBACK *LPCCHOOKPROC16) (HWND16, UINT16, WPARAM16, LPARAM);
+
+typedef struct {
+	DWORD		lStructSize;
+	HWND16		hwndOwner;
+	HWND16		hInstance;
+	COLORREF	rgbResult;
+	COLORREF       *lpCustColors;
+	DWORD 		Flags;
+	LPARAM		lCustData;
+        LPCCHOOKPROC16  lpfnHook;
+	SEGPTR 		lpTemplateName;
+} CHOOSECOLOR16;
+typedef CHOOSECOLOR16 *LPCHOOSECOLOR16;
+
+typedef UINT16 (CALLBACK *LPFRHOOKPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
+typedef struct {
+	DWORD		lStructSize; 			/* size of this struct 0x20 */
+	HWND16		hwndOwner; 				/* handle to owner's window */
+	HINSTANCE16	hInstance; 				/* instance handle of.EXE that  */
+										/*	contains cust. dlg. template */
+	DWORD		Flags;                  /* one or more of the FR_?? */
+	SEGPTR		lpstrFindWhat;          /* ptr. to search string    */
+	SEGPTR		lpstrReplaceWith;       /* ptr. to replace string   */
+	UINT16		wFindWhatLen;           /* size of find buffer      */
+	UINT16 		wReplaceWithLen;        /* size of replace buffer   */
+	LPARAM 		lCustData;              /* data passed to hook fn.  */
+        LPFRHOOKPROC16  lpfnHook;
+	SEGPTR 		lpTemplateName;         /* custom template name     */
+} FINDREPLACE16, *LPFINDREPLACE16;
+
+typedef UINT16 (CALLBACK *LPCFHOOKPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
+typedef struct 
+{
+	DWORD			lStructSize;
+	HWND16			hwndOwner;          /* caller's window handle   */
+	HDC16          	        hDC;                /* printer DC/IC or NULL    */
+	SEGPTR                  lpLogFont;          /* ptr. to a LOGFONT struct */
+	short			iPointSize;         /* 10 * size in points of selected font */
+	DWORD			Flags;  /* enum. type flags         */
+	COLORREF		rgbColors;          /* returned text color      */
+	LPARAM	                lCustData;          /* data passed to hook fn.  */
+	LPCFHOOKPROC16          lpfnHook;
+	SEGPTR			lpTemplateName;     /* custom template name     */
+	HINSTANCE16		hInstance;          /* instance handle of.EXE that   */
+							/* contains cust. dlg. template  */
+	SEGPTR			lpszStyle;  /* return the style field here   */
+							/* must be LF_FACESIZE or bigger */
+	UINT16			nFontType;          	/* same value reported to the    */
+						    	/* EnumFonts callback with the   */
+							/* extra FONTTYPE_ bits added    */
+	short			nSizeMin;   /* minimum pt size allowed & */
+	short			nSizeMax;   /* max pt size allowed if    */
+							/* CF_LIMITSIZE is used      */
+} CHOOSEFONT16, *LPCHOOSEFONT16;
+
+
+typedef UINT16 (CALLBACK *LPPRINTHOOKPROC16) (HWND16, UINT16, WPARAM16, LPARAM);
+typedef UINT16 (CALLBACK *LPSETUPHOOKPROC16) (HWND16, UINT16, WPARAM16, LPARAM);
+typedef struct
+{
+    DWORD            lStructSize;
+    HWND16           hwndOwner;
+    HGLOBAL16        hDevMode;
+    HGLOBAL16        hDevNames;
+    HDC16            hDC;
+    DWORD            Flags;
+    WORD             nFromPage;
+    WORD             nToPage;
+    WORD             nMinPage;
+    WORD             nMaxPage;
+    WORD             nCopies;
+    HINSTANCE16      hInstance;
+    LPARAM           lCustData;
+    LPPRINTHOOKPROC16 lpfnPrintHook;
+    LPSETUPHOOKPROC16 lpfnSetupHook;
+    SEGPTR           lpPrintTemplateName;
+    SEGPTR           lpSetupTemplateName;
+    HGLOBAL16        hPrintTemplate;
+    HGLOBAL16        hSetupTemplate;
+} PRINTDLG16, *LPPRINTDLG16;
+
+BOOL16  WINAPI ChooseColor16(LPCHOOSECOLOR16 lpChCol);
+HWND16  WINAPI FindText16( SEGPTR find);
+INT16   WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf);
+BOOL16  WINAPI GetOpenFileName16(SEGPTR ofn);
+BOOL16  WINAPI GetSaveFileName16(SEGPTR ofn);
+BOOL16  WINAPI PrintDlg16( LPPRINTDLG16 print);
+HWND16  WINAPI ReplaceText16( SEGPTR find);
+BOOL16  WINAPI ChooseFont16(LPCHOOSEFONT16);
+
+#include "poppack.h"
+
+#endif /* _WINE_DLL_CDLG_H */
 
diff --git a/dlls/commdlg/cdlg_En.rc b/dlls/commdlg/cdlg_En.rc
index 8bca5cb..f8e64ae 100644
--- a/dlls/commdlg/cdlg_En.rc
+++ b/dlls/commdlg/cdlg_En.rc
@@ -198,7 +198,7 @@
 PRINT32 DIALOG LOADONCALL MOVEABLE DISCARDABLE  32, 32, 288, 186
 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
       DS_CONTEXTHELP | DS_3DLOOK
-CAPTION "Print32"
+CAPTION "Print"
 FONT 8, "Helv"
 {
     DEFPUSHBUTTON   "OK",     IDOK,     180,164, 48,14, WS_GROUP | BS_DEFPUSHBUTTON
@@ -238,7 +238,7 @@
 PRINT32_SETUP DIALOG LOADONCALL MOVEABLE DISCARDABLE  32, 32, 288, 178
 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
       DS_CONTEXTHELP | DS_3DLOOK
-CAPTION "Print32 Setup"
+CAPTION "Print Setup"
 FONT 8, "Helv"
 BEGIN
     DEFPUSHBUTTON   "OK",IDOK,180,156,48,14,WS_GROUP
diff --git a/dlls/commdlg/comdlg32.spec b/dlls/commdlg/comdlg32.spec
index 375eadd..821fa8c 100644
--- a/dlls/commdlg/comdlg32.spec
+++ b/dlls/commdlg/comdlg32.spec
@@ -2,6 +2,7 @@
 type	win32
 init	COMDLG32_DllEntryPoint
 rsrc	comdlg32
+import   winspool.drv
 
 import	shell32.dll
 import	comctl32.dll
@@ -23,7 +24,7 @@
 13 stdcall GetSaveFileNameW(ptr) GetSaveFileNameW
 14 stub LoadAlterBitmap
 15 stdcall PageSetupDlgA(ptr) PageSetupDlgA
-16 stub PageSetupDlgW
+16 stdcall PageSetupDlgW(ptr) PageSetupDlgW
 17 stdcall PrintDlgA(ptr) PrintDlgA
 18 stdcall PrintDlgW(ptr) PrintDlgW
 19 stdcall ReplaceTextA(ptr) ReplaceTextA
diff --git a/dlls/commdlg/filedlg.c b/dlls/commdlg/filedlg.c
index b788edb..befb863 100644
--- a/dlls/commdlg/filedlg.c
+++ b/dlls/commdlg/filedlg.c
@@ -46,6 +46,12 @@
  * Windows 3.1 OpenFileName/SaveFileName dialog
  *
  */
+
+LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
+				 LPARAM lParam);
+LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
+				 LPARAM lParam);
+
 /***********************************************************************
  * 				FileDlg_Init			[internal]
  */
diff --git a/dlls/commdlg/finddlg.c b/dlls/commdlg/finddlg.c
index 8b8698a..a8ad9b2 100644
--- a/dlls/commdlg/finddlg.c
+++ b/dlls/commdlg/finddlg.c
@@ -23,6 +23,11 @@
 
 #include "cdlg.h"
 
+LRESULT WINAPI FindTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
+                                 LPARAM lParam);
+LRESULT WINAPI ReplaceTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
+				    LPARAM lParam);
+
 /***********************************************************************
  *           FindTextDlgProc [internal]
  *
diff --git a/dlls/commdlg/fontdlg.c b/dlls/commdlg/fontdlg.c
index d09d228..7660d60 100644
--- a/dlls/commdlg/fontdlg.c
+++ b/dlls/commdlg/fontdlg.c
@@ -32,6 +32,10 @@
 static HBITMAP16 hBitmapTT = 0; 
 
 
+LRESULT WINAPI FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
+				  LPARAM lParam);
+LRESULT WINAPI FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
+				  LPARAM lParam);
 
 
 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONTA chf32a)
diff --git a/dlls/commdlg/printdlg.c b/dlls/commdlg/printdlg.c
index fdcac59..5fe6558 100644
--- a/dlls/commdlg/printdlg.c
+++ b/dlls/commdlg/printdlg.c
@@ -4,8 +4,8 @@
  * Copyright 1994 Martin Ayotte
  * Copyright 1996 Albrecht Kleine
  * Copyright 1999 Klaas van Gend
+ * Copyright 2000 Huw D M Davies
  */
-
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -13,11 +13,11 @@
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
-#include "wine/winbase16.h"
+#include "wine/wingdi16.h"
+#include "winuser.h"
 #include "wine/winuser16.h"
 #include "ldt.h"
 #include "commdlg.h"
-#include "dialog.h"
 #include "dlgs.h"
 #include "module.h"
 #include "debugtools.h"
@@ -37,11 +37,9 @@
  */
 typedef struct  
 {
-  LPPRINTER_INFO_2A lpPrinterInfo;
-  UINT              CurrentPrinter;  /* used as lpPrinterInfo[CurrentPrinter] */
-  UINT              DefaultPrinter;  /* used as lpPrinterInfo[DefaultPrinter] */
-  DWORD             NrOfPrinterInfoEntries;
+  LPDEVMODEA        lpDevMode;
   LPPRINTDLGA       lpPrintDlg;
+  LPPRINTER_INFO_2A lpPrinterInfo;
   UINT              HelpMessageID;
   HICON             hCollateIcon;    /* PrintDlg only */
   HICON             hNoCollateIcon;  /* PrintDlg only */
@@ -49,73 +47,817 @@
   HICON             hLandscapeIcon;  /* PrintSetupDlg only */
 } PRINT_PTRA;
 
-
-/* prototypes */
-static BOOL PRINTDLG_ValidateAndDuplicateSettings(HWND hDlg, 
-						  PRINT_PTRA* PrintStructures);
-
-LRESULT WINAPI PrintSetupDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
-                                    LPARAM lParam);
+/* Debugiging info */
+static struct pd_flags {
+  DWORD flag;
+  LPSTR name;
+} pd_flags[] = {
+  {PD_SELECTION, "PD_SELECTION "},
+  {PD_PAGENUMS, "PD_PAGENUMS "},
+  {PD_NOSELECTION, "PD_NOSELECTION "},
+  {PD_NOPAGENUMS, "PD_NOPAGENUMS "},
+  {PD_COLLATE, "PD_COLLATE "},
+  {PD_PRINTTOFILE, "PD_PRINTTOFILE "},
+  {PD_PRINTSETUP, "PD_PRINTSETUP "},
+  {PD_NOWARNING, "PD_NOWARNING "},
+  {PD_RETURNDC, "PD_RETURNDC "},
+  {PD_RETURNIC, "PD_RETURNIC "},
+  {PD_RETURNDEFAULT, "PD_RETURNDEFAULT "},
+  {PD_SHOWHELP, "PD_SHOWHELP "},
+  {PD_ENABLEPRINTHOOK, "PD_ENABLEPRINTHOOK "},
+  {PD_ENABLESETUPHOOK, "PD_ENABLESETUPHOOK "},
+  {PD_ENABLEPRINTTEMPLATE, "PD_ENABLEPRINTTEMPLATE "},
+  {PD_ENABLESETUPTEMPLATE, "PD_ENABLESETUPTEMPLATE "},
+  {PD_ENABLEPRINTTEMPLATEHANDLE, "PD_ENABLEPRINTTEMPLATEHANDLE "},
+  {PD_ENABLESETUPTEMPLATEHANDLE, "PD_ENABLESETUPTEMPLATEHANDLE "},
+  {PD_USEDEVMODECOPIES, "PD_USEDEVMODECOPIES[ANDCOLLATE] "},
+  {PD_DISABLEPRINTTOFILE, "PD_DISABLEPRINTTOFILE "},
+  {PD_HIDEPRINTTOFILE, "PD_HIDEPRINTTOFILE "},
+  {PD_NONETWORKBUTTON, "PD_NONETWORKBUTTON "},
+  {-1, NULL}
+};
 
 
 /***********************************************************************
- *           PrintDlg16   (COMMDLG.20)
- * 
- *  Displays the the PRINT dialog box, which enables the user to specify
- *  specific properties of the print job.
+ *    PRINTDLG_GetDefaultPrinterName
  *
- * RETURNS
- *  nonzero if the user pressed the OK button
- *  zero    if the user cancelled the window or an error occurred
+ * Returns the default printer name in buf.
+ * Even under WinNT/2000 default printer is retrieved via GetProfileString - 
+ * these entries are mapped somewhere in the registry rather than win.ini.
  *
- * BUGS
- *  * calls up to the 32-bit versions of the Dialogs, which look different
- *  * Customizing is *not* implemented.
+ * Returns TRUE on success else FALSE
  */
-BOOL16 WINAPI PrintDlg16( LPPRINTDLG16 lpPrint )
+static BOOL PRINTDLG_GetDefaultPrinterName(LPSTR buf, DWORD len)
 {
-    PRINTDLGA Print32;
-    BOOL16 ret;
+    char *ptr;
 
-    memset(&Print32, 0, sizeof(Print32));
-    Print32.lStructSize = sizeof(Print32);
-    Print32.hwndOwner   = lpPrint->hwndOwner;
-    Print32.hDevMode    = lpPrint->hDevMode;
-    Print32.hDevNames   = lpPrint->hDevNames;
-    Print32.Flags       = lpPrint->Flags;
-    Print32.nFromPage   = lpPrint->nFromPage;
-    Print32.nToPage     = lpPrint->nToPage;
-    Print32.nMinPage    = lpPrint->nMinPage;
-    Print32.nMaxPage    = lpPrint->nMaxPage;
-    Print32.nCopies     = lpPrint->nCopies;
-    Print32.hInstance   = lpPrint->hInstance;
-    Print32.lCustData   = lpPrint->lCustData;
-    if(lpPrint->lpfnPrintHook) {
-        FIXME("Need to allocate thunk\n");
-/*        Print32.lpfnPrintHook = lpPrint->lpfnPrintHook;*/
-    }
-    if(lpPrint->lpfnSetupHook) {
-        FIXME("Need to allocate thunk\n");
-/*	Print32.lpfnSetupHook = lpPrint->lpfnSetupHook;*/
-    }
-    Print32.lpPrintTemplateName = PTR_SEG_TO_LIN(lpPrint->lpPrintTemplateName);
-    Print32.lpSetupTemplateName = PTR_SEG_TO_LIN(lpPrint->lpSetupTemplateName);
-    Print32.hPrintTemplate = lpPrint->hPrintTemplate;
-    Print32.hSetupTemplate = lpPrint->hSetupTemplate;
-
-    ret = PrintDlgA(&Print32);
-
-    lpPrint->hDevMode  = Print32.hDevMode;
-    lpPrint->hDevNames = Print32.hDevNames;
-    lpPrint->hDC       = Print32.hDC;
-    lpPrint->Flags     = Print32.Flags;
-    lpPrint->nFromPage = Print32.nFromPage;
-    lpPrint->nToPage   = Print32.nToPage;
-    lpPrint->nCopies   = Print32.nCopies;
-
-    return ret;
+    if(!GetProfileStringA("windows", "device", "", buf, len))
+	return FALSE;
+    if((ptr = strchr(buf, ',')) == NULL)
+	return FALSE;
+    *ptr = '\0';
+    return TRUE;
 }
 
+/***********************************************************************
+ *    PRINTDLG_OpenDefaultPrinter
+ *
+ * Returns a winspool printer handle to the default printer in *hprn
+ * Caller must call ClosePrinter on the handle
+ *
+ * Returns TRUE on success else FALSE
+ */
+static BOOL PRINTDLG_OpenDefaultPrinter(HANDLE *hprn)
+{
+    char buf[260];
+    if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf)))
+        return FALSE;
+    return OpenPrinterA(buf, hprn, NULL);
+}
+
+/***********************************************************************
+ *    PRINTDLG_SetUpPrinterListCombo
+ *
+ * Initializes printer list combox.
+ * hDlg:  HWND of dialog
+ * id:    Control id of combo
+ * name:  Name of printer to select
+ *
+ * Initializes combo with list of available printers.  Selects printer 'name'
+ * If name is NULL or does not exist select the default printer.
+ *
+ * Returns number of printers added to list.
+ */
+static INT PRINTDLG_SetUpPrinterListCombo(HWND hDlg, UINT id, LPCSTR name)
+{
+    DWORD needed, num;
+    INT i;
+    LPPRINTER_INFO_2A pi;
+    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
+    pi = HeapAlloc(GetProcessHeap(), 0, needed);
+    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 
+		  &num);
+
+    for(i = 0; i < num; i++) {
+        SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0,
+			    (LPARAM)pi[i].pPrinterName );
+    }
+    HeapFree(GetProcessHeap(), 0, pi);
+    if(!name ||
+       (i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1,
+				(LPARAM)name)) == CB_ERR) {
+
+        char buf[260];
+        TRACE("Can't find '%s' in printer list so trying to find default\n",
+	      name);
+	if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf)))
+	    return num;
+	i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
+	if(i == CB_ERR)
+	    TRACE("Can't find default printer in printer list\n");
+    }
+    SendDlgItemMessageA(hDlg, id, CB_SETCURSEL, i, 0);
+    return num;
+}
+
+/***********************************************************************
+ *             PRINTDLG_CreateDevNames          [internal]
+ *
+ *
+ *   creates a DevNames structure.
+ *
+ *  (NB. when we handle unicode the offsets will be in wchars).
+ */
+static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 
+				    char* DeviceName, char* OutputPort)
+{
+    long size;
+    char*   pDevNamesSpace;
+    char*   pTempPtr;
+    LPDEVNAMES lpDevNames;
+    char buf[260];
+
+    size = strlen(DeviceDriverName) + 1
+            + strlen(DeviceName) + 1
+            + strlen(OutputPort) + 1
+            + sizeof(DEVNAMES);
+            
+    if(*hmem)
+        *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
+    else
+        *hmem = GlobalAlloc(GMEM_MOVEABLE, size);
+    if (*hmem == 0)
+        return FALSE;
+
+    pDevNamesSpace = GlobalLock(*hmem);
+    lpDevNames = (LPDEVNAMES) pDevNamesSpace;
+
+    pTempPtr = pDevNamesSpace + sizeof(DEVNAMES);
+    strcpy(pTempPtr, DeviceDriverName);
+    lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace;
+
+    pTempPtr += strlen(DeviceDriverName) + 1;
+    strcpy(pTempPtr, DeviceName);
+    lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
+        
+    pTempPtr += strlen(DeviceName) + 1;
+    strcpy(pTempPtr, OutputPort);
+    lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
+
+    PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf));
+    lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0;
+    GlobalUnlock(*hmem);
+    return TRUE;
+}
+
+/***********************************************************************
+ *             PRINTDLG_UpdatePrintDlg          [internal]
+ *
+ *
+ *   updates the PrintDlg structure for returnvalues.
+ *      
+ * RETURNS
+ *   FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
+ *   TRUE  if succesful.
+ */
+static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg, 
+				    PRINT_PTRA* PrintStructures)
+{
+    LPPRINTDLGA       lppd = PrintStructures->lpPrintDlg;
+    PDEVMODEA         lpdm = PrintStructures->lpDevMode;
+    LPPRINTER_INFO_2A pi = PrintStructures->lpPrinterInfo;
+
+
+    if(!lpdm) return FALSE;
+
+
+    if(!(lppd->Flags & PD_PRINTSETUP)) {
+        /* check whether nFromPage and nToPage are within range defined by
+	 * nMinPage and nMaxPage
+	 */
+        if (IsDlgButtonChecked(hDlg, rad3) == BST_CHECKED) { /* Pages */
+	    WORD nToPage;
+	    WORD nFromPage;
+	    nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
+	    nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
+	    if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
+		nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
+	        char resourcestr[256];
+		char resultstr[256];
+		LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, 
+			    resourcestr, 255);
+		sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
+		LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE, 
+			    resourcestr, 255);
+		MessageBoxA(hDlg, resultstr, resourcestr,
+			    MB_OK | MB_ICONWARNING);
+		return FALSE;
+	    }
+	    lppd->nFromPage = nFromPage;
+	    lppd->nToPage   = nToPage;
+	}
+
+	if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
+	    lppd->Flags |= PD_PRINTTOFILE;
+	    pi->pPortName = "FILE:";
+	}
+
+	if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */
+	    FIXME("Collate lppd not yet implemented as output\n");
+	}
+
+	/* set PD_Collate and nCopies */
+	if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
+	  /*  The application doesn't support multiple copies or collate...
+	   */
+	    lppd->Flags &= ~PD_COLLATE;
+	    lppd->nCopies = 1;
+	  /* if the printer driver supports it... store info there
+	   * otherwise no collate & multiple copies !
+	   */
+	    if (lpdm->dmFields & DM_COLLATE)
+	        lpdm->dmCollate = 
+		  (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED);
+	    if (lpdm->dmFields & DM_COPIES)
+	        lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
+	} else {
+	    if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
+	        lppd->Flags |= PD_COLLATE;
+            else
+               lppd->Flags &= ~PD_COLLATE;
+            lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
+	}
+    }
+    return TRUE;
+}
+
+
+/************************************************************************
+ * PRINTDLG_SetUpPaperComboBox
+ *
+ * Initialize either the papersize or inputslot combos of the Printer Setup
+ * dialog.  We store the associated word (eg DMPAPER_A4) as the item data.
+ * We also try to re-select the old selection.
+ */
+static BOOL PRINTDLG_SetUpPaperComboBox(HWND hDlg,
+					int   nIDComboBox,
+					char* PrinterName, 
+					char* PortName,
+					LPDEVMODEA dm)
+{
+    int     i;
+    DWORD   NrOfEntries;
+    char*   Names;
+    WORD*   Words;
+    DWORD   Sel;
+    WORD    oldWord = 0;
+    int     NamesSize;
+    int     fwCapability_Names;
+    int     fwCapability_Words;
+    
+    TRACE(" Printer: %s, ComboID: %d\n",PrinterName,nIDComboBox);
+    
+    /* query the dialog box for the current selected value */
+    Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
+    if(Sel != CB_ERR) {
+        oldWord = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, Sel,
+				      0);
+    }
+
+    if (nIDComboBox == cmb2) {
+         NamesSize          = 64;
+         fwCapability_Names = DC_PAPERNAMES;
+         fwCapability_Words = DC_PAPERS;
+    } else {
+         nIDComboBox        = cmb3;
+         NamesSize          = 24;
+         fwCapability_Names = DC_BINNAMES;
+         fwCapability_Words = DC_BINS;
+    }
+    
+    /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 
+     * paper settings. As Wine doesn't allow VXDs, this results in a crash.
+     */
+    WARN(" if your printer driver uses VXDs, expect a crash now!\n");
+    NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
+                                      fwCapability_Names, NULL, dm);
+    if (NrOfEntries == 0)
+         WARN("no Name Entries found!\n");
+
+    if(DeviceCapabilitiesA(PrinterName, PortName, fwCapability_Words, NULL, dm)
+       != NrOfEntries) {
+        ERR("Number of caps is different\n");
+	NrOfEntries = 0;
+    }
+
+    Names = HeapAlloc(GetProcessHeap(),0, NrOfEntries*NamesSize);
+    Words = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(WORD));
+    NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
+                                      fwCapability_Names, Names, dm);
+    NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
+				      fwCapability_Words, (LPSTR)Words, dm);
+
+    /* reset any current content in the combobox */
+    SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
+    
+    /* store new content */
+    for (i = 0; i < NrOfEntries; i++) {
+        DWORD pos = SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0,
+					(LPARAM)(&Names[i*NamesSize]) );
+	SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos, 
+			    Words[i]);
+    }
+
+    /* Look for old selection - can't do this is previous loop since
+       item order will change as more items are added */
+    Sel = 0;
+    for (i = 0; i < NrOfEntries; i++) {
+        if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
+	   oldWord) {
+	    Sel = i;
+	    break;
+	}
+    }
+    SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
+
+    HeapFree(GetProcessHeap(),0,Words);
+    HeapFree(GetProcessHeap(),0,Names);
+    return TRUE;
+}
+
+/***********************************************************************
+ *               PRINTDLG_UpdatePrinterInfoTexts               [internal]
+ */
+static void PRINTDLG_UpdatePrinterInfoTexts(HWND hDlg, LPPRINTER_INFO_2A pi)
+{
+    char   StatusMsg[256];
+    char   ResourceString[256];
+    int    i;
+
+    /* Status Message */
+    StatusMsg[0]='\0';
+
+    /* add all status messages */
+    for (i = 0; i < 25; i++) {
+        if (pi->Status & (1<<i)) {
+	    LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 
+			ResourceString, 255);
+	    strcat(StatusMsg,ResourceString);
+        }
+    }
+    /* append "ready" */
+    /* FIXME: status==ready must only be appended if really so. 
+              but how to detect? */
+    LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 
+		ResourceString, 255);
+    strcat(StatusMsg,ResourceString);
+  
+    SendDlgItemMessageA(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg);
+
+    /* set all other printer info texts */
+    SendDlgItemMessageA(hDlg, stc11, WM_SETTEXT, 0, (LPARAM)pi->pDriverName);
+    if (pi->pLocation != NULL && pi->pLocation[0] != '\0')
+        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);
+    return;
+}
+
+/*******************************************************************
+ *
+ *                 PRINTDLG_ChangePrinter
+ *
+ */
+static BOOL PRINTDLG_ChangePrinter(HWND hDlg, char *name,
+				   PRINT_PTRA *PrintStructures)
+{
+    LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
+    LPDEVMODEA lpdm = NULL;
+    LONG dmSize;
+    DWORD needed;
+    HANDLE hprn;
+
+    if(PrintStructures->lpPrinterInfo)
+        HeapFree(GetProcessHeap(),0, PrintStructures->lpPrinterInfo);
+    if(!OpenPrinterA(name, &hprn, NULL)) {
+        ERR("Can't open printer %s\n", name);
+	return FALSE;
+    }
+    GetPrinterA(hprn, 2, NULL, 0, &needed);
+    PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed);
+    GetPrinterA(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
+		&needed);
+    ClosePrinter(hprn);
+
+    PRINTDLG_UpdatePrinterInfoTexts(hDlg, PrintStructures->lpPrinterInfo);
+
+    if(PrintStructures->lpDevMode) {
+        HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
+	PrintStructures->lpDevMode = NULL;
+    }
+
+    dmSize = DocumentPropertiesA(0, 0, name, NULL, NULL, 0);
+    if(dmSize == -1) {
+        ERR("DocumentProperties fails on %s\n", debugstr_a(name));
+	return FALSE;
+    }
+    PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
+    dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL,
+				 DM_OUT_BUFFER);
+    if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
+			  !strcmp(lpdm->dmDeviceName,
+				  PrintStructures->lpDevMode->dmDeviceName)) {
+      /* Supplied devicemode matches current printer so try to use it */
+        DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm,
+			    DM_OUT_BUFFER | DM_IN_BUFFER);
+    }
+    if(lpdm)
+        GlobalUnlock(lppd->hDevMode);
+
+    lpdm = PrintStructures->lpDevMode;  /* use this as a shortcut */
+
+    if(!(lppd->Flags & PD_PRINTSETUP)) {
+      /* Print range (All/Range/Selection) */
+        SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
+	SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
+	CheckRadioButton(hDlg, rad1, rad3, rad1);		/* default */
+	if (lppd->Flags & PD_NOSELECTION)
+	    EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
+	else
+	    if (lppd->Flags & PD_SELECTION)
+	        CheckRadioButton(hDlg, rad1, rad3, rad2);
+	if (lppd->Flags & PD_NOPAGENUMS) {
+	    EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
+	    EnableWindow(GetDlgItem(hDlg, stc2),FALSE);
+	    EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
+	    EnableWindow(GetDlgItem(hDlg, stc3),FALSE);
+	    EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
+	} else {
+	    if (lppd->Flags & PD_PAGENUMS)
+	        CheckRadioButton(hDlg, rad1, rad3, rad3);
+	}
+	/* "All xxx pages"... */
+	{
+	    char        resourcestr[64];
+	    char        result[64];
+	    LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES, 
+			resourcestr, 49);
+	    sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);
+	    SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);
+	}
+        
+	/* Collate pages 
+	 *
+	 * FIXME: The ico3 is not displayed for some reason. I don't know why.
+	 */
+	if (lppd->Flags & PD_COLLATE) {
+	    SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
+				(LPARAM)PrintStructures->hCollateIcon);
+	    CheckDlgButton(hDlg, chx2, 1);
+	} else {
+	    SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
+				(LPARAM)PrintStructures->hNoCollateIcon);
+	    CheckDlgButton(hDlg, chx2, 0);
+	}
+
+	if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
+	  /* if printer doesn't support it: no Collate */
+	    if (!(lpdm->dmFields & DM_COLLATE)) {
+	        EnableWindow(GetDlgItem(hDlg, chx2), FALSE);    
+		EnableWindow(GetDlgItem(hDlg, ico3), FALSE);    
+	    }
+	}
+
+	/* nCopies */
+	if (lppd->hDevMode == 0)
+	    SetDlgItemInt(hDlg, edt3, lppd->nCopies, FALSE);
+	else
+	    SetDlgItemInt(hDlg, edt3, lpdm->dmCopies, FALSE);
+
+	if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
+	  /* if printer doesn't support it: no nCopies */
+	    if (!(lpdm->dmFields & DM_COPIES)) {
+	        EnableWindow(GetDlgItem(hDlg, edt3), FALSE);    
+		EnableWindow(GetDlgItem(hDlg, stc5), FALSE);    
+	    }
+	}
+
+	/* print to file */
+	CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
+	if (lppd->Flags & PD_DISABLEPRINTTOFILE)
+            EnableWindow(GetDlgItem(hDlg, chx1), FALSE);    
+	if (lppd->Flags & PD_HIDEPRINTTOFILE)
+            ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
+
+    } else { /* PD_PRINTSETUP */
+      PRINTDLG_SetUpPaperComboBox(hDlg, cmb2,
+				  PrintStructures->lpPrinterInfo->pPrinterName,
+				  PrintStructures->lpPrinterInfo->pPortName,
+				  lpdm);
+      PRINTDLG_SetUpPaperComboBox(hDlg, cmb3,
+				  PrintStructures->lpPrinterInfo->pPrinterName,
+				  PrintStructures->lpPrinterInfo->pPortName,
+				  lpdm);
+      CheckRadioButton(hDlg, rad1, rad2,
+		       (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT) ?
+		       rad1: rad2);
+    }
+
+    /* help button */
+    if ((lppd->Flags & PD_SHOWHELP)==0) {
+        /* hide if PD_SHOWHELP not specified */
+        ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);         
+    }
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *           PRINTDLG_WMInitDialog                      [internal]
+ */
+static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam,
+				     PRINT_PTRA* PrintStructures)
+{
+    LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
+    DEVNAMES *pdn;
+    DEVMODEA *pdm;
+    char *name = NULL;
+    UINT comboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
+
+    /* load Collate ICONs */
+    PrintStructures->hCollateIcon =
+      LoadIconA(COMDLG32_hInstance, "PD32_COLLATE");
+    PrintStructures->hNoCollateIcon = 
+      LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE");
+    if(PrintStructures->hCollateIcon == 0 ||
+       PrintStructures->hNoCollateIcon == 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.
+     */
+    if (lppd->Flags & PD_SHOWHELP) {
+        if((PrintStructures->HelpMessageID = 
+	    RegisterWindowMessageA(HELPMSGSTRING)) == 0) {
+	    COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
+	    return FALSE;
+	}
+    } else
+        PrintStructures->HelpMessageID = 0;
+
+    /* 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.
+     */
+    if (lppd->nMaxPage < lppd->nMinPage)
+    	lppd->nMaxPage = lppd->nMinPage;
+    if (lppd->nMinPage == lppd->nMaxPage) 
+    	lppd->Flags |= PD_NOPAGENUMS;        
+    if (lppd->nToPage < lppd->nMinPage)
+        lppd->nToPage = lppd->nMinPage;
+    if (lppd->nToPage > lppd->nMaxPage)
+        lppd->nToPage = lppd->nMaxPage;
+    if (lppd->nFromPage < lppd->nMinPage)
+        lppd->nFromPage = lppd->nMinPage;
+    if (lppd->nFromPage > lppd->nMaxPage)
+        lppd->nFromPage = lppd->nMaxPage;
+
+    /* Fill Combobox 
+     */
+    pdn = GlobalLock(lppd->hDevNames);
+    pdm = GlobalLock(lppd->hDevMode);
+    if(pdn)
+        name = (char*)pdn + pdn->wDeviceOffset;
+    else if(pdm)
+        name = pdm->dmDeviceName;
+    PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);
+    if(pdm) GlobalUnlock(lppd->hDevMode);
+    if(pdn) GlobalUnlock(lppd->hDevNames);
+
+    /* Now find selected printer and update rest of dlg */
+    name = HeapAlloc(GetProcessHeap(),0,256);
+    GetDlgItemTextA(hDlg, comboID, name, 255);
+    PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);
+    HeapFree(GetProcessHeap(),0,name);
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *                              PRINTDLG_WMCommand               [internal]
+ */
+static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 
+			LPARAM lParam, PRINT_PTRA* PrintStructures)
+{
+    LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
+    UINT PrinterComboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
+    LPDEVMODEA lpdm = PrintStructures->lpDevMode;
+
+    switch (LOWORD(wParam))  {
+    case IDOK:
+        TRACE(" OK button was hit\n");
+        if (PRINTDLG_UpdatePrintDlg(hDlg, PrintStructures)!=TRUE)
+	    return(FALSE);
+	EndDialog(hDlg, TRUE);
+	return(TRUE);
+
+    case IDCANCEL:
+        TRACE(" CANCEL button was hit\n");
+        EndDialog(hDlg, FALSE);
+	return(FALSE);
+
+     case pshHelp:
+        TRACE(" HELP button was hit\n");
+        SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 
+        			(WPARAM) hDlg, (LPARAM) lppd);
+        break;
+
+     case chx2:                         /* collate pages checkbox */
+        if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
+            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
+                                    (LPARAM)PrintStructures->hCollateIcon);
+        else
+            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
+                                    (LPARAM)PrintStructures->hNoCollateIcon);
+        break;        
+     case edt1:                         /* from page nr editbox */
+     case edt2:                         /* to page nr editbox */
+        if (HIWORD(wParam)==EN_CHANGE) {
+	    WORD nToPage;
+	    WORD nFromPage;
+	    nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
+	    nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
+            if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage)
+	        CheckRadioButton(hDlg, rad1, rad3, rad3);
+	}
+        break;
+     case psh2:                       /* Properties button */
+       {
+         HANDLE hPrinter;
+         char   PrinterName[256];
+
+         GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255);
+         if (!OpenPrinterA(PrinterName, &hPrinter, NULL)) {
+	     WARN(" Call to OpenPrinter did not succeed!\n");
+	     break;
+	 }
+	 DocumentPropertiesA(hDlg, hPrinter, PrinterName, 
+			     PrintStructures->lpDevMode,
+			     PrintStructures->lpDevMode,
+			     DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
+	 ClosePrinter(hPrinter);
+         break;
+       }
+
+    case cmb1:
+    case cmb4:                         /* Printer combobox */
+         if (HIWORD(wParam)==CBN_SELCHANGE) {
+	     char   PrinterName[256];
+	     GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255);
+	     PRINTDLG_ChangePrinter(hDlg, PrinterName, PrintStructures);
+	 }
+	 break;
+
+    case cmb2: /* Papersize */
+      {
+	  DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
+	  if(Sel != CB_ERR)
+	      lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
+							    CB_GETITEMDATA,
+							    Sel, 0);
+      }
+      break;
+
+    case cmb3: /* Bin */
+      {
+	  DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
+	  if(Sel != CB_ERR)
+	      lpdm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3,
+							  CB_GETITEMDATA, Sel,
+							  0);
+      }
+      break; 
+    }
+    return FALSE;
+}    
+
+/***********************************************************************
+ *           PrintDlgProcA			[internal]
+ */
+BOOL WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
+			  LPARAM lParam)
+{
+    PRINT_PTRA* PrintStructures;
+    LRESULT res=FALSE;
+
+    if (uMsg!=WM_INITDIALOG) {
+        PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);   
+	if (!PrintStructures)
+	    return FALSE;
+    } else {
+        PrintStructures = (PRINT_PTRA*) lParam;
+	SetWindowLongA(hDlg, DWL_USER, lParam); 
+	res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures);
+
+	if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
+	    res = PrintStructures->lpPrintDlg->lpfnPrintHook(hDlg, uMsg,
+						 wParam,
+				       (LPARAM)PrintStructures->lpPrintDlg); 
+	}
+	return res;
+    }
+  
+    if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
+        res = PrintStructures->lpPrintDlg->lpfnPrintHook(hDlg, uMsg, wParam,
+							 lParam);
+	if(res) return res;
+    }
+
+    switch (uMsg) {
+    case WM_COMMAND:
+        return PRINTDLG_WMCommand(hDlg, wParam, lParam, PrintStructures);
+
+    case WM_DESTROY:
+	DestroyIcon(PrintStructures->hCollateIcon);
+	DestroyIcon(PrintStructures->hNoCollateIcon);
+    /* FIXME: don't forget to delete the paper orientation icons here! */
+
+        return FALSE;
+    }    
+    return res;
+}
+
+/************************************************************
+ *
+ *      PRINTDLG_GetDlgTemplate
+ *
+ */
+static HGLOBAL PRINTDLG_GetDlgTemplate(PRINTDLGA *lppd)
+{
+    HGLOBAL hDlgTmpl, hResInfo;
+
+    if (lppd->Flags & PD_PRINTSETUP) {
+        if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
+	    hDlgTmpl = lppd->hSetupTemplate;
+	} else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {	
+	    hResInfo = FindResourceA(lppd->hInstance,
+				     lppd->lpSetupTemplateName, RT_DIALOGA);
+	    hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
+	} else {
+	    hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP",
+				     RT_DIALOGA);
+	    hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
+	}
+    } else {
+        if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
+	    hDlgTmpl = lppd->hPrintTemplate;
+	} else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
+	    hResInfo = FindResourceA(lppd->hInstance,
+				     lppd->lpPrintTemplateName,
+				     RT_DIALOGA);
+	    hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
+	} else {
+	    hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32",
+				     RT_DIALOGA);
+	    hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
+	}
+    }
+    return hDlgTmpl;
+}
+
+/***********************************************************************
+ *
+ *      PRINTDLG_CreateDC
+ *
+ */
+static BOOL PRINTDLG_CreateDC(LPPRINTDLGA lppd)
+{
+    DEVNAMES *pdn = GlobalLock(lppd->hDevNames);
+    DEVMODEA *pdm = GlobalLock(lppd->hDevMode);
+
+    if(lppd->Flags & PD_RETURNDC) {
+        lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset,
+			      (char*)pdn + pdn->wDeviceOffset,
+			      (char*)pdn + pdn->wOutputOffset,
+			      pdm );
+    } else if(lppd->Flags & PD_RETURNIC) {
+        lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset,
+			      (char*)pdn + pdn->wDeviceOffset,
+			      (char*)pdn + pdn->wOutputOffset,
+			      pdm );
+    }
+    GlobalUnlock(lppd->hDevNames);
+    GlobalUnlock(lppd->hDevMode);
+    return lppd->hDC ? TRUE : FALSE;
+}
 
 /***********************************************************************
  *           PrintDlgA   (COMDLG32.17)
@@ -138,169 +880,132 @@
  *    default printer settings.
  */
 BOOL WINAPI PrintDlgA(
-			 LPPRINTDLGA lppd /* ptr to PRINTDLG32 struct */
-			 )
+		      LPPRINTDLGA lppd /* ptr to PRINTDLG32 struct */
+		      )
 {
-/* My implementing strategy:
- * 
- * step 1: display the dialog and implement the layout-flags
- * step 2: enter valid information in the fields (e.g. real printers)
- * step 3: fix the RETURN-TRUE-ALWAYS Fixme by checking lppd->Flags for
- *         PD_RETURNDEFAULT
- * step 4: implement all other specs
- * step 5: allow customisation of the dialog box
- *
- * current implementation is in step 4.
- */ 
-
-    HWND      hwndDialog;
     BOOL      bRet = FALSE;
-    LPCVOID   ptr;
-    HANDLE    hResInfo, hDlgTmpl;
+    LPVOID   ptr;
     HINSTANCE hInst = GetWindowLongA( lppd->hwndOwner, GWL_HINSTANCE );
-    DWORD     EnumBytesNeeded;
-    DWORD     CopyOfEnumBytesNeeded;
-    PRINT_PTRA PrintStructures;
 
-    TRACE("(lppd: %p)\n", lppd);
-    PrintStructures.lpPrintDlg      = lppd;
-    
+    if(TRACE_ON(commdlg)) {
+        char flagstr[1000] = "";
+	struct pd_flags *pflag = pd_flags;
+	for( ; pflag->name; pflag++) {
+	    if(lppd->Flags & pflag->flag)
+	        strcat(flagstr, pflag->name);
+	}
+	TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
+	      "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
+	      "flags %08lx (%s)\n",
+	      lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
+	      lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
+	      lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
+    }
+
+    if(lppd->lStructSize != sizeof(PRINTDLGA)) {
+        WARN("structure size failure !!!\n");
+	COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
+	return FALSE; 
+    }
+
+    if(lppd->Flags & PD_RETURNDEFAULT) {
+        PRINTER_INFO_2A *pbuf;
+	HANDLE hprn;
+	DWORD needed;
+
+	if(lppd->hDevMode || lppd->hDevNames) {
+	    WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
+	    COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 
+	    return FALSE;
+	}
+        if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
+	    WARN("Can't find default printer\n");
+	    COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 
+	    return FALSE;
+	}
+
+	GetPrinterA(hprn, 2, NULL, 0, &needed);
+	pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
+	GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
+	ClosePrinter(hprn);
+	PRINTDLG_CreateDevNames(&(lppd->hDevNames), "winspool",
+				  pbuf->pDevMode->dmDeviceName,
+				  pbuf->pPortName);
+	lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
+				     pbuf->pDevMode->dmDriverExtra);
+	ptr = GlobalLock(lppd->hDevMode);
+	memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
+	       pbuf->pDevMode->dmDriverExtra);
+	GlobalUnlock(lppd->hDevMode);
+	HeapFree(GetProcessHeap(), 0, pbuf);
+	bRet = TRUE;
+    } else {
+	HGLOBAL hDlgTmpl;
+	PRINT_PTRA *PrintStructures;
+
     /* load Dialog resources, 
      * depending on Flags indicates Print32 or Print32_setup dialog 
      */
-    if (lppd->Flags & PD_PRINTSETUP)
-        hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP", RT_DIALOGA);
-    else
-        hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32", RT_DIALOGA);
-    if (!hResInfo)
-      {
-	   COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
-	   return FALSE;
-      }
-    
-    if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo )) ||
-        !(ptr = LockResource( hDlgTmpl )))
-      {
-       COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
-       return FALSE;
-      }
+	hDlgTmpl = PRINTDLG_GetDlgTemplate(lppd);
+	if (!(hDlgTmpl) || !(ptr = LockResource( hDlgTmpl ))) {
+	    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
+	    return FALSE;
+	}
+        PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+				    sizeof(PRINT_PTRA));
+	PrintStructures->lpPrintDlg = lppd;
 
-    /* load Collate ICONs */
-    PrintStructures.hCollateIcon = 
-                              LoadIconA(COMDLG32_hInstance, "PD32_COLLATE");
-    PrintStructures.hNoCollateIcon = 
-                                LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE");
-    if (PrintStructures.hCollateIcon==0 || PrintStructures.hNoCollateIcon==0)
-    {
-    ERR("no icon in resourcefile???");
-	COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
-	return FALSE;
+	/* and create & process the dialog 
+	 */
+	bRet = DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner,
+				       PrintDlgProcA,
+				       (LPARAM)PrintStructures);
+
+	if(bRet) {
+	    DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
+	    PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
+
+	    if (lppd->hDevMode == 0) {
+	        TRACE(" No hDevMode yet... Need to create my own\n");
+		lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE,
+					lpdm->dmSize + lpdm->dmDriverExtra);
+	    } else {
+	        WORD locks;
+		if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {
+		    WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
+		    while(locks--) {
+		        GlobalUnlock(lppd->hDevMode);
+			TRACE("Now got %d locks\n", locks);
+		    }
+		}
+		lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,
+					       lpdm->dmSize + lpdm->dmDriverExtra,
+					       GMEM_MOVEABLE);
+	    }
+	    lpdmReturn = GlobalLock(lppd->hDevMode);
+	    memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
+
+	    if (lppd->hDevNames != 0) {
+	        WORD locks;
+		if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) {
+		    WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
+		    while(locks--)
+		        GlobalUnlock(lppd->hDevNames);
+		}
+	    }
+	    PRINTDLG_CreateDevNames(&(lppd->hDevNames), "winspool",
+				    lpdmReturn->dmDeviceName, pi->pPortName);
+	    GlobalUnlock(lppd->hDevMode);
+	}
+	HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
+	HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
+	HeapFree(GetProcessHeap(), 0, PrintStructures);
     }
+    if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
+        bRet = PRINTDLG_CreateDC(lppd);
 
-    /* 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.
-     */
-    if (lppd->Flags & PD_SHOWHELP)
-       {
-        if((PrintStructures.HelpMessageID = 
-                       RegisterWindowMessageA(HELPMSGSTRING)) == 0)
-            {
-             COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
-             return FALSE;
-            }
-       }
-    else
-    	PrintStructures.HelpMessageID=0;
-	
-    /* Use EnumPrinters to obtain a list of PRINTER_INFO_2A's
-     * and store a pointer to this list in our "global structure"
-     * as reference for the rest of the PrintDlg routines
-     */
-    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 
-        0, &EnumBytesNeeded, &PrintStructures.NrOfPrinterInfoEntries);
-    CopyOfEnumBytesNeeded=EnumBytesNeeded+16;
-    PrintStructures.lpPrinterInfo = malloc(CopyOfEnumBytesNeeded*sizeof(char));
-    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, 
-        (LPBYTE)PrintStructures.lpPrinterInfo, 
-        CopyOfEnumBytesNeeded, &EnumBytesNeeded, 
-        &PrintStructures.NrOfPrinterInfoEntries);
-
-    /* Find the default printer.
-     * If not: display a warning message (unless PD_NOWARNING specified)
-     * and return PDERR_NODEFAULTPRN
-     */
-    /* FIXME: not implemented yet!!! */
-    if (!PrintStructures.NrOfPrinterInfoEntries)
-    {
-        COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
-        return FALSE;
-    }
-    PrintStructures.CurrentPrinter=0; 
-    PrintStructures.DefaultPrinter=0; 
-     
-    /* FIXME: Currently Unimplemented */
-    if (lppd->Flags & PD_NOWARNING)	
-	   {
-	    COMDLG32_SetCommDlgExtendedError(PDERR_INITFAILURE); 
-	    WARN(": PD_NOWARNING Flag is not yet implemented.\n");
-	   }
-    	
-    /*
-     * FIXME : Should respond to TEMPLATE and HOOK flags here
-     * For now, only the standard dialog works.
-     */
-    if (lppd->Flags & (PD_ENABLEPRINTHOOK | PD_ENABLEPRINTTEMPLATE |
-			  PD_ENABLEPRINTTEMPLATEHANDLE | PD_ENABLESETUPHOOK | 
-			  PD_ENABLESETUPTEMPLATE|PD_ENABLESETUPTEMPLATEHANDLE)) 
-    	FIXME(": unimplemented flag (ignored)\n");     
-	
-    /*
-     * if lppd->Flags PD_RETURNDEFAULT is specified, the PrintDlg function
-     * does not display the dialog box, but returns with valid entries
-     * for hDevMode and hDevNames .
-     *
-     * According to MSDN, it is required that hDevMode and hDevNames equal
-     * zero if this flag is set.
-     */
-    if (lppd->Flags & PD_RETURNDEFAULT)
-       {
-	TRACE(" PD_RETURNDEFAULT: was requested to return printer info only.\n");
-        if (lppd->hDevMode!=0 || lppd->hDevNames !=0)
-            {
-     	     COMDLG32_SetCommDlgExtendedError(PDERR_INITFAILURE); 
-             return(FALSE);
-            }
-        return(PRINTDLG_ValidateAndDuplicateSettings(0, &PrintStructures));
-       }
-	
-    /* and create & process the dialog 
-     */
-	if (lppd->Flags & PD_PRINTSETUP)
-		{
-         hwndDialog= DIALOG_CreateIndirect(hInst, ptr, TRUE, lppd->hwndOwner,
-            (DLGPROC16)PrintSetupDlgProcA, (LPARAM)&PrintStructures, WIN_PROC_32A );
-        }
-    else
-		{
-         hwndDialog= DIALOG_CreateIndirect(hInst, ptr, TRUE, lppd->hwndOwner,
-            (DLGPROC16)PrintDlgProcA, (LPARAM)&PrintStructures, WIN_PROC_32A );
-        }
-    if (hwndDialog) 
-        bRet = DIALOG_DoDialogBox(hwndDialog, lppd->hwndOwner);  
-     
-    /* free memory & resources
-     */   
-    free(PrintStructures.lpPrinterInfo);
-    DeleteObject(PrintStructures.hCollateIcon);
-    DeleteObject(PrintStructures.hNoCollateIcon);
-    /* FIXME: don't forget to delete the paper orientation icons here! */
-
-  TRACE(" exit! (%d)", bRet);        
-  return bRet;            
+    TRACE("exit! (%d)\n", bRet);        
+    return bRet;    
 }
 
 
@@ -314,869 +1019,30 @@
     return FALSE;
 }
 
+/***********************************************************************
+ *
+ *          PageSetupDlg
+ */
 
 /***********************************************************************
- *               PRINTDLG_UpdatePrinterInfoTexts               [internal]
+ *            PageSetupDlgA  (COMDLG32.15)
  */
-static void PRINTDLG_UpdatePrinterInfoTexts(HWND hDlg, PRINT_PTRA* PrintStructures)
-{
-    char   StatusMsg[256];
-    char   ResourceString[256];
-    int    i;
-    LPPRINTER_INFO_2A lpPi = &(PrintStructures->lpPrinterInfo
-                                             [PrintStructures->CurrentPrinter]);
-    
-    /* Status Message */
-    StatusMsg[0]='\0';
-    /* FIXME: if default printer, add this first */
-    ;
-    /* add all status messages */
-    for (i=0; i< 25; i++)
-    {
-        if (lpPi->Status & (1<<i))
-        {
-         LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 
-                        ResourceString, 255);
-         strcat(StatusMsg,ResourceString);
-        }
-    }
-    /* append "ready" */
-    /* FIXME: status==ready must only be appended if really so. 
-              but how to detect??? */
-    LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 
-                        ResourceString, 255);
-    strcat(StatusMsg,ResourceString);
-  
-    SendDlgItemMessageA(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg);
-
-    /* set all other printer info texts */
-    SendDlgItemMessageA(hDlg, stc11, WM_SETTEXT, 0, (LPARAM)lpPi->pDriverName);
-    if (lpPi->pLocation != NULL && lpPi->pLocation[0]!='\0')
-        SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)lpPi->pLocation);
-    else                                        
-        SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)lpPi->pPortName);
-    SendDlgItemMessageA(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)lpPi->pComment);
+BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {
+	FIXME("(%p), stub!\n",setupdlg);
+	return FALSE;
+}
+/***********************************************************************
+ *            PageSetupDlgW  (COMDLG32.16)
+ */
+BOOL WINAPI PageSetupDlgW(LPPAGESETUPDLGW setupdlg) {
+	FIXME("(%p), stub!\n",setupdlg);
+	return FALSE;
 }
 
-/***********************************************************************
- *        PRINTSETUP32DLG_ComboBox               [internal]
+/**********************************************************************
  *
- * Queries the DeviceCapabilities for a list of paper sizes / bin names
- * and stores these in combobox cmb2 / cmb3.
- * If there was already an item selected in the listbox,
- * this item is looked up in the new list and reselected, 
- * the accompanying ID (for BinNames, this is the dmDefaultSource value)
- * is returned
- *
- * If any entries in the listbox existed, these are deleted
- *
- * RETURNS:
- *   If an entry was selected and also exists in the new list,
- *   its corresponding ID is returned.
- * 
- *   returns zero on not found, error or SelectedName==NULL.
- *
- *
- * BUGS:
- * * the lookup of a new entry shouldn't be done on stringname,
- *   but on ID value, as some drivers name the same paper format 
- *   differently (language differences, added paper size)
+ *      16 bit commdlg
  */
-static short PRINTSETUP32DLG_UpdateComboBox(HWND hDlg,
-                                      int   nIDComboBox,
-                                      char* PrinterName, 
-                                      char* PortName)
-{
-    int     i;
-    DWORD   NrOfEntries;
-    char*   Names;
-    WORD*   Sizes;
-    HGLOBAL hTempMem;
-    short   returnvalue = 0;
-    char    SelectedName[256];
-    int     NamesSize;
-    int     fwCapability_Names;
-    int     fwCapability_Words;
-    
-    TRACE(" Printer: %s, ComboID: %d\n",PrinterName,nIDComboBox);
-    
-    /* query the dialog box for the current selected value */
-    GetDlgItemTextA(hDlg, nIDComboBox, SelectedName, 255);
-
-    if (nIDComboBox == cmb2)
-        {
-         NamesSize          = 64;
-         fwCapability_Names = DC_PAPERNAMES;
-         fwCapability_Words = DC_PAPERS;
-        }
-    else
-        {
-         nIDComboBox        = cmb3;
-         NamesSize          = 24;
-         fwCapability_Names = DC_BINNAMES;
-         fwCapability_Words = DC_BINS;
-        }
-    
-    /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 
-     * paper settings. As Wine doesn't allow VXDs, this results in a crash.
-     */
-    WARN(" if your printer driver uses VXDs, expect a crash now!\n");
-    NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
-                                      fwCapability_Names, NULL, NULL);
-    if (NrOfEntries == 0)
-        {
-         WARN(" no Name Entries found!\n");
-        }
-    hTempMem = GlobalAlloc(GMEM_MOVEABLE, NrOfEntries*NamesSize);
-    if (hTempMem == 0)
-        {
-         ERR(" Not enough memory to store Paper Size Names!\n");
-         return(0);
-        }
-    Names = GlobalLock(hTempMem);
-    NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
-                                      fwCapability_Names, Names, NULL);
-                                      
-    /* reset any current content in the combobox */
-    SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
-    
-    /* store new content */
-    for (i=0; i<NrOfEntries; i++)
-      {
-       SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0,
-                        (LPARAM)(&Names[i*NamesSize]) );
-      }
-                        
-    /* select first entry */                        
-    SendDlgItemMessageA(hDlg, nIDComboBox, CB_SELECTSTRING, 0, 
-                        (LPARAM)(&Names[0]) );
-
-    /* lookup SelectedName and select it, if found */
-    if (SelectedName[0] != '\0')
-       {
-        for (i=0; i<NrOfEntries; i++)
-            {
-             if (strcmp(&Names[i*NamesSize], SelectedName)==0)
-                {
-                 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SELECTSTRING, 0, 
-                                     (LPARAM)(SelectedName));
-                 
-                 /* now, we need the i-th entry from the list of paper sizes */
-                 /* let's recycle the memory */
-                 DeviceCapabilitiesA(PrinterName, PortName, fwCapability_Words,
-                                     Names, NULL);
-                 Sizes = (WORD*) Names;
-                 returnvalue = Sizes[i];                 
-                 break; /* quit for loop */
-                }
-            }
-       }
-                        
-    GlobalUnlock(hTempMem);
-    GlobalFree(hTempMem);
- return(returnvalue);
-}
-
-
-
-/***********************************************************************
- *           PRINTDLG_WMInitDialog                      [internal]
- */
-static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
-				     PRINT_PTRA* PrintStructures)
-{
- int               i;
- LPPRINTDLGA       lppd     = PrintStructures->lpPrintDlg;
- LPPRINTER_INFO_2A lppi     = PrintStructures->lpPrinterInfo;
- PDEVMODEA	   pDevMode = lppi[PrintStructures->CurrentPrinter].pDevMode; 
- 
-	SetWindowLongA(hDlg, DWL_USER, lParam); 
-	TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
-
-	if (lppd->lStructSize != sizeof(PRINTDLGA))
-	{
-		FIXME("structure size failure !!!\n");
-/*		EndDialog (hDlg, 0); 
-		return FALSE; 
-*/	}
-
-/* Fill Combobox according to info from PRINTER_INFO2A
- * structure inside PrintStructures,
- * select the default printer and generate an
- * update-message to have the rest of the dialog box updated.
- */ 
-    for (i=0; i < PrintStructures->NrOfPrinterInfoEntries; i++)
-	   SendDlgItemMessageA(hDlg, cmb4, CB_ADDSTRING, 0,
-                        (LPARAM)lppi[i].pPrinterName );
-    i=SendDlgItemMessageA(hDlg, cmb4, CB_SELECTSTRING, 
-        (WPARAM) -1,
-        (LPARAM) lppi[PrintStructures->CurrentPrinter].pPrinterName);
-    SendDlgItemMessageA(hDlg, cmb4, CB_SETCURSEL, 
-        (WPARAM)i, (LPARAM)0);
-    PRINTDLG_UpdatePrinterInfoTexts(hDlg, PrintStructures);
-
-/* Flag processing to set the according buttons on/off and
- * Initialise the various values
- */
-
-    /* Print range (All/Range/Selection) */
-    /* 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.
-     */
-    if (lppd->nMaxPage < lppd->nMinPage)
-    	lppd->nMaxPage = lppd->nMinPage;
-    if (lppd->nMinPage == lppd->nMaxPage) 
-    	lppd->Flags |= PD_NOPAGENUMS;        
-    if (lppd->nToPage < lppd->nMinPage)
-        lppd->nToPage = lppd->nMinPage;
-    if (lppd->nToPage > lppd->nMaxPage)
-        lppd->nToPage = lppd->nMaxPage;
-    if (lppd->nFromPage < lppd->nMinPage)
-        lppd->nFromPage = lppd->nMinPage;
-    if (lppd->nFromPage > lppd->nMaxPage)
-        lppd->nFromPage = lppd->nMaxPage;
-    SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
-    SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
-    CheckRadioButton(hDlg, rad1, rad3, rad1);		/* default */
-    if (lppd->Flags & PD_NOSELECTION)
-		EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
-    else
-		if (lppd->Flags & PD_SELECTION)
-	    	CheckRadioButton(hDlg, rad1, rad3, rad2);
-    if (lppd->Flags & PD_NOPAGENUMS)
-       {
-		EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
-		EnableWindow(GetDlgItem(hDlg, stc2),FALSE);
-		EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
-		EnableWindow(GetDlgItem(hDlg, stc3),FALSE);
-		EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
-       }
-    else
-       {
-		if (lppd->Flags & PD_PAGENUMS)
-	    	CheckRadioButton(hDlg, rad1, rad3, rad3);
-       }
-	/* "All xxx pages"... */
-    {
-     char        resourcestr[64];
-     char        result[64];
-     LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES, 
-                resourcestr, 49);
-     sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);
-     SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);
-    }
-        
-    /* Collate pages 
-     *
-     * FIXME: The ico3 is not displayed for some reason. I don't know why.
-     */
-    if (lppd->Flags & PD_COLLATE)
-       {
-        SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
-                                    (LPARAM)PrintStructures->hCollateIcon);
-   	    CheckDlgButton(hDlg, chx2, 1);
-       }
-    else
-       {
-            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
-                                    (LPARAM)PrintStructures->hNoCollateIcon);
-   	    CheckDlgButton(hDlg, chx2, 0);
-       }
-       
-    if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE ||
-        lppd->Flags & PD_USEDEVMODECOPIES)
-	{
-	 /* if printer doesn't support it: no Collate */
-	 if (!(pDevMode->dmFields & DM_COLLATE))
-	    {
-		EnableWindow(GetDlgItem(hDlg, chx2), FALSE);    
-		EnableWindow(GetDlgItem(hDlg, ico3), FALSE);    
-	    }
-	}
-        
-    /* nCopies */
-    if (lppd->hDevMode == 0)
-    	{
-         SetDlgItemInt(hDlg, edt3, lppd->nCopies, FALSE);
-	}
-    else
-        {
-         SetDlgItemInt(hDlg, edt1, pDevMode->dmCopies, FALSE);
-	}
-    if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE ||
-        lppd->Flags & PD_USEDEVMODECOPIES)
-	{
-	 /* if printer doesn't support it: no nCopies */
-	 if (!(pDevMode->dmFields & DM_COPIES))
-	    {
-		EnableWindow(GetDlgItem(hDlg, edt3), FALSE);    
-		EnableWindow(GetDlgItem(hDlg, stc5), FALSE);    
-	    }
-	}
-
-    /* print to file */
-   	CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
-    if (lppd->Flags & PD_DISABLEPRINTTOFILE)
-		EnableWindow(GetDlgItem(hDlg, chx1), FALSE);    
-    if (lppd->Flags & PD_HIDEPRINTTOFILE)
-		ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
-
-    /* help button */
-	if ((lppd->Flags & PD_SHOWHELP)==0)
-    	{	/* hide if PD_SHOWHELP not specified */
-		 ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);         
-        }
-
-  GlobalUnlock(lppd->hDevMode);
-  return TRUE;
-}
-
-
-
-
-/***********************************************************************
- *           PRINTSETUP32DLG_WMInitDialog                      [internal]
- */
-static LRESULT PRINTSETUP32DLG_WMInitDialog(HWND hDlg, WPARAM wParam, 
-                     LPARAM lParam,
-				     PRINT_PTRA* PrintStructures)
-{
- int               i;
- LPPRINTDLGA       lppd     = PrintStructures->lpPrintDlg;
- LPPRINTER_INFO_2A lppi     = PrintStructures->lpPrinterInfo;
- 
-	SetWindowLongA(hDlg, DWL_USER, lParam); 
-	TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
-
-	if (lppd->lStructSize != sizeof(PRINTDLGA))
-	{
-		FIXME("structure size failure !!!\n");
-/*		EndDialog (hDlg, 0); 
-		return FALSE; 
-*/	}
-
-/* Fill Combobox 1 according to info from PRINTER_INFO2A
- * structure inside PrintStructures,
- * select the default printer and generate an
- * update-message to have the rest of the dialog box updated.
- */ 
-    for (i=0; i < PrintStructures->NrOfPrinterInfoEntries; i++)
-	   SendDlgItemMessageA(hDlg, cmb1, CB_ADDSTRING, 0,
-                        (LPARAM)lppi[i].pPrinterName );
-    i=SendDlgItemMessageA(hDlg, cmb1, CB_SELECTSTRING, 
-        (WPARAM) -1,
-        (LPARAM) lppi[PrintStructures->CurrentPrinter].pPrinterName);
-    SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, 
-        (WPARAM)i, (LPARAM)0);
-    PRINTDLG_UpdatePrinterInfoTexts(hDlg, PrintStructures);
-    
-/* 
- * fill both ComboBoxes with their info
- */
-  PRINTSETUP32DLG_UpdateComboBox(hDlg, cmb2,
-                lppi[PrintStructures->CurrentPrinter].pPrinterName,
-                lppi[PrintStructures->CurrentPrinter].pPortName);
-  PRINTSETUP32DLG_UpdateComboBox(hDlg, cmb3,
-                lppi[PrintStructures->CurrentPrinter].pPrinterName,
-                lppi[PrintStructures->CurrentPrinter].pPortName);
-                
-/* 
- * set the correct radiobutton & icon for print orientation
- */
-  /* this should be dependent on a incoming DevMode 
-   * (FIXME: not implemented yet) */
-  CheckRadioButton(hDlg, rad1, rad2, rad1);
-  /* also set the correct icon (FIXME: not implemented yet) */
-                
-  return TRUE;
-}
-
-
-/***********************************************************************
- *             PRINTDLG_CreateDevNames          [internal]
- *
- *
- *   creates a DevNames structure.
- * RETURNS
- *   HGLOBAL to DevNames memory object on success or
- *   zero on faillure
- */
-static HGLOBAL PRINTDLG_CreateDevNames(
-                    char* DeviceDriverName, 
-                    char* DeviceName, 
-                    char* OutputPort, 
-                    WORD  Flags)
-{
-    long size;
-    HGLOBAL hDevNames;
-    char*   pDevNamesSpace;
-    char*   pTempPtr;
-    LPDEVNAMES lpDevNames;
-    
-    size = strlen(DeviceDriverName) +1
-            + strlen(DeviceName) + 1
-            + strlen(OutputPort) + 1
-            + sizeof(DEVNAMES);
-            
-    hDevNames = GlobalAlloc(GMEM_MOVEABLE, size*sizeof(char));
-    if (hDevNames != 0)
-    {
-        pDevNamesSpace = GlobalLock(hDevNames);
-        lpDevNames = (LPDEVNAMES) pDevNamesSpace;
-        
-        pTempPtr = pDevNamesSpace + sizeof(DEVNAMES);
-        strcpy(pTempPtr, DeviceDriverName);
-        lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace;
-        
-        pTempPtr += strlen(DeviceDriverName) + 1;
-        strcpy(pTempPtr, DeviceName);
-        lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
-        
-        pTempPtr += strlen(DeviceName) + 1;
-        strcpy(pTempPtr, OutputPort);
-        lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
-        
-        lpDevNames->wDefault = Flags;
-        
-        GlobalUnlock(hDevNames);
-    }
-    return(hDevNames);
-}
-            
-    
-           
-    
-/***********************************************************************
- *             PRINTDLG_ValidateAndDuplicateSettings          [internal]
- *
- *
- *   updates the PrintDlg structure for returnvalues.
- *   (yep, the name was chosen a bit stupid...)
- *
- *   if hDlg equals zero, only hDevModes and hDevNames are adapted.
- *      
- * RETURNS
- *   FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
- *   TRUE  if succesful.
- */
-static BOOL PRINTDLG_ValidateAndDuplicateSettings(HWND hDlg, 
-						  PRINT_PTRA* PrintStructures)
-{
- LPPRINTER_INFO_2A lpPi = &(PrintStructures->lpPrinterInfo
-                                             [PrintStructures->CurrentPrinter]);
- LPPRINTDLGA       lppd = PrintStructures->lpPrintDlg;
- PDEVMODEA         pDevMode;
- 
- if (hDlg!=0)
- {
-    /* check whether nFromPage and nToPage are within range defined by
-     * nMinPage and nMaxPage
-     */
-    if (IsDlgButtonChecked(hDlg, rad3) == BST_CHECKED)
-    {
-        WORD nToPage;
-        WORD nFromPage;
-     	nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
-        nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
-        if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
-            nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage)
-        {
-	    char resourcestr[256];
-            char resultstr[256];
-            LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, 
-                resourcestr, 255);
-            sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
-            LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE, 
-                resourcestr, 255);
-            MessageBoxA(hDlg, resultstr, resourcestr, MB_OK | MB_ICONWARNING);
-            return(FALSE);
-        }
-        lppd->nFromPage = nFromPage;
-        lppd->nToPage   = nToPage;
-    }
-     
-    
-    if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED)
-       {
-        lppd->Flags |= PD_PRINTTOFILE;
-        lpPi->pPortName = "FILE:";
-       }
-
-    if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
-       {
-        FIXME("Collate lppd not yet implemented as output\n");
-       }
- } /* end-of-if(hDlg!=0) */
-
-    /* 
-     * create or modify hDevMode 
-     */     
-    if (lppd->hDevMode == 0)
-       {
-        TRACE(" No hDevMode yet... Need to create my own\n");
-        /* FIXME: possible memory leak? Memory never freed again! */
-        lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, lpPi->pDevMode->dmSize);
-        pDevMode    = GlobalLock(lppd->hDevMode);
-        memcpy(pDevMode, lpPi->pDevMode, lpPi->pDevMode->dmSize);
-       }
-    else
-       {
-        FIXME(" already hDevMode... must adjust it... Not implemented yet\n");
-        pDevMode    = GlobalLock(lppd->hDevMode);
-       }
-              
-    /* If hDevNames already exists, trash it.
-     * But create a new one anyway
-     */
-    if (lppd->hDevNames != 0)
-       {
-        if ( (GlobalFlags(lppd->hDevNames)&0xFF) != 0)
-	    ERR(" Tried to free hDevNames, but your application still has a"
-	    	" lock on hDevNames. Possible program crash...");
-        GlobalFree(lppd->hDevNames);
-       }
-    /* FIXME: The first entry  of DevNames is fixed to "winspool", 
-     * because I don't know of any printerdriver which doesn't return 
-     * winspool there. But I guess they do exist... 
-     */
-    lppd->hDevNames = PRINTDLG_CreateDevNames("winspool",
-                      lpPi->pDriverName, lpPi->pPortName, 
-		      (PrintStructures->DefaultPrinter ==
-		                PrintStructures->CurrentPrinter)?1:0);
-
-    /* set PD_Collate and nCopies */
-    if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE ||
-        lppd->Flags & PD_USEDEVMODECOPIES)
-        {
-	 /* if one of the above flags was set, the application doesn't
-	   * (want to) support multiple copies or collate...
-	   */
-         lppd->Flags &= ~PD_COLLATE;
-         lppd->nCopies = 1;
-	  /* if the printer driver supports it... store info there
-	   * otherwise no collate & multiple copies !
-	   */
-         if (pDevMode->dmFields & DM_COLLATE)
-          {
-           pDevMode->dmCollate = 0;
-           if (hDlg!=0)
-             if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
-	    	   pDevMode->dmCollate = 1;	 
-          }
-         if (pDevMode->dmFields & DM_COPIES)
-          {
-           pDevMode->dmCopies = 1;
-           if (hDlg!=0)
-                pDevMode->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
-	      }
-	    }
-    else
-        {
-         if (hDlg!=0)
-           {
-	        /* set Collate & nCopies according to dialog */
-            if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
-               lppd->Flags |= PD_COLLATE;
-            else
-               lppd->Flags &= ~PD_COLLATE;
-            lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
-           }
-        else
-           {
-            /* stick to defaults */
-            lppd->Flags &= ~PD_COLLATE;
-            lppd->nCopies = 1;
-           }
-       }
-
-    /* set DC */
-    if (lppd->Flags & PD_RETURNDC){
-      lppd->hDC = CreateDCA(NULL, lpPi->pPrinterName, NULL, NULL);
-    }
-
-
-    GlobalUnlock(lppd->hDevMode);
-
- return(TRUE);   
-}
-
-
-    
-/***********************************************************************
- *      PRINTSETUP32DLG_ValidateAndDuplicateSettings          [internal]
- *
- *
- *   updates the PrintDlg structure for returnvalues.
- *   (yep, the name was chosen a bit stupid...)
- *
- *   if hDlg equals zero, only hDevModes and hDevNames are adapted.
- *      
- * RETURNS
- *   FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
- *   TRUE  if succesful.
- */
-static BOOL PRINTSETUP32DLG_ValidateAndDuplicateSettings(HWND hDlg, 
-						  PRINT_PTRA* PrintStructures)
-{
- LPPRINTDLGA       lppd = PrintStructures->lpPrintDlg;
- LPPRINTER_INFO_2A lppi = &(PrintStructures->lpPrinterInfo
-                                             [PrintStructures->CurrentPrinter]);
- PDEVMODEA         pDevMode;
-
-   if (PRINTDLG_ValidateAndDuplicateSettings(0, PrintStructures)==FALSE)
-      return(FALSE);
-
-   pDevMode    = GlobalLock(lppd->hDevMode);
-
-   /* set bin type and paper size to DevMode */
-   if (pDevMode->dmFields & DM_PAPERSIZE)
-     {
-      pDevMode->u1.s1.dmPaperSize = PRINTSETUP32DLG_UpdateComboBox(hDlg, cmb2,
-                            lppi->pPrinterName,
-                            lppi->pPortName);
-      /* FIXME: should set dmPaperLength and dmPaperWidth also??? */
-     }                      
-   if (pDevMode->dmFields & DM_DEFAULTSOURCE)
-      pDevMode->dmDefaultSource = PRINTSETUP32DLG_UpdateComboBox(hDlg, cmb3,
-                            lppi->pPrinterName,
-                            lppi->pPortName);
- 
-   /* set paper orientation to DevMode */
-   if (pDevMode->dmFields & DM_ORIENTATION)
-      {
-       if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED)
-           pDevMode->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
-       else
-           pDevMode->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
-      }
-      
-   GlobalUnlock(lppd->hDevMode);
-   
- return(TRUE);
-}
-
-
-
-/***********************************************************************
- *                              PRINTDLG_WMCommand               [internal]
- */
-static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 
-			LPARAM lParam, PRINT_PTRA* PrintStructures)
-{
-    LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
-    LPPRINTER_INFO_2A lppi = &(PrintStructures->lpPrinterInfo
-                                        [PrintStructures->CurrentPrinter]);
-    
-
-    switch (LOWORD(wParam)) 
-    {
-	 case IDOK:
-        TRACE(" OK button was hit\n");
-        if (PRINTDLG_ValidateAndDuplicateSettings(hDlg, PrintStructures)!=TRUE)
-        	return(FALSE);
-	    DestroyWindow(hDlg);
-	    return(TRUE);
-	 case IDCANCEL:
-        TRACE(" CANCEL button was hit\n");
-        EndDialog(hDlg, FALSE);
-	    return(FALSE);
-     case pshHelp:
-        TRACE(" HELP button was hit\n");
-        SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 
-        			(WPARAM) hDlg, (LPARAM) lppd);
-        break;
-     case chx2:                         /* collate pages checkbox */
-        if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
-            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
-                                    (LPARAM)PrintStructures->hCollateIcon);
-        else
-            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
-                                    (LPARAM)PrintStructures->hNoCollateIcon);
-        break;        
-     case edt1:                         /* from page nr editbox */
-     case edt2:                         /* to page nr editbox */
-        if (HIWORD(wParam)==EN_CHANGE)
-           {
-            WORD nToPage;
-	        WORD nFromPage;
-	    	nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
-	        nToPage   = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
-            if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage)
-			    CheckRadioButton(hDlg, rad1, rad3, rad3);
-    }
-        break;
-     case psh2:                         /* Properties button */
-        {
-/*         HANDLE hPrinter;
-         char   PrinterName[256];
-         GetDlgItemTextA(hDlg, cmb4, PrinterName, 255);
-         if (OpenPrinterA(PrinterName, &hPrinter, NULL))
-            {
-             PrinterProperties(hDlg, hPrinter);
-             ClosePrinter(hPrinter);
-            }
-         else
-            WARN(" Call to OpenPrinter did not succeed!\n");
-         break;
-*/       MessageBoxA(hDlg, "Not implemented yet!", "PRINT", MB_OK);
-        }
-     case cmb4:                         /* Printer combobox */
-        if (HIWORD(wParam)==CBN_SELCHANGE)
-           {
-            int i;
-        	char   PrinterName[256];
-
-            /* look the newly selected Printer up in 
-             * our array Printer_Info2As
-             */
-        	GetDlgItemTextA(hDlg, cmb4, PrinterName, 255);
-            for (i=0; i < PrintStructures->NrOfPrinterInfoEntries; i++)
-           	   {
-                if (strcmp(PrintStructures->lpPrinterInfo[i].pPrinterName, 
-                           PrinterName)==0)
-                     break;
-               }
-            PrintStructures->CurrentPrinter = i;   
-	    PRINTDLG_UpdatePrinterInfoTexts(hDlg, PrintStructures);
-	    lppi = &(PrintStructures->lpPrinterInfo
-                                       [PrintStructures->CurrentPrinter]);
-            if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE ||
-                lppd->Flags & PD_USEDEVMODECOPIES)
-        	{
-	         /* if printer doesn't support it: no nCopies */
-	 	 if (!(lppi->pDevMode->dmFields & DM_COPIES))
-		    {
-			EnableWindow(GetDlgItem(hDlg, edt3), FALSE);    
-			EnableWindow(GetDlgItem(hDlg, stc5), FALSE);    
-		    }
-		 else
-		    {
-			EnableWindow(GetDlgItem(hDlg, edt3), TRUE);    
-			EnableWindow(GetDlgItem(hDlg, stc5), TRUE);    
-		    }
-	         /* if printer doesn't support it: no Collate */
-	 	 if (!(lppi->pDevMode->dmFields & DM_COPIES))
-		    {
-			EnableWindow(GetDlgItem(hDlg, ico3), FALSE);    
-			EnableWindow(GetDlgItem(hDlg, chx2), FALSE);    
-		    }
-		 else
-		    {
-			EnableWindow(GetDlgItem(hDlg, ico3), TRUE);
-			EnableWindow(GetDlgItem(hDlg, chx2), TRUE);
-		    }
-		}
-
-           }
-        break;
-    }
-    return FALSE;
-}    
-
-
-/***********************************************************************
- *                  PRINTSETUP32DLG_WMCommand               [internal]
- */
-static LRESULT PRINTSETUP32DLG_WMCommand(HWND hDlg, WPARAM wParam, 
-			LPARAM lParam, PRINT_PTRA* PrintStructures)
-{
-    LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
-    LPPRINTER_INFO_2A lppi = &(PrintStructures->lpPrinterInfo
-                                        [PrintStructures->CurrentPrinter]);
-    
-
-    switch (LOWORD(wParam)) 
-    {
-     case IDOK:
-        TRACE(" OK button was hit\n");
-        if (PRINTSETUP32DLG_ValidateAndDuplicateSettings(hDlg, PrintStructures) != TRUE)
-        	return(FALSE);
-        DestroyWindow(hDlg);
-        return(TRUE);
-     case IDCANCEL:
-        TRACE(" CANCEL button was hit\n");
-        EndDialog(hDlg, FALSE);
-        return(FALSE);
-     case pshHelp:
-        TRACE(" HELP button was hit\n");
-        SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 
-        			(WPARAM) hDlg, (LPARAM) lppd);
-        break;
-     case psh2:                         /* Properties button */
-       MessageBoxA(hDlg, "Not implemented yet!", "PRINT SETUP", MB_OK);
-       break;
-     case cmb1:                         /* Printer combobox */
-        if (HIWORD(wParam)==CBN_SELCHANGE)
-           {
-            int i;
-        	char   Name[256];
-
-            /* look the newly selected Printer up in 
-             * our array Printer_Info2As
-             */
-        	GetDlgItemTextA(hDlg, cmb1, Name, 255);
-            for (i=0; i < PrintStructures->NrOfPrinterInfoEntries; i++)
-           	   {
-                if (strcmp(PrintStructures->lpPrinterInfo[i].pPrinterName, 
-                           Name)==0)
-                     break;
-               }
-            PrintStructures->CurrentPrinter = i;   
-            PRINTDLG_UpdatePrinterInfoTexts(hDlg, PrintStructures);
-            lppi = &(PrintStructures->
-                        lpPrinterInfo[PrintStructures->CurrentPrinter]);
-                    
-            /* Update both ComboBoxes to the items available for the new
-             * printer. Keep the same entry selected, if possible
-             */
-            PRINTSETUP32DLG_UpdateComboBox(hDlg, cmb2, lppi->pPrinterName,
-                                             lppi->pPortName);
-            PRINTSETUP32DLG_UpdateComboBox(hDlg, cmb3, lppi->pPrinterName,
-                                             lppi->pPortName);
-           }
-        break;
-    }
-    return FALSE;
-}    
-
-
-/***********************************************************************
- *           PrintDlgProcA			[internal]
- */
-LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
-                                    LPARAM lParam)
-{
-  PRINT_PTRA* PrintStructures;
-  LRESULT res=FALSE;
-  if (uMsg!=WM_INITDIALOG)
-  {
-   PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);   
-   if (!PrintStructures)
-    return FALSE;
-}
-  else
-  {
-    PrintStructures=(PRINT_PTRA*) lParam;
-    if (!PRINTDLG_WMInitDialog(hDlg, wParam, lParam, PrintStructures)) 
-    {
-      TRACE("PRINTDLG_WMInitDialog returned FALSE\n");
-      return FALSE;
-    }  
-  }
-  switch (uMsg)
-  {
-  	case WM_COMMAND:
-       return PRINTDLG_WMCommand(hDlg, wParam, lParam, PrintStructures);
-    case WM_DESTROY:
-	    return FALSE;
-  }
-  
- return res;
-}
-
-
-
 
 /***********************************************************************
  *           PrintDlgProc16   (COMMDLG.21)
@@ -1207,10 +1073,10 @@
 
 
 /***********************************************************************
- *           PrintSetupDlgProc   (COMMDLG.22)
+ *           PrintSetupDlgProc16   (COMMDLG.22)
  */
 LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
-                                 LPARAM lParam)
+				   LPARAM lParam)
 {
   switch (wMsg)
     {
@@ -1234,54 +1100,98 @@
 
 
 /***********************************************************************
- *           PrintSetupDlgProcA			[???]
+ *           PrintDlg16   (COMMDLG.20)
+ * 
+ *  Displays the the PRINT dialog box, which enables the user to specify
+ *  specific properties of the print job.
  *
- *   FIXME:
- *   note: I don't know whether this function actually is allowed
- *         to exist (i.e. is exported/overrideable from the DLL)
- *         For now, this function is local only.
- *         If necessary, this call can be merged with PrintDlgProcA,
- *         as it is very similar.
+ * RETURNS
+ *  nonzero if the user pressed the OK button
+ *  zero    if the user cancelled the window or an error occurred
+ *
+ * BUGS
+ *  * calls up to the 32-bit versions of the Dialogs, which look different
+ *  * Customizing is *not* implemented.
  */
-LRESULT WINAPI PrintSetupDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
-                                    LPARAM lParam)
+BOOL16 WINAPI PrintDlg16( LPPRINTDLG16 lpPrint )
 {
-  PRINT_PTRA* PrintStructures;
-  LRESULT res=FALSE;
-  if (uMsg!=WM_INITDIALOG)
-  {
-   PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);   
-   if (!PrintStructures)
-    return FALSE;
-}
-  else
-  {
-    PrintStructures=(PRINT_PTRA*) lParam;
-    if (!PRINTSETUP32DLG_WMInitDialog(hDlg, wParam, lParam, PrintStructures)) 
-    {
-      TRACE("PRINTSETUP32DLG_WMInitDialog returned FALSE\n");
-      return FALSE;
-    }  
-  }
-  switch (uMsg)
-  {
-  	case WM_COMMAND:
-       return PRINTSETUP32DLG_WMCommand(hDlg, wParam, lParam, PrintStructures);
-    case WM_DESTROY:
-	    return FALSE;
-  }
-  
- return res;
+    PRINTDLGA Print32;
+    BOOL16 ret;
+    char *ptr, *ptr16;
+    DWORD size;
+
+    memset(&Print32, 0, sizeof(Print32));
+    Print32.lStructSize = sizeof(Print32);
+    Print32.hwndOwner   = lpPrint->hwndOwner;
+    if(lpPrint->hDevMode) {
+        size = GlobalSize16(lpPrint->hDevMode);
+        Print32.hDevMode = GlobalAlloc(GMEM_MOVEABLE, size);
+	ptr = GlobalLock(Print32.hDevMode);
+	ptr16 = GlobalLock16(lpPrint->hDevMode);
+	memcpy(ptr, ptr16, size);
+	GlobalFree16(lpPrint->hDevMode);
+	GlobalUnlock(Print32.hDevMode);
+    } else
+        Print32.hDevMode = 0;
+    if(lpPrint->hDevNames) {
+        size = GlobalSize16(lpPrint->hDevNames);
+        Print32.hDevNames = GlobalAlloc(GMEM_MOVEABLE, size);
+	ptr = GlobalLock(Print32.hDevNames);
+	ptr16 = GlobalLock16(lpPrint->hDevNames);
+	memcpy(ptr, ptr16, size);
+	GlobalFree16(lpPrint->hDevNames);
+	GlobalUnlock(Print32.hDevNames);
+    } else
+        Print32.hDevNames = 0;
+    Print32.Flags       = lpPrint->Flags;
+    Print32.nFromPage   = lpPrint->nFromPage;
+    Print32.nToPage     = lpPrint->nToPage;
+    Print32.nMinPage    = lpPrint->nMinPage;
+    Print32.nMaxPage    = lpPrint->nMaxPage;
+    Print32.nCopies     = lpPrint->nCopies;
+    Print32.hInstance   = lpPrint->hInstance;
+    Print32.lCustData   = lpPrint->lCustData;
+    if(lpPrint->lpfnPrintHook) {
+        FIXME("Need to allocate thunk\n");
+/*        Print32.lpfnPrintHook = lpPrint->lpfnPrintHook;*/
+    }
+    if(lpPrint->lpfnSetupHook) {
+        FIXME("Need to allocate thunk\n");
+/*	Print32.lpfnSetupHook = lpPrint->lpfnSetupHook;*/
+    }
+    Print32.lpPrintTemplateName = PTR_SEG_TO_LIN(lpPrint->lpPrintTemplateName);
+    Print32.lpSetupTemplateName = PTR_SEG_TO_LIN(lpPrint->lpSetupTemplateName);
+    Print32.hPrintTemplate = lpPrint->hPrintTemplate;
+    Print32.hSetupTemplate = lpPrint->hSetupTemplate;
+
+    ret = PrintDlgA(&Print32);
+
+    if(Print32.hDevMode) {
+        size = GlobalSize(Print32.hDevMode);
+	lpPrint->hDevMode = GlobalAlloc16(GMEM_MOVEABLE, size);
+	ptr16 = GlobalLock16(lpPrint->hDevMode);
+	ptr = GlobalLock(Print32.hDevMode);
+	memcpy(ptr16, ptr, size);
+	GlobalFree(Print32.hDevMode);
+	GlobalUnlock16(lpPrint->hDevMode);
+    } else
+        lpPrint->hDevMode = 0;
+    if(Print32.hDevNames) {
+        size = GlobalSize(Print32.hDevNames);
+	lpPrint->hDevNames = GlobalAlloc16(GMEM_MOVEABLE, size);
+	ptr16 = GlobalLock16(lpPrint->hDevNames);
+	ptr = GlobalLock(Print32.hDevNames);
+	memcpy(ptr16, ptr, size);
+	GlobalFree(Print32.hDevNames);
+	GlobalUnlock16(lpPrint->hDevNames);
+    } else
+        lpPrint->hDevNames = 0;
+    lpPrint->hDC       = Print32.hDC;
+    lpPrint->Flags     = Print32.Flags;
+    lpPrint->nFromPage = Print32.nFromPage;
+    lpPrint->nToPage   = Print32.nToPage;
+    lpPrint->nCopies   = Print32.nCopies;
+
+    return ret;
 }
 
-
-
-
-
-/***********************************************************************
- *            PageSetupDlgA  (COMDLG32.15)
- */
-BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {
-	FIXME("(%p), stub!\n",setupdlg);
-	return FALSE;
-}
diff --git a/include/commdlg.h b/include/commdlg.h
index d046e4c..1839ccd 100644
--- a/include/commdlg.h
+++ b/include/commdlg.h
@@ -48,34 +48,10 @@
 #define SAVE_DIALOG  1
 #define OPEN_DIALOG  2
     
-typedef UINT16 (CALLBACK *LPOFNHOOKPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
 typedef UINT (CALLBACK *LPOFNHOOKPROC)(HWND,UINT,WPARAM,LPARAM);
 
 typedef struct {
 	DWORD		lStructSize;
-	HWND16		hwndOwner;
-	HINSTANCE16	hInstance;
-	SEGPTR	        lpstrFilter;
-	SEGPTR          lpstrCustomFilter;
-	DWORD		nMaxCustFilter;
-	DWORD		nFilterIndex;
-	SEGPTR          lpstrFile;
-	DWORD		nMaxFile;
-	SEGPTR		lpstrFileTitle;
-	DWORD		nMaxFileTitle;
-	SEGPTR 		lpstrInitialDir;
-	SEGPTR 		lpstrTitle;
-	DWORD		Flags;
-	UINT16		nFileOffset;
-	UINT16		nFileExtension;
-	SEGPTR		lpstrDefExt;
-	LPARAM 		lCustData;
-	LPOFNHOOKPROC16 lpfnHook;
-	SEGPTR 		lpTemplateName;
-}   OPENFILENAME16,*LPOPENFILENAME16;
-
-typedef struct {
-	DWORD		lStructSize;
 	HWND		hwndOwner;
 	HINSTANCE	hInstance;
 	LPCSTR		lpstrFilter;
@@ -140,24 +116,10 @@
 DECL_WINELIB_TYPE_AW(OFNOTIFY)
 DECL_WINELIB_TYPE_AW(LPOFNOTIFY)
  
-typedef UINT16 (CALLBACK *LPCCHOOKPROC16) (HWND16, UINT16, WPARAM16, LPARAM);
 typedef UINT (CALLBACK *LPCCHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
 
 typedef struct {
 	DWORD		lStructSize;
-	HWND16		hwndOwner;
-	HWND16		hInstance;
-	COLORREF	rgbResult;
-	COLORREF       *lpCustColors;
-	DWORD 		Flags;
-	LPARAM		lCustData;
-        LPCCHOOKPROC16  lpfnHook;
-	SEGPTR 		lpTemplateName;
-} CHOOSECOLOR16;
-typedef CHOOSECOLOR16 *LPCHOOSECOLOR16;
-
-typedef struct {
-	DWORD		lStructSize;
 	HWND		hwndOwner;
 	HWND		hInstance;
 	DWORD	        rgbResult;
@@ -194,29 +156,12 @@
 #define CC_ENABLETEMPLATE        0x00000020
 #define CC_ENABLETEMPLATEHANDLE  0x00000040
 
-typedef UINT16 (CALLBACK *LPFRHOOKPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
 typedef UINT (CALLBACK *LPFRHOOKPROC)(HWND,UINT,WPARAM,LPARAM);
 
 typedef struct {
-	DWORD		lStructSize; 			/* size of this struct 0x20 */
-	HWND16		hwndOwner; 				/* handle to owner's window */
-	HINSTANCE16	hInstance; 				/* instance handle of.EXE that  */
-										/*	contains cust. dlg. template */
-	DWORD		Flags;                  /* one or more of the FR_?? */
-	SEGPTR		lpstrFindWhat;          /* ptr. to search string    */
-	SEGPTR		lpstrReplaceWith;       /* ptr. to replace string   */
-	UINT16		wFindWhatLen;           /* size of find buffer      */
-	UINT16 		wReplaceWithLen;        /* size of replace buffer   */
-	LPARAM 		lCustData;              /* data passed to hook fn.  */
-        LPFRHOOKPROC16  lpfnHook;
-	SEGPTR 		lpTemplateName;         /* custom template name     */
-	} FINDREPLACE16, *LPFINDREPLACE16;
-
-typedef struct {
 	DWORD		lStructSize;
 	HWND		hwndOwner;
 	HINSTANCE	hInstance;
-
 	DWORD		Flags;
 	LPSTR		lpstrFindWhat;
 	LPSTR		lpstrReplaceWith;
@@ -225,13 +170,12 @@
 	LPARAM 		lCustData;
         LPFRHOOKPROC    lpfnHook;
 	LPCSTR 		lpTemplateName;
-	} FINDREPLACEA, *LPFINDREPLACEA;
+} FINDREPLACEA, *LPFINDREPLACEA;
 
 typedef struct {
 	DWORD		lStructSize;
 	HWND		hwndOwner;
 	HINSTANCE	hInstance;
-
 	DWORD		Flags;
 	LPWSTR		lpstrFindWhat;
 	LPWSTR		lpstrReplaceWith;
@@ -240,7 +184,7 @@
 	LPARAM 		lCustData;
         LPFRHOOKPROC    lpfnHook;
 	LPCWSTR		lpTemplateName;
-	} FINDREPLACEW, *LPFINDREPLACEW;
+} FINDREPLACEW, *LPFINDREPLACEW;
 	
 DECL_WINELIB_TYPE_AW(FINDREPLACE)
 DECL_WINELIB_TYPE_AW(LPFINDREPLACE)
@@ -263,34 +207,8 @@
 #define FR_HIDEMATCHCASE                0x00008000
 #define FR_HIDEWHOLEWORD                0x00010000
 
-typedef UINT16 (CALLBACK *LPCFHOOKPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
 typedef UINT (CALLBACK *LPCFHOOKPROC)(HWND,UINT,WPARAM,LPARAM);
 
-typedef struct 
-{
-	DWORD			lStructSize;
-	HWND16			hwndOwner;          /* caller's window handle   */
-	HDC16          	        hDC;                /* printer DC/IC or NULL    */
-	SEGPTR                  lpLogFont;          /* ptr. to a LOGFONT struct */
-	short			iPointSize;         /* 10 * size in points of selected font */
-	DWORD			Flags;  /* enum. type flags         */
-	COLORREF		rgbColors;          /* returned text color      */
-	LPARAM	                lCustData;          /* data passed to hook fn.  */
-	LPCFHOOKPROC16          lpfnHook;
-	SEGPTR			lpTemplateName;     /* custom template name     */
-	HINSTANCE16		hInstance;          /* instance handle of.EXE that   */
-							/* contains cust. dlg. template  */
-	SEGPTR			lpszStyle;  /* return the style field here   */
-							/* must be LF_FACESIZE or bigger */
-	UINT16			nFontType;          	/* same value reported to the    */
-						    	/* EnumFonts callback with the   */
-							/* extra FONTTYPE_ bits added    */
-	short			nSizeMin;   /* minimum pt size allowed & */
-	short			nSizeMax;   /* max pt size allowed if    */
-							/* CF_LIMITSIZE is used      */
-} CHOOSEFONT16, *LPCHOOSEFONT16;
-
-
 typedef struct
 {
 	UINT  	lStructSize; 
@@ -443,35 +361,9 @@
         (void)SNDMSG(_hdlg, CDM_SETDEFEXT, 0, (LPARAM)(LPSTR)_pszext)
 
 
-typedef UINT16 (CALLBACK *LPPRINTHOOKPROC16) (HWND16, UINT16, WPARAM16, LPARAM);
 typedef UINT (CALLBACK *LPPRINTHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
-
-typedef UINT16 (CALLBACK *LPSETUPHOOKPROC16) (HWND16, UINT16, WPARAM16, LPARAM);
 typedef UINT (CALLBACK *LPSETUPHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
 
-typedef struct
-{
-    DWORD            lStructSize;
-    HWND16           hwndOwner;
-    HGLOBAL16        hDevMode;
-    HGLOBAL16        hDevNames;
-    HDC16            hDC;
-    DWORD            Flags;
-    WORD             nFromPage;
-    WORD             nToPage;
-    WORD             nMinPage;
-    WORD             nMaxPage;
-    WORD             nCopies;
-    HINSTANCE16      hInstance;
-    LPARAM           lCustData;
-    LPPRINTHOOKPROC16 lpfnPrintHook;
-    LPSETUPHOOKPROC16 lpfnSetupHook;
-    SEGPTR           lpPrintTemplateName;
-    SEGPTR           lpSetupTemplateName;
-    HGLOBAL16        hPrintTemplate;
-    HGLOBAL16        hSetupTemplate;
-} PRINTDLG16, *LPPRINTDLG16;
-
 typedef struct tagPDA
 {
     DWORD            lStructSize;
@@ -544,6 +436,7 @@
 #define PD_USEDEVMODECOPIESANDCOLLATE 0x00040000
 #define PD_DISABLEPRINTTOFILE        0x00080000
 #define PD_HIDEPRINTTOFILE           0x00100000
+#define PD_NONETWORKBUTTON           0x00200000
 
 typedef struct {
 	UINT16 	wDriverOffset;
@@ -625,57 +518,35 @@
 #define PSD_ENABLEPAGEPAINTHOOK           0x00040000
 #define PSD_DISABLEPAGEPAINTING           0x00080000
 
-BOOL16  WINAPI ChooseColor16(LPCHOOSECOLOR16 lpChCol);
+
 BOOL  WINAPI ChooseColorA(LPCHOOSECOLORA lpChCol);
 BOOL  WINAPI ChooseColorW(LPCHOOSECOLORW lpChCol);
 #define ChooseColor WINELIB_NAME_AW(ChooseColor)
 DWORD   WINAPI CommDlgExtendedError(void);
-HWND16  WINAPI FindText16( SEGPTR find);
 HWND  WINAPI FindTextA(LPFINDREPLACEA lpFind);
 HWND  WINAPI FindTextW(LPFINDREPLACEW lpFind);
 #define FindText WINELIB_NAME_AW(FindText)
-INT16   WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf);
-INT16   WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf);
-INT16   WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf);
+short   WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf);
+short   WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf);
 #define GetFileTitle WINELIB_NAME_AW(GetFileTitle)
-BOOL16  WINAPI GetOpenFileName16(SEGPTR ofn);
 BOOL  WINAPI GetOpenFileNameA(LPOPENFILENAMEA ofn);
 BOOL  WINAPI GetOpenFileNameW(LPOPENFILENAMEW ofn);
-BOOL  WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType);
-BOOL  WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType);
 #define GetOpenFileName WINELIB_NAME_AW(GetOpenFileName)
-BOOL16  WINAPI GetSaveFileName16(SEGPTR ofn);
 BOOL  WINAPI GetSaveFileNameA(LPOPENFILENAMEA ofn);
 BOOL  WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn);
 #define GetSaveFileName WINELIB_NAME_AW(GetSaveFileName)
 BOOL WINAPI PageSetupDlgA( LPPAGESETUPDLGA );
 BOOL WINAPI PageSetupDlgW( LPPAGESETUPDLGW );
 #define PageSetupDlg WINELIB_NAME_AW(PageSetupDlg)
-BOOL16  WINAPI PrintDlg16( LPPRINTDLG16 print);
 BOOL  WINAPI PrintDlgA( LPPRINTDLGA printdlg);
 BOOL  WINAPI PrintDlgW( LPPRINTDLGW printdlg);
 #define PrintDlg WINELIB_NAME_AW(PrintDlg)
-HWND16  WINAPI ReplaceText16( SEGPTR find);
 HWND  WINAPI ReplaceTextA( LPFINDREPLACEA lpFind);
 HWND  WINAPI ReplaceTextW( LPFINDREPLACEW lpFind);
 #define ReplaceText WINELIB_NAME_AW(ReplaceText)
-BOOL16  WINAPI ChooseFont16(LPCHOOSEFONT16);
 BOOL  WINAPI ChooseFontA(LPCHOOSEFONTA);
 BOOL  WINAPI ChooseFontW(LPCHOOSEFONTW);
 #define ChooseFont WINELIB_NAME_AW(ChooseFont)
-LRESULT WINAPI FileOpenDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT WINAPI FileSaveDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT WINAPI ColorDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT WINAPI FindTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT WINAPI ReplaceTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT WINAPI PrintDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT WINAPI PrintDlgProcA(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
-LRESULT WINAPI PrintDlgProcW(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
-LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT WINAPI FormatCharDlgProc16(HWND16,UINT16,WPARAM16,LPARAM);
-LRESULT WINAPI FormatCharDlgProcA(HWND,UINT,WPARAM,LPARAM);
-LRESULT WINAPI FormatCharDlgProcW(HWND,UINT,WPARAM,LPARAM);
-#define FormatCharDlgProc WINELIB_NAME_AW(FormatCharDlgProc)
 
 void COMDLG32_SetCommDlgExtendedError(DWORD err);