This is last patch that should create any new files. After this almost every Win16 function can be compiled out although quite a few of the internal and Win32 functions still call the Win16 api. I am starting to work on this now.
Changelog: Split Win16/32 print dialog support.
Index: Makefile.in =================================================================== RCS file: /home/wine/wine/dlls/commdlg/Makefile.in,v retrieving revision 1.31 diff -u -r1.31 Makefile.in --- Makefile.in 16 Jun 2003 01:19:16 -0000 1.31 +++ Makefile.in 19 Jun 2003 15:40:15 -0000 @@ -28,7 +28,8 @@ colordlg16.c \ filedlg16.c \ finddlg.c \ - fontdlg16.c + fontdlg16.c \ + printdlg16.c
RC_SRCS= rsrc.rc
Index: printdlg.c =================================================================== RCS file: /home/wine/wine/dlls/commdlg/printdlg.c,v retrieving revision 1.65 diff -u -r1.65 printdlg.c --- printdlg.c 18 Jun 2003 03:30:41 -0000 1.65 +++ printdlg.c 19 Jun 2003 15:39:11 -0000 @@ -43,6 +43,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
#include "cdlg.h" +#include "printdlg.h"
/* This PRINTDLGA internal structure stores * pointers to several throughout useful structures. @@ -50,23 +51,6 @@ */ typedef struct { - LPDEVMODEA lpDevMode; - struct { - LPPRINTDLGA lpPrintDlg; - LPPRINTDLG16 lpPrintDlg16; - } dlg; - LPPRINTER_INFO_2A lpPrinterInfo; - LPDRIVER_INFO_3A lpDriverInfo; - UINT HelpMessageID; - HICON hCollateIcon; /* PrintDlg only */ - HICON hNoCollateIcon; /* PrintDlg only */ - HICON hPortraitIcon; /* PrintSetupDlg only */ - HICON hLandscapeIcon; /* PrintSetupDlg only */ - HWND hwndUpDown; -} PRINT_PTRA; - -typedef struct -{ LPDEVMODEW lpDevMode; struct { LPPRINTDLGW lpPrintDlg; @@ -145,7 +129,7 @@ * * Returns TRUE on success else FALSE */ -static BOOL PRINTDLG_GetDefaultPrinterNameA(LPSTR buf, DWORD len) +BOOL PRINTDLG_GetDefaultPrinterNameA(LPSTR buf, DWORD len) { char *ptr;
@@ -215,7 +199,7 @@ * * Returns number of printers added to list. */ -static INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name) +INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name) { DWORD needed, num; INT i; @@ -1005,7 +989,7 @@ * PRINTDLG_ChangePrinter * */ -static BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, +BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, PRINT_PTRA *PrintStructures) { LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; @@ -1540,127 +1524,10 @@ return TRUE; }
- -/*********************************************************************** - * PRINTDLG_WMInitDialog [internal] - */ -static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam, - PRINT_PTRA* PrintStructures) -{ - LPPRINTDLG16 lppd = PrintStructures->dlg.lpPrintDlg16; - 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(HELPMSGSTRINGA)) == 0) { - COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); - return FALSE; - } - } else - PrintStructures->HelpMessageID = 0; - - if (!(lppd->Flags & PD_PRINTSETUP)) { - /* We have a print quality combo box. What shall we do? */ - if (GetDlgItem(hDlg,cmb1)) { - char buf [20]; - - FIXME("Print quality only displaying currently.\n"); - - pdm = GlobalLock16(lppd->hDevMode); - if(pdm) { - switch (pdm->dmPrintQuality) { - case DMRES_HIGH : strcpy(buf,"High");break; - case DMRES_MEDIUM : strcpy(buf,"Medium");break; - case DMRES_LOW : strcpy(buf,"Low");break; - case DMRES_DRAFT : strcpy(buf,"Draft");break; - case 0 : strcpy(buf,"Default");break; - default : sprintf(buf,"%ddpi",pdm->dmPrintQuality);break; - } - GlobalUnlock16(lppd->hDevMode); - } else - strcpy(buf,"Default"); - SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf); - SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0); - EnableWindow(GetDlgItem(hDlg,cmb1),FALSE); - } - } - - /* 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; - - /* If the printer combo box is in the dialog, fill it */ - if (GetDlgItem(hDlg,comboID)) { - /* Fill Combobox - */ - pdn = GlobalLock16(lppd->hDevNames); - pdm = GlobalLock16(lppd->hDevMode); - if(pdn) - name = (char*)pdn + pdn->wDeviceOffset; - else if(pdm) - name = pdm->dmDeviceName; - PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name); - if(pdm) GlobalUnlock16(lppd->hDevMode); - if(pdn) GlobalUnlock16(lppd->hDevNames); - - /* Now find selected printer and update rest of dlg */ - name = HeapAlloc(GetProcessHeap(),0,256); - if (GetDlgItemTextA(hDlg, comboID, name, 255)) - PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); - } else { - /* else just use default printer */ - char name[200]; - BOOL ret = PRINTDLG_GetDefaultPrinterNameA(name, sizeof(name)); - - if (ret) - PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); - else - FIXME("No default printer found, expect problems!\n"); - } - HeapFree(GetProcessHeap(),0,name); - - return TRUE; -} - /*********************************************************************** * PRINTDLG_WMCommand [internal] */ -static LRESULT PRINTDLG_WMCommandA(HWND hDlg, WPARAM wParam, +LRESULT PRINTDLG_WMCommandA(HWND hDlg, WPARAM wParam, LPARAM lParam, PRINT_PTRA* PrintStructures) { LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; @@ -3462,98 +3329,6 @@ ); return bRet; } - -/********************************************************************** - * - * 16 bit commdlg - */ - -/*********************************************************************** - * PrintDlgProc (COMMDLG.21) - */ -BOOL16 CALLBACK PrintDlgProc16(HWND16 hDlg16, UINT16 uMsg, WPARAM16 wParam, - LPARAM lParam) -{ - HWND hDlg = HWND_32(hDlg16); - PRINT_PTRA* PrintStructures; - BOOL16 res = FALSE; - - if (uMsg!=WM_INITDIALOG) { - PrintStructures = (PRINT_PTRA*)GetPropA(hDlg,"__WINE_PRINTDLGDATA"); - if (!PrintStructures) - return FALSE; - } else { - PrintStructures = (PRINT_PTRA*) lParam; - SetPropA(hDlg,"__WINE_PRINTDLGDATA",PrintStructures); - res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures); - - if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { - res = CallWindowProc16( - (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, - hDlg16, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16 - ); - } - return res; - } - - if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { - res = CallWindowProc16( - (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, - hDlg16,uMsg, wParam, lParam - ); - if(LOWORD(res)) return res; - } - - switch (uMsg) { - case WM_COMMAND: { - /* We need to map those for the 32bit window procedure, compare - * with 32Ato16 mapper in winproc.c - */ - return PRINTDLG_WMCommandA( - hDlg, - MAKEWPARAM(wParam,HIWORD(lParam)), - LOWORD(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; -} - - -/*********************************************************************** - * PrintSetupDlgProc (COMMDLG.22) - */ -BOOL16 CALLBACK PrintSetupDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam, - LPARAM lParam) -{ - HWND hWnd = HWND_32(hWnd16); - switch (wMsg) - { - case WM_INITDIALOG: - TRACE("WM_INITDIALOG lParam=%08lX\n", lParam); - ShowWindow(hWnd, SW_SHOWNORMAL); - return (TRUE); - case WM_COMMAND: - switch (wParam) { - case IDOK: - EndDialog(hWnd, TRUE); - return(TRUE); - case IDCANCEL: - EndDialog(hWnd, FALSE); - return(TRUE); - } - return(FALSE); - } - return FALSE; -} -
/*********************************************************************** * PrintDlgExA (COMDLG32.@)
--- /dev/null Thu Jun 19 11:40:24 2003 +++ printdlg.h Thu Jun 19 11:40:22 2003 @@ -0,0 +1,65 @@ +/* + * COMMDLG - Print Dialog + * + * Copyright 1994 Martin Ayotte + * Copyright 1996 Albrecht Kleine + * Copyright 1999 Klaas van Gend + * Copyright 2000 Huw D M Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _WINE_PRINTDLG_H +#define _WINE_PRINTDLG_H + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT + +#include "cdlg.h" + +/* This PRINTDLGA internal structure stores + * pointers to several throughout useful structures. + * + */ +typedef struct +{ + LPDEVMODEA lpDevMode; + struct { + LPPRINTDLGA lpPrintDlg; + LPPRINTDLG16 lpPrintDlg16; + } dlg; + LPPRINTER_INFO_2A lpPrinterInfo; + LPDRIVER_INFO_3A lpDriverInfo; + UINT HelpMessageID; + HICON hCollateIcon; /* PrintDlg only */ + HICON hNoCollateIcon; /* PrintDlg only */ + HICON hPortraitIcon; /* PrintSetupDlg only */ + HICON hLandscapeIcon; /* PrintSetupDlg only */ + HWND hwndUpDown; +} PRINT_PTRA; + +/* Internal Functions + * Do not Export to other Apps or Dlls. + */ + +INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name); +BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, + PRINT_PTRA *PrintStructures); +BOOL PRINTDLG_GetDefaultPrinterNameA(LPSTR buf, DWORD len); +LRESULT PRINTDLG_WMCommandA(HWND hDlg, WPARAM wParam, + LPARAM lParam, PRINT_PTRA* PrintStructures); + +#endif /* _WINE_PRINTDLG_H */ +
--- /dev/null Thu Jun 19 11:42:09 2003 +++ printdlg16.c Thu Jun 19 11:33:18 2003 @@ -0,0 +1,252 @@ +/* + * COMMDLG - Print Dialog + * + * Copyright 1994 Martin Ayotte + * Copyright 1996 Albrecht Kleine + * Copyright 1999 Klaas van Gend + * Copyright 2000 Huw D M Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <ctype.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "wine/wingdi16.h" +#include "winuser.h" +#include "wine/winuser16.h" +#include "commdlg.h" +#include "dlgs.h" +#include "wine/debug.h" +#include "cderr.h" +#include "winspool.h" +#include "winerror.h" + +WINE_DEFAULT_DEBUG_CHANNEL(commdlg); + +#include "printdlg.h" + +/*********************************************************************** + * PRINTDLG_WMInitDialog [internal] + */ +static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam, + PRINT_PTRA* PrintStructures) +{ + LPPRINTDLG16 lppd = PrintStructures->dlg.lpPrintDlg16; + 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(HELPMSGSTRINGA)) == 0) { + COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); + return FALSE; + } + } else + PrintStructures->HelpMessageID = 0; + + if (!(lppd->Flags & PD_PRINTSETUP)) { + /* We have a print quality combo box. What shall we do? */ + if (GetDlgItem(hDlg,cmb1)) { + char buf [20]; + + FIXME("Print quality only displaying currently.\n"); + + pdm = GlobalLock16(lppd->hDevMode); + if(pdm) { + switch (pdm->dmPrintQuality) { + case DMRES_HIGH : strcpy(buf,"High");break; + case DMRES_MEDIUM : strcpy(buf,"Medium");break; + case DMRES_LOW : strcpy(buf,"Low");break; + case DMRES_DRAFT : strcpy(buf,"Draft");break; + case 0 : strcpy(buf,"Default");break; + default : sprintf(buf,"%ddpi",pdm->dmPrintQuality);break; + } + GlobalUnlock16(lppd->hDevMode); + } else + strcpy(buf,"Default"); + SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf); + SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0); + EnableWindow(GetDlgItem(hDlg,cmb1),FALSE); + } + } + + /* 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; + + /* If the printer combo box is in the dialog, fill it */ + if (GetDlgItem(hDlg,comboID)) { + /* Fill Combobox + */ + pdn = GlobalLock16(lppd->hDevNames); + pdm = GlobalLock16(lppd->hDevMode); + if(pdn) + name = (char*)pdn + pdn->wDeviceOffset; + else if(pdm) + name = pdm->dmDeviceName; + PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name); + if(pdm) GlobalUnlock16(lppd->hDevMode); + if(pdn) GlobalUnlock16(lppd->hDevNames); + + /* Now find selected printer and update rest of dlg */ + name = HeapAlloc(GetProcessHeap(),0,256); + if (GetDlgItemTextA(hDlg, comboID, name, 255)) + PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); + } else { + /* else just use default printer */ + char name[200]; + BOOL ret = PRINTDLG_GetDefaultPrinterNameA(name, sizeof(name)); + + if (ret) + PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); + else + FIXME("No default printer found, expect problems!\n"); + } + HeapFree(GetProcessHeap(),0,name); + + return TRUE; +} + +/********************************************************************** + * + * 16 bit commdlg + */ + +/*********************************************************************** + * PrintDlgProc (COMMDLG.21) + */ +BOOL16 CALLBACK PrintDlgProc16(HWND16 hDlg16, UINT16 uMsg, WPARAM16 wParam, + LPARAM lParam) +{ + HWND hDlg = HWND_32(hDlg16); + PRINT_PTRA* PrintStructures; + BOOL16 res = FALSE; + + if (uMsg!=WM_INITDIALOG) { + PrintStructures = (PRINT_PTRA*)GetPropA(hDlg,"__WINE_PRINTDLGDATA"); + if (!PrintStructures) + return FALSE; + } else { + PrintStructures = (PRINT_PTRA*) lParam; + SetPropA(hDlg,"__WINE_PRINTDLGDATA",PrintStructures); + res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures); + + if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { + res = CallWindowProc16( + (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, + hDlg16, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16 + ); + } + return res; + } + + if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { + res = CallWindowProc16( + (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, + hDlg16,uMsg, wParam, lParam + ); + if(LOWORD(res)) return res; + } + + switch (uMsg) { + case WM_COMMAND: { + /* We need to map those for the 32bit window procedure, compare + * with 32Ato16 mapper in winproc.c + */ + return PRINTDLG_WMCommandA( + hDlg, + MAKEWPARAM(wParam,HIWORD(lParam)), + LOWORD(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; +} + + +/*********************************************************************** + * PrintSetupDlgProc (COMMDLG.22) + */ +BOOL16 CALLBACK PrintSetupDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam, + LPARAM lParam) +{ + HWND hWnd = HWND_32(hWnd16); + switch (wMsg) + { + case WM_INITDIALOG: + TRACE("WM_INITDIALOG lParam=%08lX\n", lParam); + ShowWindow(hWnd, SW_SHOWNORMAL); + return (TRUE); + case WM_COMMAND: + switch (wParam) { + case IDOK: + EndDialog(hWnd, TRUE); + return(TRUE); + case IDCANCEL: + EndDialog(hWnd, FALSE); + return(TRUE); + } + return(FALSE); + } + return FALSE; +}