[PATCH] 16 bits print dialog
gerard patel
gerard.patel at asi.fr
Sun Feb 25 07:53:02 CST 2001
As it's rather unlikely anyone will craft 16 bits specific resources now, I have
mapped the 32 bits resource into 16 bit ones
I did not test if 16 bits printing still works, but the print dialog box displays again
at least.
There is also a minor fix to cast the return value for the 16 bits hook to 16 bits.
ChangeLog:
* dlls/commdlg/printdlg.c
maps 32 bits resource for 16 bits print dialog.
-------------- next part --------------
Index: dlls/commdlg/printdlg.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/printdlg.c,v
retrieving revision 1.37
diff -u -r1.37 printdlg.c
--- dlls/commdlg/printdlg.c 2001/02/12 19:42:08 1.37
+++ dlls/commdlg/printdlg.c 2001/02/25 13:49:43
@@ -47,7 +47,7 @@
HWND hwndUpDown;
} PRINT_PTRA;
-/* Debugiging info */
+/* Debugging info */
static struct pd_flags {
DWORD flag;
LPSTR name;
@@ -1049,8 +1049,56 @@
return res;
}
+
/************************************************************
*
+ * PRINTDLG_Get16TemplateFrom32 [Internal]
+ * Generates a 16 bits template from the Wine 32 bits resource
+ *
+ */
+static HGLOBAL16 PRINTDLG_Get16TemplateFrom32(char *PrintResourceName)
+{
+ HANDLE hResInfo, hDlgTmpl32;
+ LPCVOID template32;
+ DWORD size;
+ HGLOBAL16 hGlobal16;
+ LPVOID template;
+
+ if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
+ PrintResourceName, RT_DIALOGA)))
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
+ return 0;
+ }
+ if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
+ !(template32 = LockResource( hDlgTmpl32 )))
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
+ return 0;
+ }
+ size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
+ hGlobal16 = GlobalAlloc16(0, size);
+ if (!hGlobal16)
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
+ ERR("alloc failure for %ld bytes\n", size);
+ return 0;
+ }
+ template = GlobalLock16(hGlobal16);
+ if (!template)
+ {
+ COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
+ ERR("global lock failure for %x handle\n", hGlobal16);
+ GlobalFree16(hGlobal16);
+ return 0;
+ }
+ ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
+ GlobalUnlock16(hGlobal16);
+ return hGlobal16;
+}
+
+/************************************************************
+ *
* PRINTDLG_GetDlgTemplate
*
*/
@@ -1104,8 +1152,7 @@
MapSL(lppd->lpSetupTemplateName), RT_DIALOGA);
hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
} else {
- ERR("no comctl32 templates for printing setup currently!\n");
- hDlgTmpl = 0;
+ hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP");
}
} else {
if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
@@ -1116,8 +1163,7 @@
RT_DIALOGA);
hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo);
} else {
- ERR("no comctl32 templates for printing currently!\n");
- hDlgTmpl = 0;
+ hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32");
}
}
return hDlgTmpl;
@@ -1474,6 +1520,8 @@
lpdmReturn->dmDeviceName, pi->pPortName);
GlobalUnlock16(lppd->hDevMode);
}
+ if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE)))
+ GlobalFree16(hDlgTmpl); /* created from the 32 bits resource */
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
HeapFree(GetProcessHeap(), 0, PrintStructures);
@@ -1553,7 +1601,7 @@
(WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook,
hDlg,uMsg, wParam, lParam
);
- if(res) return res;
+ if(LOWORD(res)) return res;
}
switch (uMsg) {
-------------- next part --------------
More information about the wine-patches
mailing list