1999-02-28 21:05:11 +01:00
|
|
|
/*
|
|
|
|
* COMMDLG - Print Dialog
|
|
|
|
*
|
|
|
|
* Copyright 1994 Martin Ayotte
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
|
|
|
* Copyright 1999 Klaas van Gend
|
2000-05-27 00:26:06 +02:00
|
|
|
* Copyright 2000 Huw D M Davies
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1999-02-28 21:05:11 +01:00
|
|
|
#include <string.h>
|
2009-01-19 16:33:05 +01:00
|
|
|
#include <assert.h>
|
2003-01-07 21:36:20 +01:00
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
2000-05-27 00:26:06 +02:00
|
|
|
#include "winuser.h"
|
2003-10-08 00:51:09 +02:00
|
|
|
#include "winspool.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
2009-01-16 14:51:18 +01:00
|
|
|
#include "wine/unicode.h"
|
2003-10-08 00:51:09 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "commdlg.h"
|
|
|
|
#include "dlgs.h"
|
1999-03-13 18:07:56 +01:00
|
|
|
#include "cderr.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-04-25 20:31:35 +02:00
|
|
|
#include "cdlg.h"
|
2003-08-02 02:41:41 +02:00
|
|
|
#include "printdlg.h"
|
1999-04-25 20:31:35 +02:00
|
|
|
|
2003-08-02 02:41:41 +02:00
|
|
|
/* Yes these constants are the same, but we're just copying win98 */
|
|
|
|
#define UPDOWN_ID 0x270f
|
|
|
|
#define MAX_COPIES 9999
|
1999-08-07 14:34:54 +02:00
|
|
|
|
2001-05-05 02:44:03 +02:00
|
|
|
/* Debugging info */
|
2006-11-29 11:04:52 +01:00
|
|
|
static const struct pd_flags psd_flags[] = {
|
2001-05-05 02:44:03 +02:00
|
|
|
{PSD_MINMARGINS,"PSD_MINMARGINS"},
|
|
|
|
{PSD_MARGINS,"PSD_MARGINS"},
|
|
|
|
{PSD_INTHOUSANDTHSOFINCHES,"PSD_INTHOUSANDTHSOFINCHES"},
|
|
|
|
{PSD_INHUNDREDTHSOFMILLIMETERS,"PSD_INHUNDREDTHSOFMILLIMETERS"},
|
|
|
|
{PSD_DISABLEMARGINS,"PSD_DISABLEMARGINS"},
|
|
|
|
{PSD_DISABLEPRINTER,"PSD_DISABLEPRINTER"},
|
|
|
|
{PSD_NOWARNING,"PSD_NOWARNING"},
|
|
|
|
{PSD_DISABLEORIENTATION,"PSD_DISABLEORIENTATION"},
|
|
|
|
{PSD_RETURNDEFAULT,"PSD_RETURNDEFAULT"},
|
|
|
|
{PSD_DISABLEPAPER,"PSD_DISABLEPAPER"},
|
|
|
|
{PSD_SHOWHELP,"PSD_SHOWHELP"},
|
|
|
|
{PSD_ENABLEPAGESETUPHOOK,"PSD_ENABLEPAGESETUPHOOK"},
|
|
|
|
{PSD_ENABLEPAGESETUPTEMPLATE,"PSD_ENABLEPAGESETUPTEMPLATE"},
|
|
|
|
{PSD_ENABLEPAGESETUPTEMPLATEHANDLE,"PSD_ENABLEPAGESETUPTEMPLATEHANDLE"},
|
|
|
|
{PSD_ENABLEPAGEPAINTHOOK,"PSD_ENABLEPAGEPAINTHOOK"},
|
|
|
|
{PSD_DISABLEPAGEPAINTING,"PSD_DISABLEPAGEPAINTING"},
|
|
|
|
{-1, NULL}
|
|
|
|
};
|
|
|
|
|
2005-01-24 12:26:23 +01:00
|
|
|
/* address of wndproc for subclassed Static control */
|
|
|
|
static WNDPROC lpfnStaticWndProc;
|
2009-01-16 14:51:18 +01:00
|
|
|
static WNDPROC edit_wndproc;
|
2005-01-24 12:26:23 +01:00
|
|
|
/* the text of the fake document to render for the Page Setup dialog */
|
|
|
|
static WCHAR wszFakeDocumentText[1024];
|
2008-07-10 19:18:37 +02:00
|
|
|
static const WCHAR pd32_collateW[] = { 'P', 'D', '3', '2', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E', 0 };
|
|
|
|
static const WCHAR pd32_nocollateW[] = { 'P', 'D', '3', '2', '_', 'N', 'O', 'C', 'O', 'L', 'L', 'A', 'T', 'E', 0 };
|
|
|
|
static const WCHAR pd32_portraitW[] = { 'P', 'D', '3', '2', '_', 'P', 'O', 'R', 'T', 'R', 'A', 'I', 'T', 0 };
|
|
|
|
static const WCHAR pd32_landscapeW[] = { 'P', 'D', '3', '2', '_', 'L', 'A', 'N', 'D', 'S', 'C', 'A', 'P', 'E', 0 };
|
2008-12-27 13:21:19 +01:00
|
|
|
static const WCHAR printdlg_prop[] = {'_','_','W','I','N','E','_','P','R','I','N','T','D','L','G','D','A','T','A',0};
|
|
|
|
static const WCHAR pagesetupdlg_prop[] = { '_', '_', 'W', 'I', 'N', 'E', '_', 'P', 'A', 'G', 'E',
|
|
|
|
'S', 'E', 'T', 'U', 'P', 'D', 'L', 'G', 'D', 'A', 'T', 'A', 0 };
|
2005-01-24 12:26:23 +01:00
|
|
|
|
2009-01-21 11:41:36 +01:00
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
static LPWSTR strdupW(LPCWSTR p)
|
|
|
|
{
|
|
|
|
LPWSTR ret;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if(!p) return NULL;
|
|
|
|
len = (strlenW(p) + 1) * sizeof(WCHAR);
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
memcpy(ret, p, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-01-21 11:41:36 +01:00
|
|
|
/***********************************************************
|
|
|
|
* convert_to_devmodeA
|
|
|
|
*
|
|
|
|
* Creates an ansi copy of supplied devmode
|
|
|
|
*/
|
|
|
|
static DEVMODEA *convert_to_devmodeA(const DEVMODEW *dmW)
|
|
|
|
{
|
|
|
|
DEVMODEA *dmA;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
if (!dmW) return NULL;
|
|
|
|
size = dmW->dmSize - CCHDEVICENAME -
|
|
|
|
((dmW->dmSize > FIELD_OFFSET(DEVMODEW, dmFormName)) ? CCHFORMNAME : 0);
|
|
|
|
|
|
|
|
dmA = HeapAlloc(GetProcessHeap(), 0, size + dmW->dmDriverExtra);
|
|
|
|
if (!dmA) return NULL;
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, dmW->dmDeviceName, -1,
|
|
|
|
(LPSTR)dmA->dmDeviceName, CCHDEVICENAME, NULL, NULL);
|
|
|
|
|
|
|
|
if (FIELD_OFFSET(DEVMODEW, dmFormName) >= dmW->dmSize)
|
|
|
|
{
|
|
|
|
memcpy(&dmA->dmSpecVersion, &dmW->dmSpecVersion,
|
|
|
|
dmW->dmSize - FIELD_OFFSET(DEVMODEW, dmSpecVersion));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(&dmA->dmSpecVersion, &dmW->dmSpecVersion,
|
|
|
|
FIELD_OFFSET(DEVMODEW, dmFormName) - FIELD_OFFSET(DEVMODEW, dmSpecVersion));
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, dmW->dmFormName, -1,
|
|
|
|
(LPSTR)dmA->dmFormName, CCHFORMNAME, NULL, NULL);
|
|
|
|
|
|
|
|
memcpy(&dmA->dmLogPixels, &dmW->dmLogPixels, dmW->dmSize - FIELD_OFFSET(DEVMODEW, dmLogPixels));
|
|
|
|
}
|
|
|
|
|
|
|
|
dmA->dmSize = size;
|
|
|
|
memcpy((char *)dmA + dmA->dmSize, (const char *)dmW + dmW->dmSize, dmW->dmDriverExtra);
|
|
|
|
return dmA;
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2000-05-27 00:26:06 +02:00
|
|
|
* PRINTDLG_OpenDefaultPrinter
|
1999-11-13 21:49:58 +01:00
|
|
|
*
|
2000-05-27 00:26:06 +02:00
|
|
|
* Returns a winspool printer handle to the default printer in *hprn
|
|
|
|
* Caller must call ClosePrinter on the handle
|
1999-11-13 21:49:58 +01:00
|
|
|
*
|
2000-05-27 00:26:06 +02:00
|
|
|
* Returns TRUE on success else FALSE
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2003-08-02 02:41:41 +02:00
|
|
|
BOOL PRINTDLG_OpenDefaultPrinter(HANDLE *hprn)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2005-03-14 11:07:11 +01:00
|
|
|
WCHAR buf[260];
|
|
|
|
DWORD dwBufLen = sizeof(buf) / sizeof(buf[0]);
|
2001-01-02 23:26:09 +01:00
|
|
|
BOOL res;
|
2005-03-14 11:07:11 +01:00
|
|
|
if(!GetDefaultPrinterW(buf, &dwBufLen))
|
2000-05-27 00:26:06 +02:00
|
|
|
return FALSE;
|
2005-03-14 11:07:11 +01:00
|
|
|
res = OpenPrinterW(buf, hprn, NULL);
|
2001-01-02 23:26:09 +01:00
|
|
|
if (!res)
|
2005-03-14 11:07:11 +01:00
|
|
|
WARN("Could not open printer %s\n", debugstr_w(buf));
|
2001-01-02 23:26:09 +01:00
|
|
|
return res;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
1999-10-13 14:29:57 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* 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.
|
|
|
|
*/
|
2003-08-02 02:41:41 +02:00
|
|
|
INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name)
|
2000-05-27 00:26:06 +02:00
|
|
|
{
|
|
|
|
DWORD needed, num;
|
|
|
|
INT i;
|
|
|
|
LPPRINTER_INFO_2A pi;
|
|
|
|
EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
|
|
|
|
pi = HeapAlloc(GetProcessHeap(), 0, needed);
|
2002-06-01 01:06:46 +02:00
|
|
|
EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed,
|
2000-05-27 00:26:06 +02:00
|
|
|
&num);
|
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
SendDlgItemMessageA(hDlg, id, CB_RESETCONTENT, 0, 0);
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
for(i = 0; i < num; i++) {
|
|
|
|
SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0,
|
|
|
|
(LPARAM)pi[i].pPrinterName );
|
1999-04-25 20:31:35 +02:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pi);
|
|
|
|
if(!name ||
|
|
|
|
(i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1,
|
|
|
|
(LPARAM)name)) == CB_ERR) {
|
|
|
|
|
|
|
|
char buf[260];
|
2004-01-02 02:49:31 +01:00
|
|
|
DWORD dwBufLen = sizeof(buf);
|
2007-10-16 03:42:42 +02:00
|
|
|
if (name != NULL)
|
|
|
|
WARN("Can't find %s in printer list so trying to find default\n",
|
|
|
|
debugstr_a(name));
|
2004-01-02 02:49:31 +01:00
|
|
|
if(!GetDefaultPrinterA(buf, &dwBufLen))
|
2000-05-27 00:26:06 +02:00
|
|
|
return num;
|
|
|
|
i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
|
|
|
|
if(i == CB_ERR)
|
2001-01-02 23:26:09 +01:00
|
|
|
FIXME("Can't find default printer in printer list\n");
|
1999-04-25 20:31:35 +02:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
SendDlgItemMessageA(hDlg, id, CB_SETCURSEL, i, 0);
|
|
|
|
return num;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
static INT PRINTDLG_SetUpPrinterListComboW(HWND hDlg, UINT id, LPCWSTR name)
|
|
|
|
{
|
|
|
|
DWORD needed, num;
|
|
|
|
INT i;
|
|
|
|
LPPRINTER_INFO_2W pi;
|
|
|
|
EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
|
|
|
|
pi = HeapAlloc(GetProcessHeap(), 0, needed);
|
2002-06-01 01:06:46 +02:00
|
|
|
EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed,
|
2002-04-11 19:32:49 +02:00
|
|
|
&num);
|
|
|
|
|
|
|
|
for(i = 0; i < num; i++) {
|
|
|
|
SendDlgItemMessageW(hDlg, id, CB_ADDSTRING, 0,
|
|
|
|
(LPARAM)pi[i].pPrinterName );
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, pi);
|
|
|
|
if(!name ||
|
|
|
|
(i = SendDlgItemMessageW(hDlg, id, CB_FINDSTRINGEXACT, -1,
|
|
|
|
(LPARAM)name)) == CB_ERR) {
|
2004-09-22 21:11:05 +02:00
|
|
|
WCHAR buf[260];
|
|
|
|
DWORD dwBufLen = sizeof(buf)/sizeof(buf[0]);
|
2007-10-16 03:42:42 +02:00
|
|
|
if (name != NULL)
|
|
|
|
WARN("Can't find %s in printer list so trying to find default\n",
|
|
|
|
debugstr_w(name));
|
2004-09-22 21:11:05 +02:00
|
|
|
if(!GetDefaultPrinterW(buf, &dwBufLen))
|
2002-04-11 19:32:49 +02:00
|
|
|
return num;
|
2004-09-22 21:11:05 +02:00
|
|
|
i = SendDlgItemMessageW(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
|
2002-04-11 19:32:49 +02:00
|
|
|
if(i == CB_ERR)
|
2004-09-22 21:11:05 +02:00
|
|
|
TRACE("Can't find default printer in printer list\n");
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
SendDlgItemMessageW(hDlg, id, CB_SETCURSEL, i, 0);
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2000-05-27 00:26:06 +02:00
|
|
|
* PRINTDLG_CreateDevNames [internal]
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
*
|
2000-05-27 00:26:06 +02:00
|
|
|
* creates a DevNames structure.
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
2000-05-27 00:26:06 +02:00
|
|
|
* (NB. when we handle unicode the offsets will be in wchars).
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2007-04-06 11:56:15 +02:00
|
|
|
static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, const char* DeviceDriverName,
|
|
|
|
const char* DeviceName, const char* OutputPort)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-05-27 00:26:06 +02:00
|
|
|
long size;
|
|
|
|
char* pDevNamesSpace;
|
|
|
|
char* pTempPtr;
|
|
|
|
LPDEVNAMES lpDevNames;
|
|
|
|
char buf[260];
|
2004-01-02 02:49:31 +01:00
|
|
|
DWORD dwBufLen = sizeof(buf);
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
size = strlen(DeviceDriverName) + 1
|
|
|
|
+ strlen(DeviceName) + 1
|
|
|
|
+ strlen(OutputPort) + 1
|
|
|
|
+ sizeof(DEVNAMES);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
if(*hmem)
|
|
|
|
*hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
|
1999-05-02 13:34:26 +02:00
|
|
|
else
|
2000-05-27 00:26:06 +02:00
|
|
|
*hmem = GlobalAlloc(GMEM_MOVEABLE, size);
|
|
|
|
if (*hmem == 0)
|
1999-08-15 18:33:11 +02:00
|
|
|
return FALSE;
|
1999-08-07 14:34:54 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
pDevNamesSpace = GlobalLock(*hmem);
|
|
|
|
lpDevNames = (LPDEVNAMES) pDevNamesSpace;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
pTempPtr = pDevNamesSpace + sizeof(DEVNAMES);
|
|
|
|
strcpy(pTempPtr, DeviceDriverName);
|
|
|
|
lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
pTempPtr += strlen(DeviceDriverName) + 1;
|
|
|
|
strcpy(pTempPtr, DeviceName);
|
|
|
|
lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
pTempPtr += strlen(DeviceName) + 1;
|
|
|
|
strcpy(pTempPtr, OutputPort);
|
|
|
|
lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
|
|
|
|
|
2004-01-02 02:49:31 +01:00
|
|
|
GetDefaultPrinterA(buf, &dwBufLen);
|
2000-05-27 00:26:06 +02:00
|
|
|
lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0;
|
|
|
|
GlobalUnlock(*hmem);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName,
|
2002-04-11 19:32:49 +02:00
|
|
|
LPCWSTR DeviceName, LPCWSTR OutputPort)
|
|
|
|
{
|
|
|
|
long size;
|
|
|
|
LPWSTR pDevNamesSpace;
|
|
|
|
LPWSTR pTempPtr;
|
|
|
|
LPDEVNAMES lpDevNames;
|
|
|
|
WCHAR bufW[260];
|
2004-01-02 02:49:31 +01:00
|
|
|
DWORD dwBufLen = sizeof(bufW) / sizeof(WCHAR);
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
size = sizeof(WCHAR)*lstrlenW(DeviceDriverName) + 2
|
|
|
|
+ sizeof(WCHAR)*lstrlenW(DeviceName) + 2
|
|
|
|
+ sizeof(WCHAR)*lstrlenW(OutputPort) + 2
|
|
|
|
+ sizeof(DEVNAMES);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
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 = (LPWSTR)((LPDEVNAMES)pDevNamesSpace + 1);
|
|
|
|
lstrcpyW(pTempPtr, DeviceDriverName);
|
|
|
|
lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace;
|
|
|
|
|
|
|
|
pTempPtr += lstrlenW(DeviceDriverName) + 1;
|
|
|
|
lstrcpyW(pTempPtr, DeviceName);
|
|
|
|
lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
pTempPtr += lstrlenW(DeviceName) + 1;
|
|
|
|
lstrcpyW(pTempPtr, OutputPort);
|
|
|
|
lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
|
|
|
|
|
2004-01-02 02:49:31 +01:00
|
|
|
GetDefaultPrinterW(bufW, &dwBufLen);
|
2002-04-11 19:32:49 +02:00
|
|
|
lpDevNames->wDefault = (lstrcmpW(bufW, DeviceName) == 0) ? 1 : 0;
|
|
|
|
GlobalUnlock(*hmem);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2000-05-27 00:26:06 +02:00
|
|
|
* PRINTDLG_UpdatePrintDlg [internal]
|
|
|
|
*
|
|
|
|
*
|
2003-06-18 05:30:39 +02:00
|
|
|
* updates the PrintDlg structure for return values.
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2000-05-27 00:26:06 +02:00
|
|
|
* RETURNS
|
|
|
|
* FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
|
2003-06-18 05:30:39 +02:00
|
|
|
* TRUE if successful.
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static BOOL PRINTDLG_UpdatePrintDlgA(HWND hDlg,
|
2000-05-27 00:26:06 +02:00
|
|
|
PRINT_PTRA* PrintStructures)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2004-01-09 06:10:35 +01:00
|
|
|
LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
|
2000-05-27 00:26:06 +02:00
|
|
|
PDEVMODEA lpdm = PrintStructures->lpDevMode;
|
|
|
|
LPPRINTER_INFO_2A pi = PrintStructures->lpPrinterInfo;
|
|
|
|
|
|
|
|
|
2001-01-02 23:26:09 +01:00
|
|
|
if(!lpdm) {
|
|
|
|
FIXME("No lpdm ptr?\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
2008-09-05 11:08:49 +02:00
|
|
|
BOOL translated;
|
2000-05-27 00:26:06 +02:00
|
|
|
nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
|
2008-09-05 11:08:49 +02:00
|
|
|
nToPage = GetDlgItemInt(hDlg, edt2, &translated, FALSE);
|
|
|
|
|
|
|
|
/* if no ToPage value is entered, use the FromPage value */
|
|
|
|
if(!translated) nToPage = nFromPage;
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
|
|
|
|
nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
|
2008-03-03 20:07:37 +01:00
|
|
|
WCHAR resourcestr[256];
|
|
|
|
WCHAR resultstr[256];
|
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, resourcestr, 255);
|
|
|
|
wsprintfW(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
|
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_PRINT_TITLE, resourcestr, 255);
|
|
|
|
MessageBoxW(hDlg, resultstr, resourcestr, MB_OK | MB_ICONWARNING);
|
2000-05-27 00:26:06 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
lppd->nFromPage = nFromPage;
|
|
|
|
lppd->nToPage = nToPage;
|
2002-10-21 20:22:31 +02:00
|
|
|
lppd->Flags |= PD_PAGENUMS;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
2002-10-21 20:22:31 +02:00
|
|
|
else
|
|
|
|
lppd->Flags &= ~PD_PAGENUMS;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2007-07-25 21:08:33 +02:00
|
|
|
if (IsDlgButtonChecked(hDlg, rad2) == BST_CHECKED) /* Selection */
|
|
|
|
lppd->Flags |= PD_SELECTION;
|
|
|
|
else
|
|
|
|
lppd->Flags &= ~PD_SELECTION;
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
|
2006-05-23 21:05:53 +02:00
|
|
|
static char file[] = "FILE:";
|
2000-05-27 00:26:06 +02:00
|
|
|
lppd->Flags |= PD_PRINTTOFILE;
|
2006-05-23 21:05:53 +02:00
|
|
|
pi->pPortName = file;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */
|
|
|
|
FIXME("Collate lppd not yet implemented as output\n");
|
|
|
|
}
|
1999-09-03 14:41:23 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/* 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)
|
2002-06-01 01:06:46 +02:00
|
|
|
lpdm->dmCollate =
|
2000-05-27 00:26:06 +02:00
|
|
|
(IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED);
|
|
|
|
if (lpdm->dmFields & DM_COPIES)
|
2007-11-01 07:22:11 +01:00
|
|
|
lpdm->u1.s1.dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
|
2000-05-27 00:26:06 +02:00
|
|
|
} else {
|
2008-03-31 15:13:46 +02:00
|
|
|
/* Application is responsible for multiple copies */
|
2000-05-27 00:26:06 +02:00
|
|
|
if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
|
|
|
|
lppd->Flags |= PD_COLLATE;
|
|
|
|
else
|
|
|
|
lppd->Flags &= ~PD_COLLATE;
|
|
|
|
lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
|
2008-03-31 15:13:46 +02:00
|
|
|
/* multiple copies already included in the document. Driver must print only one copy */
|
|
|
|
lpdm->u1.s1.dmCopies = 1;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
2008-01-29 22:40:23 +01:00
|
|
|
|
|
|
|
/* Print quality, PrintDlg16 */
|
|
|
|
if(GetDlgItem(hDlg, cmb1))
|
|
|
|
{
|
|
|
|
HWND hQuality = GetDlgItem(hDlg, cmb1);
|
|
|
|
int Sel = SendMessageA(hQuality, CB_GETCURSEL, 0, 0);
|
|
|
|
|
|
|
|
if(Sel != CB_ERR)
|
|
|
|
{
|
|
|
|
LONG dpi = SendMessageA(hQuality, CB_GETITEMDATA, Sel, 0);
|
|
|
|
lpdm->dmFields |= DM_PRINTQUALITY | DM_YRESOLUTION;
|
|
|
|
lpdm->u1.s1.dmPrintQuality = LOWORD(dpi);
|
|
|
|
lpdm->dmYResolution = HIWORD(dpi);
|
|
|
|
}
|
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
1999-05-02 13:34:26 +02:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static BOOL PRINTDLG_UpdatePrintDlgW(HWND hDlg,
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINT_PTRW* PrintStructures)
|
|
|
|
{
|
2004-01-09 06:10:35 +01:00
|
|
|
LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
|
2002-04-11 19:32:49 +02:00
|
|
|
PDEVMODEW lpdm = PrintStructures->lpDevMode;
|
|
|
|
LPPRINTER_INFO_2W pi = PrintStructures->lpPrinterInfo;
|
|
|
|
|
|
|
|
|
|
|
|
if(!lpdm) {
|
|
|
|
FIXME("No lpdm ptr?\n");
|
|
|
|
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;
|
2008-09-05 11:08:49 +02:00
|
|
|
BOOL translated;
|
2002-04-11 19:32:49 +02:00
|
|
|
nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
|
2008-09-05 11:08:49 +02:00
|
|
|
nToPage = GetDlgItemInt(hDlg, edt2, &translated, FALSE);
|
|
|
|
|
|
|
|
/* if no ToPage value is entered, use the FromPage value */
|
|
|
|
if(!translated) nToPage = nFromPage;
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
|
|
|
|
nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
|
2004-09-22 21:11:05 +02:00
|
|
|
WCHAR resourcestr[256];
|
|
|
|
WCHAR resultstr[256];
|
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE,
|
2002-04-11 19:32:49 +02:00
|
|
|
resourcestr, 255);
|
2004-09-22 21:11:05 +02:00
|
|
|
wsprintfW(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
|
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_PRINT_TITLE,
|
2002-04-11 19:32:49 +02:00
|
|
|
resourcestr, 255);
|
2004-09-22 21:11:05 +02:00
|
|
|
MessageBoxW(hDlg, resultstr, resourcestr,
|
2002-04-11 19:32:49 +02:00
|
|
|
MB_OK | MB_ICONWARNING);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
lppd->nFromPage = nFromPage;
|
|
|
|
lppd->nToPage = nToPage;
|
2006-07-16 04:10:00 +02:00
|
|
|
lppd->Flags |= PD_PAGENUMS;
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
2006-07-16 04:10:00 +02:00
|
|
|
else
|
|
|
|
lppd->Flags &= ~PD_PAGENUMS;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
2007-07-25 21:08:33 +02:00
|
|
|
if (IsDlgButtonChecked(hDlg, rad2) == BST_CHECKED) /* Selection */
|
|
|
|
lppd->Flags |= PD_SELECTION;
|
|
|
|
else
|
|
|
|
lppd->Flags &= ~PD_SELECTION;
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
|
|
|
|
static WCHAR file[] = {'F','I','L','E',':',0};
|
|
|
|
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)
|
2002-06-01 01:06:46 +02:00
|
|
|
lpdm->dmCollate =
|
2002-04-11 19:32:49 +02:00
|
|
|
(IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED);
|
|
|
|
if (lpdm->dmFields & DM_COPIES)
|
2007-11-01 07:22:11 +01:00
|
|
|
lpdm->u1.s1.dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
|
2002-04-11 19:32:49 +02:00
|
|
|
} 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;
|
|
|
|
}
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/************************************************************************
|
|
|
|
* PRINTDLG_SetUpPaperComboBox
|
1999-11-13 21:49:58 +01:00
|
|
|
*
|
2000-05-27 00:26:06 +02:00
|
|
|
* 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.
|
1999-11-13 21:49:58 +01:00
|
|
|
*/
|
2002-04-11 19:32:49 +02:00
|
|
|
static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg,
|
2000-05-27 00:26:06 +02:00
|
|
|
int nIDComboBox,
|
2002-06-01 01:06:46 +02:00
|
|
|
char* PrinterName,
|
2000-05-27 00:26:06 +02:00
|
|
|
char* PortName,
|
|
|
|
LPDEVMODEA dm)
|
1999-11-13 21:49:58 +01:00
|
|
|
{
|
|
|
|
int i;
|
2001-09-11 01:14:22 +02:00
|
|
|
int NrOfEntries;
|
1999-11-13 21:49:58 +01:00
|
|
|
char* Names;
|
2000-05-27 00:26:06 +02:00
|
|
|
WORD* Words;
|
|
|
|
DWORD Sel;
|
|
|
|
WORD oldWord = 0;
|
1999-11-13 21:49:58 +01:00
|
|
|
int NamesSize;
|
|
|
|
int fwCapability_Names;
|
|
|
|
int fwCapability_Words;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-09-11 01:14:22 +02:00
|
|
|
TRACE(" Printer: %s, Port: %s, ComboID: %d\n",PrinterName,PortName,nIDComboBox);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-13 21:49:58 +01:00
|
|
|
/* query the dialog box for the current selected value */
|
2000-05-27 00:26:06 +02:00
|
|
|
Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
|
|
|
|
if(Sel != CB_ERR) {
|
2001-02-12 20:42:08 +01:00
|
|
|
/* we enter here only if a different printer is selected after
|
|
|
|
* the Print Setup dialog is opened. The current settings are
|
|
|
|
* stored into the newly selected printer.
|
|
|
|
*/
|
|
|
|
oldWord = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA,
|
|
|
|
Sel, 0);
|
|
|
|
if (dm) {
|
|
|
|
if (nIDComboBox == cmb2)
|
|
|
|
dm->u1.s1.dmPaperSize = oldWord;
|
|
|
|
else
|
2007-11-01 07:22:11 +01:00
|
|
|
dm->u1.s1.dmDefaultSource = oldWord;
|
2001-02-12 20:42:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* we enter here only when the Print setup dialog is initially
|
|
|
|
* opened. In this case the settings are restored from when
|
|
|
|
* the dialog was last closed.
|
|
|
|
*/
|
|
|
|
if (dm) {
|
|
|
|
if (nIDComboBox == cmb2)
|
|
|
|
oldWord = dm->u1.s1.dmPaperSize;
|
|
|
|
else
|
2007-11-01 07:22:11 +01:00
|
|
|
oldWord = dm->u1.s1.dmDefaultSource;
|
2001-02-12 20:42:08 +01:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
if (nIDComboBox == cmb2) {
|
1999-11-13 21:49:58 +01:00
|
|
|
NamesSize = 64;
|
|
|
|
fwCapability_Names = DC_PAPERNAMES;
|
|
|
|
fwCapability_Words = DC_PAPERS;
|
2000-05-27 00:26:06 +02:00
|
|
|
} else {
|
1999-11-13 21:49:58 +01:00
|
|
|
nIDComboBox = cmb3;
|
|
|
|
NamesSize = 24;
|
|
|
|
fwCapability_Names = DC_BINNAMES;
|
|
|
|
fwCapability_Words = DC_BINS;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-13 21:49:58 +01:00
|
|
|
NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
|
2000-05-27 00:26:06 +02:00
|
|
|
fwCapability_Names, NULL, dm);
|
1999-11-13 21:49:58 +01:00
|
|
|
if (NrOfEntries == 0)
|
2000-05-27 00:26:06 +02:00
|
|
|
WARN("no Name Entries found!\n");
|
2001-09-11 01:14:22 +02:00
|
|
|
else if (NrOfEntries < 0)
|
|
|
|
return FALSE;
|
2000-05-27 00:26:06 +02:00
|
|
|
|
|
|
|
if(DeviceCapabilitiesA(PrinterName, PortName, fwCapability_Words, NULL, dm)
|
|
|
|
!= NrOfEntries) {
|
|
|
|
ERR("Number of caps is different\n");
|
|
|
|
NrOfEntries = 0;
|
|
|
|
}
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
Names = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(char)*NamesSize);
|
2000-05-27 00:26:06 +02:00
|
|
|
Words = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(WORD));
|
1999-11-13 21:49:58 +01:00
|
|
|
NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
|
2000-05-27 00:26:06 +02:00
|
|
|
fwCapability_Names, Names, dm);
|
|
|
|
NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
|
|
|
|
fwCapability_Words, (LPSTR)Words, dm);
|
|
|
|
|
1999-11-13 21:49:58 +01:00
|
|
|
/* reset any current content in the combobox */
|
|
|
|
SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-13 21:49:58 +01:00
|
|
|
/* store new content */
|
2000-05-27 00:26:06 +02:00
|
|
|
for (i = 0; i < NrOfEntries; i++) {
|
|
|
|
DWORD pos = SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0,
|
|
|
|
(LPARAM)(&Names[i*NamesSize]) );
|
2002-06-01 01:06:46 +02:00
|
|
|
SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos,
|
2000-05-27 00:26:06 +02:00
|
|
|
Words[i]);
|
|
|
|
}
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/* 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);
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,Words);
|
|
|
|
HeapFree(GetProcessHeap(),0,Names);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg,
|
|
|
|
int nIDComboBox,
|
2007-04-06 11:56:15 +02:00
|
|
|
const WCHAR* PrinterName,
|
|
|
|
const WCHAR* PortName,
|
2002-04-11 19:32:49 +02:00
|
|
|
LPDEVMODEW dm)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2002-04-11 19:32:49 +02:00
|
|
|
int i;
|
|
|
|
int NrOfEntries;
|
|
|
|
WCHAR* Names;
|
|
|
|
WORD* Words;
|
|
|
|
DWORD Sel;
|
|
|
|
WORD oldWord = 0;
|
|
|
|
int NamesSize;
|
|
|
|
int fwCapability_Names;
|
|
|
|
int fwCapability_Words;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
TRACE(" Printer: %s, Port: %s, ComboID: %d\n",debugstr_w(PrinterName),debugstr_w(PortName),nIDComboBox);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
/* query the dialog box for the current selected value */
|
2004-09-22 21:11:05 +02:00
|
|
|
Sel = SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
|
2002-04-11 19:32:49 +02:00
|
|
|
if(Sel != CB_ERR) {
|
|
|
|
/* we enter here only if a different printer is selected after
|
|
|
|
* the Print Setup dialog is opened. The current settings are
|
|
|
|
* stored into the newly selected printer.
|
|
|
|
*/
|
2004-09-22 21:11:05 +02:00
|
|
|
oldWord = SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA,
|
2002-04-11 19:32:49 +02:00
|
|
|
Sel, 0);
|
|
|
|
if (dm) {
|
|
|
|
if (nIDComboBox == cmb2)
|
|
|
|
dm->u1.s1.dmPaperSize = oldWord;
|
|
|
|
else
|
2007-11-01 07:22:11 +01:00
|
|
|
dm->u1.s1.dmDefaultSource = oldWord;
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* we enter here only when the Print setup dialog is initially
|
|
|
|
* opened. In this case the settings are restored from when
|
|
|
|
* the dialog was last closed.
|
|
|
|
*/
|
|
|
|
if (dm) {
|
|
|
|
if (nIDComboBox == cmb2)
|
|
|
|
oldWord = dm->u1.s1.dmPaperSize;
|
|
|
|
else
|
2007-11-01 07:22:11 +01:00
|
|
|
oldWord = dm->u1.s1.dmDefaultSource;
|
1999-05-02 13:34:26 +02:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
1999-05-02 13:34:26 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
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;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
NrOfEntries = DeviceCapabilitiesW(PrinterName, PortName,
|
|
|
|
fwCapability_Names, NULL, dm);
|
|
|
|
if (NrOfEntries == 0)
|
|
|
|
WARN("no Name Entries found!\n");
|
|
|
|
else if (NrOfEntries < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if(DeviceCapabilitiesW(PrinterName, PortName, fwCapability_Words, NULL, dm)
|
|
|
|
!= NrOfEntries) {
|
|
|
|
ERR("Number of caps is different\n");
|
|
|
|
NrOfEntries = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Names = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(WCHAR)*NamesSize);
|
|
|
|
Words = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(WORD));
|
|
|
|
NrOfEntries = DeviceCapabilitiesW(PrinterName, PortName,
|
|
|
|
fwCapability_Names, Names, dm);
|
|
|
|
NrOfEntries = DeviceCapabilitiesW(PrinterName, PortName,
|
2009-01-13 23:30:08 +01:00
|
|
|
fwCapability_Words, Words, dm);
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
/* reset any current content in the combobox */
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
/* store new content */
|
|
|
|
for (i = 0; i < NrOfEntries; i++) {
|
|
|
|
DWORD pos = SendDlgItemMessageW(hDlg, nIDComboBox, CB_ADDSTRING, 0,
|
|
|
|
(LPARAM)(&Names[i*NamesSize]) );
|
2002-06-01 01:06:46 +02:00
|
|
|
SendDlgItemMessageW(hDlg, nIDComboBox, CB_SETITEMDATA, pos,
|
2002-04-11 19:32:49 +02:00
|
|
|
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++) {
|
2004-09-22 21:11:05 +02:00
|
|
|
if(SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
|
2002-04-11 19:32:49 +02:00
|
|
|
oldWord) {
|
|
|
|
Sel = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0,Words);
|
|
|
|
HeapFree(GetProcessHeap(),0,Names);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PRINTDLG_UpdatePrinterInfoTexts [internal]
|
|
|
|
*/
|
2007-04-06 11:56:15 +02:00
|
|
|
static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg, const PRINTER_INFO_2A *pi)
|
2002-04-11 19:32:49 +02:00
|
|
|
{
|
|
|
|
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)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i,
|
2002-04-11 19:32:49 +02:00
|
|
|
ResourceString, 255);
|
|
|
|
strcat(StatusMsg,ResourceString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* append "ready" */
|
2002-06-01 01:06:46 +02:00
|
|
|
/* FIXME: status==ready must only be appended if really so.
|
2002-04-11 19:32:49 +02:00
|
|
|
but how to detect? */
|
2002-06-01 01:06:46 +02:00
|
|
|
LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY,
|
2002-04-11 19:32:49 +02:00
|
|
|
ResourceString, 255);
|
|
|
|
strcat(StatusMsg,ResourceString);
|
2003-05-14 02:02:17 +02:00
|
|
|
SetDlgItemTextA(hDlg, stc12, StatusMsg);
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
/* set all other printer info texts */
|
2003-05-14 02:02:17 +02:00
|
|
|
SetDlgItemTextA(hDlg, stc11, pi->pDriverName);
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
if (pi->pLocation != NULL && pi->pLocation[0] != '\0')
|
2003-05-14 02:02:17 +02:00
|
|
|
SetDlgItemTextA(hDlg, stc14, pi->pLocation);
|
2002-04-11 19:32:49 +02:00
|
|
|
else
|
2003-05-14 02:02:17 +02:00
|
|
|
SetDlgItemTextA(hDlg, stc14, pi->pPortName);
|
|
|
|
SetDlgItemTextA(hDlg, stc13, pi->pComment ? pi->pComment : "");
|
2002-04-11 19:32:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-06 11:56:15 +02:00
|
|
|
static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg, const PRINTER_INFO_2W *pi)
|
2002-04-11 19:32:49 +02:00
|
|
|
{
|
|
|
|
WCHAR StatusMsg[256];
|
|
|
|
WCHAR ResourceString[256];
|
2003-05-14 02:02:17 +02:00
|
|
|
static const WCHAR emptyW[] = {0};
|
2002-04-11 19:32:49 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Status Message */
|
|
|
|
StatusMsg[0]='\0';
|
|
|
|
|
|
|
|
/* add all status messages */
|
|
|
|
for (i = 0; i < 25; i++) {
|
|
|
|
if (pi->Status & (1<<i)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i,
|
2002-04-11 19:32:49 +02:00
|
|
|
ResourceString, 255);
|
|
|
|
lstrcatW(StatusMsg,ResourceString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* append "ready" */
|
2002-06-01 01:06:46 +02:00
|
|
|
/* FIXME: status==ready must only be appended if really so.
|
2002-04-11 19:32:49 +02:00
|
|
|
but how to detect? */
|
2002-06-01 01:06:46 +02:00
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY,
|
2002-04-11 19:32:49 +02:00
|
|
|
ResourceString, 255);
|
|
|
|
lstrcatW(StatusMsg,ResourceString);
|
2003-05-14 02:02:17 +02:00
|
|
|
SetDlgItemTextW(hDlg, stc12, StatusMsg);
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
/* set all other printer info texts */
|
2003-05-14 02:02:17 +02:00
|
|
|
SetDlgItemTextW(hDlg, stc11, pi->pDriverName);
|
2002-04-11 19:32:49 +02:00
|
|
|
if (pi->pLocation != NULL && pi->pLocation[0] != '\0')
|
2003-05-14 02:02:17 +02:00
|
|
|
SetDlgItemTextW(hDlg, stc14, pi->pLocation);
|
2002-04-11 19:32:49 +02:00
|
|
|
else
|
2003-05-14 02:02:17 +02:00
|
|
|
SetDlgItemTextW(hDlg, stc14, pi->pPortName);
|
|
|
|
SetDlgItemTextW(hDlg, stc13, pi->pComment ? pi->pComment : emptyW);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/*******************************************************************
|
|
|
|
*
|
|
|
|
* PRINTDLG_ChangePrinter
|
|
|
|
*
|
1999-11-13 21:49:58 +01:00
|
|
|
*/
|
2003-08-02 02:41:41 +02:00
|
|
|
BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name,
|
2000-05-27 00:26:06 +02:00
|
|
|
PRINT_PTRA *PrintStructures)
|
1999-11-13 21:49:58 +01:00
|
|
|
{
|
2004-01-09 06:10:35 +01:00
|
|
|
LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
|
2000-05-27 00:26:06 +02:00
|
|
|
LPDEVMODEA lpdm = NULL;
|
|
|
|
LONG dmSize;
|
|
|
|
DWORD needed;
|
|
|
|
HANDLE hprn;
|
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(),0, PrintStructures->lpPrinterInfo);
|
|
|
|
HeapFree(GetProcessHeap(),0, PrintStructures->lpDriverInfo);
|
2000-05-27 00:26:06 +02:00
|
|
|
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);
|
2001-05-02 03:10:43 +02:00
|
|
|
GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
|
|
|
|
PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed);
|
|
|
|
if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo,
|
|
|
|
needed, &needed)) {
|
|
|
|
ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
ClosePrinter(hprn);
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTDLG_UpdatePrinterInfoTextsA(hDlg, PrintStructures->lpPrinterInfo);
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
|
|
|
|
PrintStructures->lpDevMode = NULL;
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
dmSize = DocumentPropertiesA(0, 0, name, NULL, NULL, 0);
|
|
|
|
if(dmSize == -1) {
|
|
|
|
ERR("DocumentProperties fails on %s\n", debugstr_a(name));
|
|
|
|
return FALSE;
|
1999-08-07 14:34:54 +02:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
|
|
|
|
dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL,
|
|
|
|
DM_OUT_BUFFER);
|
|
|
|
if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
|
2005-09-07 13:31:17 +02:00
|
|
|
!lstrcmpA( (LPSTR) lpdm->dmDeviceName,
|
|
|
|
(LPSTR) PrintStructures->lpDevMode->dmDeviceName)) {
|
2000-05-27 00:26:06 +02:00
|
|
|
/* Supplied devicemode matches current printer so try to use it */
|
|
|
|
DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm,
|
|
|
|
DM_OUT_BUFFER | DM_IN_BUFFER);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
if(lpdm)
|
|
|
|
GlobalUnlock(lppd->hDevMode);
|
|
|
|
|
|
|
|
lpdm = PrintStructures->lpDevMode; /* use this as a shortcut */
|
|
|
|
|
|
|
|
if(!(lppd->Flags & PD_PRINTSETUP)) {
|
2008-09-05 11:17:53 +02:00
|
|
|
/* Print range (All/Range/Selection) */
|
|
|
|
if(lppd->nFromPage != 0xffff)
|
|
|
|
SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
|
|
|
|
if(lppd->nToPage != 0xffff)
|
|
|
|
SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
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);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
/* Collate pages
|
2000-05-27 00:26:06 +02:00
|
|
|
*
|
|
|
|
* FIXME: The ico3 is not displayed for some reason. I don't know why.
|
|
|
|
*/
|
|
|
|
if (lppd->Flags & PD_COLLATE) {
|
2002-06-01 01:06:46 +02:00
|
|
|
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2000-05-27 00:26:06 +02:00
|
|
|
(LPARAM)PrintStructures->hCollateIcon);
|
|
|
|
CheckDlgButton(hDlg, chx2, 1);
|
|
|
|
} else {
|
2002-06-01 01:06:46 +02:00
|
|
|
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2000-05-27 00:26:06 +02:00
|
|
|
(LPARAM)PrintStructures->hNoCollateIcon);
|
|
|
|
CheckDlgButton(hDlg, chx2, 0);
|
|
|
|
}
|
1999-08-07 14:34:54 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
|
|
|
|
/* if printer doesn't support it: no Collate */
|
|
|
|
if (!(lpdm->dmFields & DM_COLLATE)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, ico3), FALSE);
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
|
|
|
}
|
1999-08-07 14:34:54 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/* nCopies */
|
2001-02-12 19:09:34 +01:00
|
|
|
{
|
|
|
|
INT copies;
|
|
|
|
if (lppd->hDevMode == 0)
|
|
|
|
copies = lppd->nCopies;
|
|
|
|
else
|
2007-11-01 07:22:11 +01:00
|
|
|
copies = lpdm->u1.s1.dmCopies;
|
2001-02-12 19:09:34 +01:00
|
|
|
if(copies == 0) copies = 1;
|
|
|
|
else if(copies < 0) copies = MAX_COPIES;
|
|
|
|
SetDlgItemInt(hDlg, edt3, copies, FALSE);
|
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
|
|
|
|
if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
|
|
|
|
/* if printer doesn't support it: no nCopies */
|
|
|
|
if (!(lpdm->dmFields & DM_COPIES)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, edt3), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, stc5), FALSE);
|
1999-08-07 14:34:54 +02:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
1999-08-07 14:34:54 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/* print to file */
|
|
|
|
CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
|
|
|
|
if (lppd->Flags & PD_DISABLEPRINTTOFILE)
|
2002-06-01 01:06:46 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, chx1), FALSE);
|
2000-05-27 00:26:06 +02:00
|
|
|
if (lppd->Flags & PD_HIDEPRINTTOFILE)
|
|
|
|
ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
|
|
|
|
|
2008-01-29 22:40:23 +01:00
|
|
|
/* Fill print quality combo, PrintDlg16 */
|
|
|
|
if(GetDlgItem(hDlg, cmb1))
|
|
|
|
{
|
|
|
|
DWORD numResolutions = DeviceCapabilitiesA(PrintStructures->lpPrinterInfo->pPrinterName,
|
|
|
|
PrintStructures->lpPrinterInfo->pPortName,
|
|
|
|
DC_ENUMRESOLUTIONS, NULL, lpdm);
|
|
|
|
|
|
|
|
if(numResolutions != -1)
|
|
|
|
{
|
|
|
|
HWND hQuality = GetDlgItem(hDlg, cmb1);
|
|
|
|
LONG* Resolutions;
|
|
|
|
char buf[255];
|
2008-09-20 23:29:36 +02:00
|
|
|
DWORD i;
|
2008-01-29 22:40:23 +01:00
|
|
|
int dpiX, dpiY;
|
|
|
|
HDC hPrinterDC = CreateDCA(PrintStructures->lpPrinterInfo->pDriverName,
|
|
|
|
PrintStructures->lpPrinterInfo->pPrinterName,
|
|
|
|
0, lpdm);
|
|
|
|
|
|
|
|
Resolutions = HeapAlloc(GetProcessHeap(), 0, numResolutions*sizeof(LONG)*2);
|
|
|
|
DeviceCapabilitiesA(PrintStructures->lpPrinterInfo->pPrinterName,
|
|
|
|
PrintStructures->lpPrinterInfo->pPortName,
|
|
|
|
DC_ENUMRESOLUTIONS, (LPSTR)Resolutions, lpdm);
|
|
|
|
|
|
|
|
dpiX = GetDeviceCaps(hPrinterDC, LOGPIXELSX);
|
|
|
|
dpiY = GetDeviceCaps(hPrinterDC, LOGPIXELSY);
|
|
|
|
DeleteDC(hPrinterDC);
|
|
|
|
|
|
|
|
SendMessageA(hQuality, CB_RESETCONTENT, 0, 0);
|
|
|
|
for(i = 0; i < (numResolutions * 2); i += 2)
|
|
|
|
{
|
|
|
|
BOOL IsDefault = FALSE;
|
|
|
|
LRESULT Index;
|
|
|
|
|
|
|
|
if(Resolutions[i] == Resolutions[i+1])
|
|
|
|
{
|
|
|
|
if(dpiX == Resolutions[i])
|
|
|
|
IsDefault = TRUE;
|
|
|
|
sprintf(buf, "%d dpi", Resolutions[i]);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
if(dpiX == Resolutions[i] && dpiY == Resolutions[i+1])
|
|
|
|
IsDefault = TRUE;
|
|
|
|
sprintf(buf, "%d dpi x %d dpi", Resolutions[i], Resolutions[i+1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Index = SendMessageA(hQuality, CB_ADDSTRING, 0, (LPARAM)buf);
|
|
|
|
|
|
|
|
if(IsDefault)
|
|
|
|
SendMessageA(hQuality, CB_SETCURSEL, Index, 0);
|
|
|
|
|
|
|
|
SendMessageA(hQuality, CB_SETITEMDATA, Index, MAKELONG(dpiX,dpiY));
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, Resolutions);
|
|
|
|
}
|
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
} else { /* PD_PRINTSETUP */
|
2001-02-12 19:09:34 +01:00
|
|
|
BOOL bPortrait = (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT);
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTDLG_SetUpPaperComboBoxA(hDlg, cmb2,
|
|
|
|
PrintStructures->lpPrinterInfo->pPrinterName,
|
|
|
|
PrintStructures->lpPrinterInfo->pPortName,
|
|
|
|
lpdm);
|
|
|
|
PRINTDLG_SetUpPaperComboBoxA(hDlg, cmb3,
|
|
|
|
PrintStructures->lpPrinterInfo->pPrinterName,
|
|
|
|
PrintStructures->lpPrinterInfo->pPortName,
|
|
|
|
lpdm);
|
|
|
|
CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
|
|
|
|
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
|
|
|
(LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
|
|
|
|
PrintStructures->hLandscapeIcon));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* help button */
|
|
|
|
if ((lppd->Flags & PD_SHOWHELP)==0) {
|
|
|
|
/* hide if PD_SHOWHELP not specified */
|
2002-06-01 01:06:46 +02:00
|
|
|
ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL PRINTDLG_ChangePrinterW(HWND hDlg, WCHAR *name,
|
|
|
|
PRINT_PTRW *PrintStructures)
|
|
|
|
{
|
2004-01-09 06:10:35 +01:00
|
|
|
LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
|
2002-04-11 19:32:49 +02:00
|
|
|
LPDEVMODEW lpdm = NULL;
|
|
|
|
LONG dmSize;
|
|
|
|
DWORD needed;
|
|
|
|
HANDLE hprn;
|
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(),0, PrintStructures->lpPrinterInfo);
|
|
|
|
HeapFree(GetProcessHeap(),0, PrintStructures->lpDriverInfo);
|
2002-04-11 19:32:49 +02:00
|
|
|
if(!OpenPrinterW(name, &hprn, NULL)) {
|
|
|
|
ERR("Can't open printer %s\n", debugstr_w(name));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
GetPrinterW(hprn, 2, NULL, 0, &needed);
|
2008-11-25 16:40:05 +01:00
|
|
|
PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed);
|
2002-04-11 19:32:49 +02:00
|
|
|
GetPrinterW(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
|
|
|
|
&needed);
|
|
|
|
GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
|
2008-11-25 16:40:05 +01:00
|
|
|
PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed);
|
2002-04-11 19:32:49 +02:00
|
|
|
if (!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo,
|
|
|
|
needed, &needed)) {
|
|
|
|
ERR("GetPrinterDriverA failed for %s, fix your config!\n",debugstr_w(PrintStructures->lpPrinterInfo->pPrinterName));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ClosePrinter(hprn);
|
|
|
|
|
|
|
|
PRINTDLG_UpdatePrinterInfoTextsW(hDlg, PrintStructures->lpPrinterInfo);
|
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
|
|
|
|
PrintStructures->lpDevMode = NULL;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
dmSize = DocumentPropertiesW(0, 0, name, NULL, NULL, 0);
|
|
|
|
if(dmSize == -1) {
|
|
|
|
ERR("DocumentProperties fails on %s\n", debugstr_w(name));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
|
|
|
|
dmSize = DocumentPropertiesW(0, 0, name, PrintStructures->lpDevMode, NULL,
|
|
|
|
DM_OUT_BUFFER);
|
|
|
|
if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
|
|
|
|
!lstrcmpW(lpdm->dmDeviceName,
|
|
|
|
PrintStructures->lpDevMode->dmDeviceName)) {
|
|
|
|
/* Supplied devicemode matches current printer so try to use it */
|
|
|
|
DocumentPropertiesW(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)) {
|
2008-09-05 11:17:53 +02:00
|
|
|
/* Print range (All/Range/Selection) */
|
|
|
|
if(lppd->nFromPage != 0xffff)
|
|
|
|
SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
|
|
|
|
if(lppd->nToPage != 0xffff)
|
|
|
|
SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
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);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
/* Collate pages
|
2002-04-11 19:32:49 +02:00
|
|
|
*
|
|
|
|
* FIXME: The ico3 is not displayed for some reason. I don't know why.
|
|
|
|
*/
|
|
|
|
if (lppd->Flags & PD_COLLATE) {
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2002-04-11 19:32:49 +02:00
|
|
|
(LPARAM)PrintStructures->hCollateIcon);
|
|
|
|
CheckDlgButton(hDlg, chx2, 1);
|
|
|
|
} else {
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2002-04-11 19:32:49 +02:00
|
|
|
(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)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, ico3), FALSE);
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nCopies */
|
|
|
|
{
|
|
|
|
INT copies;
|
|
|
|
if (lppd->hDevMode == 0)
|
|
|
|
copies = lppd->nCopies;
|
|
|
|
else
|
2007-11-01 07:22:11 +01:00
|
|
|
copies = lpdm->u1.s1.dmCopies;
|
2002-04-11 19:32:49 +02:00
|
|
|
if(copies == 0) copies = 1;
|
|
|
|
else if(copies < 0) copies = MAX_COPIES;
|
|
|
|
SetDlgItemInt(hDlg, edt3, copies, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
|
|
|
|
/* if printer doesn't support it: no nCopies */
|
|
|
|
if (!(lpdm->dmFields & DM_COPIES)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, edt3), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, stc5), FALSE);
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* print to file */
|
|
|
|
CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
|
|
|
|
if (lppd->Flags & PD_DISABLEPRINTTOFILE)
|
2002-06-01 01:06:46 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, chx1), FALSE);
|
2002-04-11 19:32:49 +02:00
|
|
|
if (lppd->Flags & PD_HIDEPRINTTOFILE)
|
|
|
|
ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
|
|
|
|
|
|
|
|
} else { /* PD_PRINTSETUP */
|
|
|
|
BOOL bPortrait = (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT);
|
|
|
|
|
|
|
|
PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb2,
|
2000-05-27 00:26:06 +02:00
|
|
|
PrintStructures->lpPrinterInfo->pPrinterName,
|
|
|
|
PrintStructures->lpPrinterInfo->pPortName,
|
|
|
|
lpdm);
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb3,
|
2000-05-27 00:26:06 +02:00
|
|
|
PrintStructures->lpPrinterInfo->pPrinterName,
|
|
|
|
PrintStructures->lpPrinterInfo->pPortName,
|
|
|
|
lpdm);
|
2001-02-12 19:09:34 +01:00
|
|
|
CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2001-02-12 19:09:34 +01:00
|
|
|
(LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
|
|
|
|
PrintStructures->hLandscapeIcon));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-11 02:09:29 +02:00
|
|
|
}
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/* help button */
|
|
|
|
if ((lppd->Flags & PD_SHOWHELP)==0) {
|
|
|
|
/* hide if PD_SHOWHELP not specified */
|
2002-06-01 01:06:46 +02:00
|
|
|
ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
1999-05-02 13:34:26 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2005-11-03 13:12:18 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* check_printer_setup [internal]
|
|
|
|
*/
|
|
|
|
static LRESULT check_printer_setup(HWND hDlg)
|
|
|
|
{
|
|
|
|
DWORD needed,num;
|
|
|
|
WCHAR resourcestr[256],resultstr[256];
|
|
|
|
|
|
|
|
EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
|
|
|
|
if(needed == 0)
|
|
|
|
{
|
|
|
|
EnumPrintersW(PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed, &num);
|
|
|
|
}
|
|
|
|
if(needed > 0)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_NO_DEVICES,resultstr, 255);
|
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_PRINT_TITLE,resourcestr, 255);
|
2008-04-14 23:13:38 +02:00
|
|
|
MessageBoxW(hDlg, resultstr, resourcestr,MB_OK | MB_ICONWARNING);
|
2005-11-03 13:12:18 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-13 21:49:58 +01:00
|
|
|
/***********************************************************************
|
2000-05-27 00:26:06 +02:00
|
|
|
* PRINTDLG_WMInitDialog [internal]
|
1999-11-13 21:49:58 +01:00
|
|
|
*/
|
2000-05-27 00:26:06 +02:00
|
|
|
static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam,
|
|
|
|
PRINT_PTRA* PrintStructures)
|
1999-11-13 21:49:58 +01:00
|
|
|
{
|
2004-01-09 06:10:35 +01:00
|
|
|
LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
|
2000-05-27 00:26:06 +02:00
|
|
|
DEVNAMES *pdn;
|
|
|
|
DEVMODEA *pdm;
|
|
|
|
char *name = NULL;
|
|
|
|
UINT comboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/* load Collate ICONs */
|
2001-10-08 22:40:09 +02:00
|
|
|
/* We load these with LoadImage because they are not a standard
|
2001-02-12 04:38:14 +01:00
|
|
|
size and we don't want them rescaled */
|
2000-05-27 00:26:06 +02:00
|
|
|
PrintStructures->hCollateIcon =
|
2001-02-12 04:38:14 +01:00
|
|
|
LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0);
|
2002-06-01 01:06:46 +02:00
|
|
|
PrintStructures->hNoCollateIcon =
|
2001-02-12 04:38:14 +01:00
|
|
|
LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0);
|
2001-02-12 19:09:34 +01:00
|
|
|
|
|
|
|
/* These can be done with LoadIcon */
|
|
|
|
PrintStructures->hPortraitIcon =
|
|
|
|
LoadIconA(COMDLG32_hInstance, "PD32_PORTRAIT");
|
|
|
|
PrintStructures->hLandscapeIcon =
|
|
|
|
LoadIconA(COMDLG32_hInstance, "PD32_LANDSCAPE");
|
|
|
|
|
2004-07-19 21:35:28 +02:00
|
|
|
/* display the collate/no_collate icon */
|
|
|
|
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hNoCollateIcon);
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
if(PrintStructures->hCollateIcon == 0 ||
|
2001-02-12 19:09:34 +01:00
|
|
|
PrintStructures->hNoCollateIcon == 0 ||
|
|
|
|
PrintStructures->hPortraitIcon == 0 ||
|
|
|
|
PrintStructures->hLandscapeIcon == 0) {
|
2000-05-27 00:26:06 +02:00
|
|
|
ERR("no icon in resourcefile\n");
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
EndDialog(hDlg, FALSE);
|
|
|
|
}
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/*
|
|
|
|
* 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) {
|
2002-06-01 01:06:46 +02:00
|
|
|
if((PrintStructures->HelpMessageID =
|
2001-01-22 03:13:58 +01:00
|
|
|
RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {
|
2000-05-27 00:26:06 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
PrintStructures->HelpMessageID = 0;
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2001-02-12 19:09:34 +01:00
|
|
|
if(!(lppd->Flags &PD_PRINTSETUP)) {
|
|
|
|
PrintStructures->hwndUpDown =
|
|
|
|
CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER |
|
|
|
|
UDS_NOTHOUSANDS | UDS_ARROWKEYS |
|
|
|
|
UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
|
|
|
|
hDlg, UPDOWN_ID, COMDLG32_hInstance,
|
|
|
|
GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
|
|
|
|
}
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/* 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;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (lppd->nMinPage == lppd->nMaxPage)
|
|
|
|
lppd->Flags |= PD_NOPAGENUMS;
|
2000-05-27 00:26:06 +02:00
|
|
|
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;
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2001-01-02 23:26:09 +01:00
|
|
|
/* if we have the combo box, fill it */
|
|
|
|
if (GetDlgItem(hDlg,comboID)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Fill Combobox
|
2001-01-02 23:26:09 +01:00
|
|
|
*/
|
|
|
|
pdn = GlobalLock(lppd->hDevNames);
|
|
|
|
pdm = GlobalLock(lppd->hDevMode);
|
|
|
|
if(pdn)
|
|
|
|
name = (char*)pdn + pdn->wDeviceOffset;
|
|
|
|
else if(pdm)
|
2005-07-05 16:11:04 +02:00
|
|
|
name = (char*)pdm->dmDeviceName;
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name);
|
2001-01-02 23:26:09 +01:00
|
|
|
if(pdm) GlobalUnlock(lppd->hDevMode);
|
|
|
|
if(pdn) GlobalUnlock(lppd->hDevNames);
|
|
|
|
|
|
|
|
/* Now find selected printer and update rest of dlg */
|
|
|
|
name = HeapAlloc(GetProcessHeap(),0,256);
|
|
|
|
if (GetDlgItemTextA(hDlg, comboID, name, 255))
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
|
2001-01-02 23:26:09 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,name);
|
|
|
|
} else {
|
|
|
|
/* else use default printer */
|
|
|
|
char name[200];
|
2004-01-02 02:49:31 +01:00
|
|
|
DWORD dwBufLen = sizeof(name);
|
|
|
|
BOOL ret = GetDefaultPrinterA(name, &dwBufLen);
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
|
|
|
|
else
|
|
|
|
FIXME("No default printer found, expect problems!\n");
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg, WPARAM wParam,
|
|
|
|
PRINT_PTRW* PrintStructures)
|
|
|
|
{
|
2004-01-09 06:10:35 +01:00
|
|
|
LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
|
2002-04-11 19:32:49 +02:00
|
|
|
DEVNAMES *pdn;
|
|
|
|
DEVMODEW *pdm;
|
|
|
|
WCHAR *name = NULL;
|
|
|
|
UINT comboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
|
|
|
|
|
|
|
|
/* load Collate ICONs */
|
|
|
|
/* We load these with LoadImage because they are not a standard
|
|
|
|
size and we don't want them rescaled */
|
|
|
|
PrintStructures->hCollateIcon =
|
2008-07-10 19:18:37 +02:00
|
|
|
LoadImageW(COMDLG32_hInstance, pd32_collateW, IMAGE_ICON, 0, 0, 0);
|
2002-06-01 01:06:46 +02:00
|
|
|
PrintStructures->hNoCollateIcon =
|
2008-07-10 19:18:37 +02:00
|
|
|
LoadImageW(COMDLG32_hInstance, pd32_nocollateW, IMAGE_ICON, 0, 0, 0);
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
/* These can be done with LoadIcon */
|
|
|
|
PrintStructures->hPortraitIcon =
|
2008-07-10 19:18:37 +02:00
|
|
|
LoadIconW(COMDLG32_hInstance, pd32_portraitW);
|
2002-04-11 19:32:49 +02:00
|
|
|
PrintStructures->hLandscapeIcon =
|
2008-07-10 19:18:37 +02:00
|
|
|
LoadIconW(COMDLG32_hInstance, pd32_landscapeW);
|
2002-04-11 19:32:49 +02:00
|
|
|
|
2004-07-19 21:35:28 +02:00
|
|
|
/* display the collate/no_collate icon */
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2004-07-19 21:35:28 +02:00
|
|
|
(LPARAM)PrintStructures->hNoCollateIcon);
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
if(PrintStructures->hCollateIcon == 0 ||
|
|
|
|
PrintStructures->hNoCollateIcon == 0 ||
|
|
|
|
PrintStructures->hPortraitIcon == 0 ||
|
|
|
|
PrintStructures->hLandscapeIcon == 0) {
|
|
|
|
ERR("no icon in resourcefile\n");
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
EndDialog(hDlg, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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) {
|
2002-06-01 01:06:46 +02:00
|
|
|
if((PrintStructures->HelpMessageID =
|
2004-09-22 21:11:05 +02:00
|
|
|
RegisterWindowMessageW(HELPMSGSTRINGW)) == 0) {
|
2002-04-11 19:32:49 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
PrintStructures->HelpMessageID = 0;
|
|
|
|
|
|
|
|
if(!(lppd->Flags &PD_PRINTSETUP)) {
|
|
|
|
PrintStructures->hwndUpDown =
|
|
|
|
CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER |
|
|
|
|
UDS_NOTHOUSANDS | UDS_ARROWKEYS |
|
|
|
|
UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
|
|
|
|
hDlg, UPDOWN_ID, COMDLG32_hInstance,
|
|
|
|
GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: I allow more freedom than either Win95 or WinNT,
|
|
|
|
* which do not agree to what errors should be thrown or not
|
|
|
|
* in case nToPage or nFromPage is out-of-range.
|
|
|
|
*/
|
|
|
|
if (lppd->nMaxPage < lppd->nMinPage)
|
|
|
|
lppd->nMaxPage = lppd->nMinPage;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (lppd->nMinPage == lppd->nMaxPage)
|
|
|
|
lppd->Flags |= PD_NOPAGENUMS;
|
2002-04-11 19:32:49 +02:00
|
|
|
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 we have the combo box, fill it */
|
|
|
|
if (GetDlgItem(hDlg,comboID)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Fill Combobox
|
2002-04-11 19:32:49 +02:00
|
|
|
*/
|
|
|
|
pdn = GlobalLock(lppd->hDevNames);
|
|
|
|
pdm = GlobalLock(lppd->hDevMode);
|
|
|
|
if(pdn)
|
|
|
|
name = (WCHAR*)pdn + pdn->wDeviceOffset;
|
|
|
|
else if(pdm)
|
|
|
|
name = pdm->dmDeviceName;
|
|
|
|
PRINTDLG_SetUpPrinterListComboW(hDlg, comboID, name);
|
|
|
|
if(pdm) GlobalUnlock(lppd->hDevMode);
|
|
|
|
if(pdn) GlobalUnlock(lppd->hDevNames);
|
|
|
|
|
|
|
|
/* Now find selected printer and update rest of dlg */
|
|
|
|
/* ansi is ok here */
|
|
|
|
name = HeapAlloc(GetProcessHeap(),0,256*sizeof(WCHAR));
|
|
|
|
if (GetDlgItemTextW(hDlg, comboID, name, 255))
|
|
|
|
PRINTDLG_ChangePrinterW(hDlg, name, PrintStructures);
|
|
|
|
HeapFree(GetProcessHeap(),0,name);
|
|
|
|
} else {
|
|
|
|
/* else use default printer */
|
|
|
|
WCHAR name[200];
|
2004-01-02 02:49:31 +01:00
|
|
|
DWORD dwBufLen = sizeof(name) / sizeof(WCHAR);
|
|
|
|
BOOL ret = GetDefaultPrinterW(name, &dwBufLen);
|
2001-01-02 23:26:09 +01:00
|
|
|
|
|
|
|
if (ret)
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTDLG_ChangePrinterW(hDlg, name, PrintStructures);
|
2001-01-02 23:26:09 +01:00
|
|
|
else
|
|
|
|
FIXME("No default printer found, expect problems!\n");
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* PRINTDLG_WMCommand [internal]
|
|
|
|
*/
|
2003-08-02 02:41:41 +02:00
|
|
|
LRESULT PRINTDLG_WMCommandA(HWND hDlg, WPARAM wParam,
|
1999-05-02 13:34:26 +02:00
|
|
|
LPARAM lParam, PRINT_PTRA* PrintStructures)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2004-01-09 06:10:35 +01:00
|
|
|
LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
|
2000-05-27 00:26:06 +02:00
|
|
|
UINT PrinterComboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
|
|
|
|
LPDEVMODEA lpdm = PrintStructures->lpDevMode;
|
1999-05-02 13:34:26 +02:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE(" OK button was hit\n");
|
2004-12-09 15:07:59 +01:00
|
|
|
if (!PRINTDLG_UpdatePrintDlgA(hDlg, PrintStructures)) {
|
2001-01-02 23:26:09 +01:00
|
|
|
FIXME("Update printdlg was not successful!\n");
|
2000-05-27 00:26:06 +02:00
|
|
|
return(FALSE);
|
2001-01-02 23:26:09 +01:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
EndDialog(hDlg, TRUE);
|
|
|
|
return(TRUE);
|
|
|
|
|
|
|
|
case IDCANCEL:
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE(" CANCEL button was hit\n");
|
1999-02-28 21:05:11 +01:00
|
|
|
EndDialog(hDlg, FALSE);
|
2000-05-27 00:26:06 +02:00
|
|
|
return(FALSE);
|
|
|
|
|
1999-05-02 13:34:26 +02:00
|
|
|
case pshHelp:
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE(" HELP button was hit\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID,
|
1999-05-02 13:34:26 +02:00
|
|
|
(WPARAM) hDlg, (LPARAM) lppd);
|
|
|
|
break;
|
2000-05-27 00:26:06 +02:00
|
|
|
|
1999-07-30 20:10:21 +02:00
|
|
|
case chx2: /* collate pages checkbox */
|
|
|
|
if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
|
2002-06-01 01:06:46 +02:00
|
|
|
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
1999-07-30 20:10:21 +02:00
|
|
|
(LPARAM)PrintStructures->hCollateIcon);
|
|
|
|
else
|
2002-06-01 01:06:46 +02:00
|
|
|
SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
1999-07-30 20:10:21 +02:00
|
|
|
(LPARAM)PrintStructures->hNoCollateIcon);
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
1999-07-30 20:10:21 +02:00
|
|
|
case edt1: /* from page nr editbox */
|
|
|
|
case edt2: /* to page nr editbox */
|
2000-05-27 00:26:06 +02:00
|
|
|
if (HIWORD(wParam)==EN_CHANGE) {
|
|
|
|
WORD nToPage;
|
|
|
|
WORD nFromPage;
|
|
|
|
nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
|
|
|
|
nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
|
1999-05-02 13:34:26 +02:00
|
|
|
if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage)
|
2000-05-27 00:26:06 +02:00
|
|
|
CheckRadioButton(hDlg, rad1, rad3, rad3);
|
|
|
|
}
|
1999-05-02 13:34:26 +02:00
|
|
|
break;
|
2001-02-12 19:09:34 +01:00
|
|
|
|
|
|
|
case edt3:
|
|
|
|
if(HIWORD(wParam) == EN_CHANGE) {
|
|
|
|
INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
|
|
|
|
if(copies <= 1)
|
|
|
|
EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
|
|
|
|
else
|
|
|
|
EnableWindow(GetDlgItem(hDlg, chx2), TRUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-08-02 02:41:41 +02:00
|
|
|
#if 0
|
2001-07-14 02:47:20 +02:00
|
|
|
case psh1: /* Print Setup */
|
|
|
|
{
|
|
|
|
PRINTDLG16 pdlg;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-14 02:47:20 +02:00
|
|
|
if (!PrintStructures->dlg.lpPrintDlg16) {
|
|
|
|
FIXME("The 32bit print dialog does not have this button!?\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg));
|
|
|
|
pdlg.Flags |= PD_PRINTSETUP;
|
2002-09-06 22:40:42 +02:00
|
|
|
pdlg.hwndOwner = HWND_16(hDlg);
|
2001-07-14 02:47:20 +02:00
|
|
|
if (!PrintDlg16(&pdlg))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2003-08-02 02:41:41 +02:00
|
|
|
#endif
|
2000-05-27 00:26:06 +02:00
|
|
|
case psh2: /* Properties button */
|
|
|
|
{
|
|
|
|
HANDLE hPrinter;
|
2002-04-11 19:32:49 +02:00
|
|
|
char PrinterName[256];
|
|
|
|
|
|
|
|
GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255);
|
|
|
|
if (!OpenPrinterA(PrinterName, &hPrinter, NULL)) {
|
|
|
|
FIXME(" Call to OpenPrinter did not succeed!\n");
|
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
DocumentPropertiesA(hDlg, hPrinter, PrinterName,
|
2002-04-11 19:32:49 +02:00
|
|
|
PrintStructures->lpDevMode,
|
|
|
|
PrintStructures->lpDevMode,
|
|
|
|
DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
|
|
|
|
ClosePrinter(hPrinter);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case rad1: /* Paperorientation */
|
|
|
|
if (lppd->Flags & PD_PRINTSETUP)
|
|
|
|
{
|
|
|
|
lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
|
|
|
|
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
|
|
|
(LPARAM)(PrintStructures->hPortraitIcon));
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
case rad2: /* Paperorientation */
|
|
|
|
if (lppd->Flags & PD_PRINTSETUP)
|
|
|
|
{
|
|
|
|
lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
|
|
|
|
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
|
|
|
(LPARAM)(PrintStructures->hLandscapeIcon));
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2008-01-29 22:40:23 +01:00
|
|
|
case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT16 */
|
2004-08-18 23:00:05 +02:00
|
|
|
if (PrinterComboID != LOWORD(wParam)) {
|
2002-04-11 19:32:49 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case cmb4: /* Printer combobox */
|
|
|
|
if (HIWORD(wParam)==CBN_SELCHANGE) {
|
|
|
|
char PrinterName[256];
|
|
|
|
GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255);
|
|
|
|
PRINTDLG_ChangePrinterA(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)
|
2007-11-01 07:22:11 +01:00
|
|
|
lpdm->u1.s1.dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3,
|
2002-04-11 19:32:49 +02:00
|
|
|
CB_GETITEMDATA, Sel,
|
|
|
|
0);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
if(lppd->Flags & PD_PRINTSETUP) {
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case rad1: /* orientation */
|
|
|
|
case rad2:
|
|
|
|
if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
|
|
|
|
if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {
|
|
|
|
lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
|
|
|
|
SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
|
|
|
|
(WPARAM)IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hPortraitIcon);
|
|
|
|
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
|
|
|
|
(WPARAM)IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hPortraitIcon);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {
|
|
|
|
lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
|
|
|
|
SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,
|
|
|
|
(WPARAM)IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hLandscapeIcon);
|
|
|
|
SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,
|
|
|
|
(WPARAM)IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hLandscapeIcon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2002-04-11 19:32:49 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam,
|
2002-04-11 19:32:49 +02:00
|
|
|
LPARAM lParam, PRINT_PTRW* PrintStructures)
|
|
|
|
{
|
2004-01-09 06:10:35 +01:00
|
|
|
LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
|
2002-04-11 19:32:49 +02:00
|
|
|
UINT PrinterComboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
|
|
|
|
LPDEVMODEW lpdm = PrintStructures->lpDevMode;
|
|
|
|
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
TRACE(" OK button was hit\n");
|
2004-12-09 15:07:59 +01:00
|
|
|
if (!PRINTDLG_UpdatePrintDlgW(hDlg, PrintStructures)) {
|
2002-04-11 19:32:49 +02:00
|
|
|
FIXME("Update printdlg was not successful!\n");
|
|
|
|
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");
|
2002-06-01 01:06:46 +02:00
|
|
|
SendMessageW(lppd->hwndOwner, PrintStructures->HelpMessageID,
|
2002-04-11 19:32:49 +02:00
|
|
|
(WPARAM) hDlg, (LPARAM) lppd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case chx2: /* collate pages checkbox */
|
|
|
|
if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2002-04-11 19:32:49 +02:00
|
|
|
(LPARAM)PrintStructures->hCollateIcon);
|
|
|
|
else
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2002-04-11 19:32:49 +02:00
|
|
|
(LPARAM)PrintStructures->hNoCollateIcon);
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2002-04-11 19:32:49 +02:00
|
|
|
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 edt3:
|
|
|
|
if(HIWORD(wParam) == EN_CHANGE) {
|
|
|
|
INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
|
|
|
|
if(copies <= 1)
|
|
|
|
EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
|
|
|
|
else
|
2004-07-17 01:43:20 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, chx2), TRUE);
|
|
|
|
}
|
|
|
|
break;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
case psh1: /* Print Setup */
|
|
|
|
{
|
|
|
|
ERR("psh1 is called from 16bit code only, we should not get here.\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case psh2: /* Properties button */
|
|
|
|
{
|
|
|
|
HANDLE hPrinter;
|
|
|
|
WCHAR PrinterName[256];
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2004-07-16 21:14:19 +02:00
|
|
|
if (!GetDlgItemTextW(hDlg, PrinterComboID, PrinterName, 255)) break;
|
2002-04-11 19:32:49 +02:00
|
|
|
if (!OpenPrinterW(PrinterName, &hPrinter, NULL)) {
|
2001-01-02 23:26:09 +01:00
|
|
|
FIXME(" Call to OpenPrinter did not succeed!\n");
|
2000-05-27 00:26:06 +02:00
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
DocumentPropertiesW(hDlg, hPrinter, PrinterName,
|
2000-05-27 00:26:06 +02:00
|
|
|
PrintStructures->lpDevMode,
|
|
|
|
PrintStructures->lpDevMode,
|
|
|
|
DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
|
|
|
|
ClosePrinter(hPrinter);
|
1999-05-02 13:34:26 +02:00
|
|
|
break;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
1999-08-07 14:34:54 +02:00
|
|
|
|
2001-02-12 20:42:08 +01:00
|
|
|
case rad1: /* Paperorientation */
|
|
|
|
if (lppd->Flags & PD_PRINTSETUP)
|
2001-05-07 22:14:57 +02:00
|
|
|
{
|
2001-02-12 20:42:08 +01:00
|
|
|
lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2001-05-07 22:14:57 +02:00
|
|
|
(LPARAM)(PrintStructures->hPortraitIcon));
|
|
|
|
}
|
2001-02-12 20:42:08 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-12 20:42:08 +01:00
|
|
|
case rad2: /* Paperorientation */
|
|
|
|
if (lppd->Flags & PD_PRINTSETUP)
|
2001-05-07 22:14:57 +02:00
|
|
|
{
|
2001-02-12 20:42:08 +01:00
|
|
|
lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
|
2001-05-07 22:14:57 +02:00
|
|
|
(LPARAM)(PrintStructures->hLandscapeIcon));
|
|
|
|
}
|
2001-02-12 20:42:08 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2008-01-29 22:46:01 +01:00
|
|
|
case cmb1: /* Printer Combobox in PRINT SETUP */
|
2001-07-14 02:47:20 +02:00
|
|
|
/* FALLTHROUGH */
|
2000-05-27 00:26:06 +02:00
|
|
|
case cmb4: /* Printer combobox */
|
|
|
|
if (HIWORD(wParam)==CBN_SELCHANGE) {
|
2002-04-11 19:32:49 +02:00
|
|
|
WCHAR PrinterName[256];
|
|
|
|
GetDlgItemTextW(hDlg, LOWORD(wParam), PrinterName, 255);
|
|
|
|
PRINTDLG_ChangePrinterW(hDlg, PrinterName, PrintStructures);
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cmb2: /* Papersize */
|
|
|
|
{
|
2004-09-22 21:11:05 +02:00
|
|
|
DWORD Sel = SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0);
|
2000-05-27 00:26:06 +02:00
|
|
|
if(Sel != CB_ERR)
|
2004-09-22 21:11:05 +02:00
|
|
|
lpdm->u1.s1.dmPaperSize = SendDlgItemMessageW(hDlg, cmb2,
|
2000-05-27 00:26:06 +02:00
|
|
|
CB_GETITEMDATA,
|
|
|
|
Sel, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cmb3: /* Bin */
|
|
|
|
{
|
2004-09-22 21:11:05 +02:00
|
|
|
DWORD Sel = SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0);
|
2000-05-27 00:26:06 +02:00
|
|
|
if(Sel != CB_ERR)
|
2007-11-01 07:22:11 +01:00
|
|
|
lpdm->u1.s1.dmDefaultSource = SendDlgItemMessageW(hDlg, cmb3,
|
2000-05-27 00:26:06 +02:00
|
|
|
CB_GETITEMDATA, Sel,
|
|
|
|
0);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
1999-08-07 14:34:54 +02:00
|
|
|
}
|
2001-02-12 19:09:34 +01:00
|
|
|
if(lppd->Flags & PD_PRINTSETUP) {
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case rad1: /* orientation */
|
|
|
|
case rad2:
|
|
|
|
if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
|
|
|
|
if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {
|
|
|
|
lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, stc10, STM_SETIMAGE,
|
2001-07-14 02:47:20 +02:00
|
|
|
(WPARAM)IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hPortraitIcon);
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE,
|
2001-02-12 19:09:34 +01:00
|
|
|
(WPARAM)IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hPortraitIcon);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {
|
|
|
|
lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, stc10, STM_SETIMAGE,
|
2001-07-14 02:47:20 +02:00
|
|
|
(WPARAM)IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hLandscapeIcon);
|
2004-09-22 21:11:05 +02:00
|
|
|
SendDlgItemMessageW(hDlg, ico1, STM_SETIMAGE,
|
2001-02-12 19:09:34 +01:00
|
|
|
(WPARAM)IMAGE_ICON,
|
|
|
|
(LPARAM)PrintStructures->hLandscapeIcon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
1999-11-13 21:49:58 +01:00
|
|
|
/***********************************************************************
|
2000-05-27 00:26:06 +02:00
|
|
|
* PrintDlgProcA [internal]
|
1999-11-13 21:49:58 +01:00
|
|
|
*/
|
2004-11-29 19:00:10 +01:00
|
|
|
static INT_PTR CALLBACK PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
1999-11-13 21:49:58 +01:00
|
|
|
{
|
2000-05-27 00:26:06 +02:00
|
|
|
PRINT_PTRA* PrintStructures;
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR res = FALSE;
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
if (uMsg!=WM_INITDIALOG) {
|
2008-12-27 13:21:19 +01:00
|
|
|
PrintStructures = GetPropW(hDlg, printdlg_prop);
|
2000-05-27 00:26:06 +02:00
|
|
|
if (!PrintStructures)
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
PrintStructures = (PRINT_PTRA*) lParam;
|
2008-12-27 13:21:19 +01:00
|
|
|
SetPropW(hDlg, printdlg_prop, PrintStructures);
|
2005-11-03 13:12:18 +01:00
|
|
|
if(!check_printer_setup(hDlg))
|
|
|
|
{
|
|
|
|
EndDialog(hDlg,FALSE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures);
|
|
|
|
|
2004-01-09 06:10:35 +01:00
|
|
|
if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
|
|
|
|
res = PrintStructures->lpPrintDlg->lpfnPrintHook(
|
|
|
|
hDlg, uMsg, wParam, (LPARAM)PrintStructures->lpPrintDlg
|
2002-06-01 01:06:46 +02:00
|
|
|
);
|
2000-05-27 00:26:06 +02:00
|
|
|
return res;
|
1999-11-13 21:49:58 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-09 06:10:35 +01:00
|
|
|
if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
|
|
|
|
res = PrintStructures->lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam,
|
2000-05-27 00:26:06 +02:00
|
|
|
lParam);
|
|
|
|
if(res) return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_COMMAND:
|
2002-04-11 19:32:49 +02:00
|
|
|
return PRINTDLG_WMCommandA(hDlg, wParam, lParam, PrintStructures);
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
DestroyIcon(PrintStructures->hCollateIcon);
|
|
|
|
DestroyIcon(PrintStructures->hNoCollateIcon);
|
|
|
|
DestroyIcon(PrintStructures->hPortraitIcon);
|
|
|
|
DestroyIcon(PrintStructures->hLandscapeIcon);
|
|
|
|
if(PrintStructures->hwndUpDown)
|
|
|
|
DestroyWindow(PrintStructures->hwndUpDown);
|
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2002-04-11 19:32:49 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2004-11-29 19:00:10 +01:00
|
|
|
static INT_PTR CALLBACK PrintDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
2002-04-11 19:32:49 +02:00
|
|
|
{
|
|
|
|
PRINT_PTRW* PrintStructures;
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR res = FALSE;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
if (uMsg!=WM_INITDIALOG) {
|
2008-12-27 13:21:19 +01:00
|
|
|
PrintStructures = GetPropW(hDlg, printdlg_prop);
|
2002-04-11 19:32:49 +02:00
|
|
|
if (!PrintStructures)
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
PrintStructures = (PRINT_PTRW*) lParam;
|
2008-12-27 13:21:19 +01:00
|
|
|
SetPropW(hDlg, printdlg_prop, PrintStructures);
|
2005-11-03 13:12:18 +01:00
|
|
|
if(!check_printer_setup(hDlg))
|
|
|
|
{
|
|
|
|
EndDialog(hDlg,FALSE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-04-11 19:32:49 +02:00
|
|
|
res = PRINTDLG_WMInitDialogW(hDlg, wParam, PrintStructures);
|
|
|
|
|
2004-01-09 06:10:35 +01:00
|
|
|
if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
|
|
|
|
res = PrintStructures->lpPrintDlg->lpfnPrintHook(hDlg, uMsg, wParam, (LPARAM)PrintStructures->lpPrintDlg);
|
2002-04-11 19:32:49 +02:00
|
|
|
return res;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-09 06:10:35 +01:00
|
|
|
if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
|
|
|
|
res = PrintStructures->lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam, lParam);
|
2002-04-11 19:32:49 +02:00
|
|
|
if(res) return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_COMMAND:
|
|
|
|
return PRINTDLG_WMCommandW(hDlg, wParam, lParam, PrintStructures);
|
1999-11-13 21:49:58 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
case WM_DESTROY:
|
|
|
|
DestroyIcon(PrintStructures->hCollateIcon);
|
|
|
|
DestroyIcon(PrintStructures->hNoCollateIcon);
|
2001-02-12 19:09:34 +01:00
|
|
|
DestroyIcon(PrintStructures->hPortraitIcon);
|
|
|
|
DestroyIcon(PrintStructures->hLandscapeIcon);
|
|
|
|
if(PrintStructures->hwndUpDown)
|
|
|
|
DestroyWindow(PrintStructures->hwndUpDown);
|
2000-05-27 00:26:06 +02:00
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
*
|
|
|
|
* PRINTDLG_GetDlgTemplate
|
|
|
|
*
|
|
|
|
*/
|
2007-04-06 11:56:15 +02:00
|
|
|
static HGLOBAL PRINTDLG_GetDlgTemplateA(const PRINTDLGA *lppd)
|
2000-05-27 00:26:06 +02:00
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
|
|
|
HGLOBAL hDlgTmpl;
|
2000-05-27 00:26:06 +02:00
|
|
|
|
|
|
|
if (lppd->Flags & PD_PRINTSETUP) {
|
2001-01-02 23:26:09 +01:00
|
|
|
if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
|
2000-05-27 00:26:06 +02:00
|
|
|
hDlgTmpl = lppd->hSetupTemplate;
|
2002-06-01 01:06:46 +02:00
|
|
|
} else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
|
2000-05-27 00:26:06 +02:00
|
|
|
hResInfo = FindResourceA(lppd->hInstance,
|
2003-09-10 05:56:47 +02:00
|
|
|
lppd->lpSetupTemplateName, (LPSTR)RT_DIALOG);
|
2000-05-27 00:26:06 +02:00
|
|
|
hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
|
|
|
|
} else {
|
|
|
|
hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP",
|
2003-09-10 05:56:47 +02:00
|
|
|
(LPSTR)RT_DIALOG);
|
2000-05-27 00:26:06 +02:00
|
|
|
hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
|
|
|
|
}
|
|
|
|
} else {
|
2001-01-02 23:26:09 +01:00
|
|
|
if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
|
2000-05-27 00:26:06 +02:00
|
|
|
hDlgTmpl = lppd->hPrintTemplate;
|
|
|
|
} else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
|
|
|
|
hResInfo = FindResourceA(lppd->hInstance,
|
|
|
|
lppd->lpPrintTemplateName,
|
2003-09-10 05:56:47 +02:00
|
|
|
(LPSTR)RT_DIALOG);
|
2000-05-27 00:26:06 +02:00
|
|
|
hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
|
|
|
|
} else {
|
|
|
|
hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32",
|
2003-09-10 05:56:47 +02:00
|
|
|
(LPSTR)RT_DIALOG);
|
2000-05-27 00:26:06 +02:00
|
|
|
hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hDlgTmpl;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2007-04-06 11:56:15 +02:00
|
|
|
static HGLOBAL PRINTDLG_GetDlgTemplateW(const PRINTDLGW *lppd)
|
2002-04-11 19:32:49 +02:00
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
|
|
|
HGLOBAL hDlgTmpl;
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR xpsetup[] = { 'P','R','I','N','T','3','2','_','S','E','T','U','P',0};
|
|
|
|
static const WCHAR xprint[] = { 'P','R','I','N','T','3','2',0};
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
if (lppd->Flags & PD_PRINTSETUP) {
|
|
|
|
if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
|
|
|
|
hDlgTmpl = lppd->hSetupTemplate;
|
2002-06-01 01:06:46 +02:00
|
|
|
} else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
|
2002-04-11 19:32:49 +02:00
|
|
|
hResInfo = FindResourceW(lppd->hInstance,
|
2003-09-10 05:56:47 +02:00
|
|
|
lppd->lpSetupTemplateName, (LPWSTR)RT_DIALOG);
|
2002-04-11 19:32:49 +02:00
|
|
|
hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
|
|
|
|
} else {
|
2003-09-10 05:56:47 +02:00
|
|
|
hResInfo = FindResourceW(COMDLG32_hInstance, xpsetup, (LPWSTR)RT_DIALOG);
|
2002-04-11 19:32:49 +02:00
|
|
|
hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
|
|
|
|
hDlgTmpl = lppd->hPrintTemplate;
|
|
|
|
} else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
|
|
|
|
hResInfo = FindResourceW(lppd->hInstance,
|
|
|
|
lppd->lpPrintTemplateName,
|
2003-09-10 05:56:47 +02:00
|
|
|
(LPWSTR)RT_DIALOG);
|
2002-04-11 19:32:49 +02:00
|
|
|
hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
|
|
|
|
} else {
|
2003-09-10 05:56:47 +02:00
|
|
|
hResInfo = FindResourceW(COMDLG32_hInstance, xprint, (LPWSTR)RT_DIALOG);
|
2002-04-11 19:32:49 +02:00
|
|
|
hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hDlgTmpl;
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2000-05-27 00:26:06 +02:00
|
|
|
*
|
|
|
|
* PRINTDLG_CreateDC
|
|
|
|
*
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-04-11 19:32:49 +02:00
|
|
|
static BOOL PRINTDLG_CreateDCA(LPPRINTDLGA lppd)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-05-27 00:26:06 +02:00
|
|
|
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;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
static BOOL PRINTDLG_CreateDCW(LPPRINTDLGW lppd)
|
|
|
|
{
|
|
|
|
DEVNAMES *pdn = GlobalLock(lppd->hDevNames);
|
|
|
|
DEVMODEW *pdm = GlobalLock(lppd->hDevMode);
|
|
|
|
|
|
|
|
if(lppd->Flags & PD_RETURNDC) {
|
|
|
|
lppd->hDC = CreateDCW((WCHAR*)pdn + pdn->wDriverOffset,
|
|
|
|
(WCHAR*)pdn + pdn->wDeviceOffset,
|
|
|
|
(WCHAR*)pdn + pdn->wOutputOffset,
|
|
|
|
pdm );
|
|
|
|
} else if(lppd->Flags & PD_RETURNIC) {
|
|
|
|
lppd->hDC = CreateICW((WCHAR*)pdn + pdn->wDriverOffset,
|
|
|
|
(WCHAR*)pdn + pdn->wDeviceOffset,
|
|
|
|
(WCHAR*)pdn + pdn->wOutputOffset,
|
|
|
|
pdm );
|
|
|
|
}
|
|
|
|
GlobalUnlock(lppd->hDevNames);
|
|
|
|
GlobalUnlock(lppd->hDevMode);
|
|
|
|
return lppd->hDC ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/***********************************************************************
|
2002-04-11 19:32:49 +02:00
|
|
|
* PrintDlgA (COMDLG32.@)
|
|
|
|
*
|
2007-10-23 15:30:30 +02:00
|
|
|
* Displays the PRINT dialog box, which enables the user to specify
|
2002-04-11 19:32:49 +02:00
|
|
|
* specific properties of the print job.
|
2005-07-07 20:23:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lppd [IO] ptr to PRINTDLG32 struct
|
|
|
|
*
|
2002-04-11 19:32:49 +02:00
|
|
|
* RETURNS
|
|
|
|
* nonzero if the user pressed the OK button
|
|
|
|
* zero if the user cancelled the window or an error occurred
|
2005-07-07 20:23:45 +02:00
|
|
|
*
|
2002-04-11 19:32:49 +02:00
|
|
|
* BUGS
|
|
|
|
* PrintDlg:
|
|
|
|
* * The Collate Icons do not display, even though they are in the code.
|
|
|
|
* * The Properties Button(s) should call DocumentPropertiesA().
|
|
|
|
*/
|
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
BOOL WINAPI PrintDlgA(LPPRINTDLGA lppd)
|
2002-04-11 19:32:49 +02:00
|
|
|
{
|
|
|
|
BOOL bRet = FALSE;
|
2006-12-14 18:13:01 +01:00
|
|
|
LPVOID ptr;
|
|
|
|
HINSTANCE hInst;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
2006-12-14 18:13:01 +01:00
|
|
|
if (!lppd)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_INITIALIZATION);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hInst = (HINSTANCE)GetWindowLongPtrA( lppd->hwndOwner, GWLP_HINSTANCE );
|
2002-04-11 19:32:49 +02:00
|
|
|
if(TRACE_ON(commdlg)) {
|
|
|
|
char flagstr[1000] = "";
|
2006-11-29 11:04:52 +01:00
|
|
|
const struct pd_flags *pflag = pd_flags;
|
2002-04-11 19:32:49 +02:00
|
|
|
for( ; pflag->name; pflag++) {
|
|
|
|
if(lppd->Flags & pflag->flag)
|
|
|
|
strcat(flagstr, pflag->name);
|
|
|
|
}
|
2002-11-22 00:55:10 +01:00
|
|
|
TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
|
2006-10-13 15:04:43 +02:00
|
|
|
"pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
|
|
|
|
"flags %08x (%s)\n",
|
2002-04-11 19:32:49 +02:00
|
|
|
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);
|
2002-06-01 01:06:46 +02:00
|
|
|
return FALSE;
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(lppd->Flags & PD_RETURNDEFAULT) {
|
|
|
|
PRINTER_INFO_2A *pbuf;
|
|
|
|
DRIVER_INFO_3A *dbuf;
|
|
|
|
HANDLE hprn;
|
|
|
|
DWORD needed;
|
|
|
|
|
|
|
|
if(lppd->hDevMode || lppd->hDevNames) {
|
|
|
|
WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
|
2002-04-11 19:32:49 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
|
|
|
|
WARN("Can't find default printer\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
|
2002-04-11 19:32:49 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetPrinterA(hprn, 2, NULL, 0, &needed);
|
|
|
|
pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
|
|
|
|
|
|
|
|
GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
|
|
|
|
dbuf = HeapAlloc(GetProcessHeap(),0,needed);
|
|
|
|
if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
|
2007-09-14 01:16:11 +02:00
|
|
|
ERR("GetPrinterDriverA failed, le %d, fix your config for printer %s!\n",
|
|
|
|
GetLastError(),pbuf->pPrinterName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pbuf);
|
2002-06-01 01:06:46 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
|
2002-04-11 19:32:49 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ClosePrinter(hprn);
|
|
|
|
|
|
|
|
PRINTDLG_CreateDevNames(&(lppd->hDevNames),
|
|
|
|
dbuf->pDriverPath,
|
|
|
|
pbuf->pPrinterName,
|
|
|
|
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);
|
|
|
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
|
|
|
bRet = TRUE;
|
|
|
|
} else {
|
|
|
|
HGLOBAL hDlgTmpl;
|
|
|
|
PRINT_PTRA *PrintStructures;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* load Dialog resources,
|
|
|
|
* depending on Flags indicates Print32 or Print32_setup dialog
|
2002-04-11 19:32:49 +02:00
|
|
|
*/
|
|
|
|
hDlgTmpl = PRINTDLG_GetDlgTemplateA(lppd);
|
|
|
|
if (!hDlgTmpl) {
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ptr = LockResource( hDlgTmpl );
|
|
|
|
if (!ptr) {
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(PRINT_PTRA));
|
2004-01-09 06:10:35 +01:00
|
|
|
PrintStructures->lpPrintDlg = lppd;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
|
|
|
/* and create & process the dialog .
|
|
|
|
* -1 is failure, 0 is broken hwnd, everything else is ok.
|
|
|
|
*/
|
|
|
|
bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner,
|
|
|
|
PrintDlgProcA,
|
|
|
|
(LPARAM)PrintStructures));
|
|
|
|
|
|
|
|
if(bRet) {
|
|
|
|
DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
|
|
|
|
PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
|
|
|
|
DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
|
|
|
|
|
|
|
|
if (lppd->hDevMode == 0) {
|
|
|
|
TRACE(" No hDevMode yet... Need to create my own\n");
|
|
|
|
lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE,
|
|
|
|
lpdm->dmSize + lpdm->dmDriverExtra);
|
|
|
|
} else {
|
|
|
|
lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,
|
|
|
|
lpdm->dmSize + lpdm->dmDriverExtra,
|
|
|
|
GMEM_MOVEABLE);
|
|
|
|
}
|
|
|
|
lpdmReturn = GlobalLock(lppd->hDevMode);
|
|
|
|
memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
|
|
|
|
|
|
|
|
PRINTDLG_CreateDevNames(&(lppd->hDevNames),
|
|
|
|
di->pDriverPath,
|
|
|
|
pi->pPrinterName,
|
|
|
|
pi->pPortName
|
|
|
|
);
|
|
|
|
GlobalUnlock(lppd->hDevMode);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
|
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
|
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
|
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures);
|
|
|
|
}
|
|
|
|
if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
|
|
|
|
bRet = PRINTDLG_CreateDCA(lppd);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("exit! (%d)\n", bRet);
|
|
|
|
return bRet;
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PrintDlgW (COMDLG32.@)
|
2005-11-12 20:12:25 +01:00
|
|
|
*
|
|
|
|
* See PrintDlgA.
|
2000-05-27 00:26:06 +02:00
|
|
|
*/
|
2006-12-14 18:13:01 +01:00
|
|
|
BOOL WINAPI PrintDlgW(LPPRINTDLGW lppd)
|
2000-05-27 00:26:06 +02:00
|
|
|
{
|
|
|
|
BOOL bRet = FALSE;
|
2006-12-14 18:13:01 +01:00
|
|
|
LPVOID ptr;
|
|
|
|
HINSTANCE hInst;
|
|
|
|
|
|
|
|
if (!lppd)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_INITIALIZATION);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2006-12-14 18:13:01 +01:00
|
|
|
hInst = (HINSTANCE)GetWindowLongPtrW( lppd->hwndOwner, GWLP_HINSTANCE );
|
2000-05-27 00:26:06 +02:00
|
|
|
if(TRACE_ON(commdlg)) {
|
|
|
|
char flagstr[1000] = "";
|
2006-11-29 11:04:52 +01:00
|
|
|
const struct pd_flags *pflag = pd_flags;
|
2000-05-27 00:26:06 +02:00
|
|
|
for( ; pflag->name; pflag++) {
|
|
|
|
if(lppd->Flags & pflag->flag)
|
|
|
|
strcat(flagstr, pflag->name);
|
|
|
|
}
|
2002-11-22 00:55:10 +01:00
|
|
|
TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
|
2006-10-13 15:04:43 +02:00
|
|
|
"pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
|
|
|
|
"flags %08x (%s)\n",
|
2000-05-27 00:26:06 +02:00
|
|
|
lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
|
|
|
|
lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
|
|
|
|
lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
|
|
|
|
}
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
if(lppd->lStructSize != sizeof(PRINTDLGW)) {
|
2000-05-27 00:26:06 +02:00
|
|
|
WARN("structure size failure !!!\n");
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
|
2002-06-01 01:06:46 +02:00
|
|
|
return FALSE;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(lppd->Flags & PD_RETURNDEFAULT) {
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTER_INFO_2W *pbuf;
|
|
|
|
DRIVER_INFO_3W *dbuf;
|
2000-05-27 00:26:06 +02:00
|
|
|
HANDLE hprn;
|
|
|
|
DWORD needed;
|
|
|
|
|
|
|
|
if(lppd->hDevMode || lppd->hDevNames) {
|
|
|
|
WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
|
|
|
if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
|
|
|
|
WARN("Can't find default printer\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
|
2000-05-27 00:26:06 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
GetPrinterW(hprn, 2, NULL, 0, &needed);
|
2008-11-25 16:40:05 +01:00
|
|
|
pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
|
2002-04-11 19:32:49 +02:00
|
|
|
GetPrinterW(hprn, 2, (LPBYTE)pbuf, needed, &needed);
|
2001-05-02 03:10:43 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
|
2008-11-25 16:40:05 +01:00
|
|
|
dbuf = HeapAlloc(GetProcessHeap(),0,needed);
|
2002-04-11 19:32:49 +02:00
|
|
|
if (!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
|
2007-09-14 01:16:11 +02:00
|
|
|
ERR("GetPrinterDriverA failed, le %d, fix your config for printer %s!\n",
|
|
|
|
GetLastError(),debugstr_w(pbuf->pPrinterName));
|
|
|
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pbuf);
|
2002-06-01 01:06:46 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
|
2001-05-02 03:10:43 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-27 00:26:06 +02:00
|
|
|
ClosePrinter(hprn);
|
2001-05-02 03:10:43 +02:00
|
|
|
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTDLG_CreateDevNamesW(&(lppd->hDevNames),
|
2001-05-02 03:10:43 +02:00
|
|
|
dbuf->pDriverPath,
|
|
|
|
pbuf->pPrinterName,
|
2000-05-27 00:26:06 +02:00
|
|
|
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);
|
2001-05-02 03:10:43 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
2000-05-27 00:26:06 +02:00
|
|
|
bRet = TRUE;
|
|
|
|
} else {
|
|
|
|
HGLOBAL hDlgTmpl;
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINT_PTRW *PrintStructures;
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* load Dialog resources,
|
|
|
|
* depending on Flags indicates Print32 or Print32_setup dialog
|
2000-05-27 00:26:06 +02:00
|
|
|
*/
|
2002-04-11 19:32:49 +02:00
|
|
|
hDlgTmpl = PRINTDLG_GetDlgTemplateW(lppd);
|
2001-01-02 23:26:09 +01:00
|
|
|
if (!hDlgTmpl) {
|
2000-05-27 00:26:06 +02:00
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-01-02 23:26:09 +01:00
|
|
|
ptr = LockResource( hDlgTmpl );
|
|
|
|
if (!ptr) {
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2002-04-11 19:32:49 +02:00
|
|
|
sizeof(PRINT_PTRW));
|
2004-01-09 06:10:35 +01:00
|
|
|
PrintStructures->lpPrintDlg = lppd;
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2000-12-08 00:13:03 +01:00
|
|
|
/* and create & process the dialog .
|
|
|
|
* -1 is failure, 0 is broken hwnd, everything else is ok.
|
2000-05-27 00:26:06 +02:00
|
|
|
*/
|
2002-04-11 19:32:49 +02:00
|
|
|
bRet = (0<DialogBoxIndirectParamW(hInst, ptr, lppd->hwndOwner,
|
|
|
|
PrintDlgProcW,
|
2001-01-02 23:26:09 +01:00
|
|
|
(LPARAM)PrintStructures));
|
2000-05-27 00:26:06 +02:00
|
|
|
|
|
|
|
if(bRet) {
|
2002-04-11 19:32:49 +02:00
|
|
|
DEVMODEW *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
|
|
|
|
PRINTER_INFO_2W *pi = PrintStructures->lpPrinterInfo;
|
|
|
|
DRIVER_INFO_3W *di = PrintStructures->lpDriverInfo;
|
2000-05-27 00:26:06 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2002-04-11 19:32:49 +02:00
|
|
|
PRINTDLG_CreateDevNamesW(&(lppd->hDevNames),
|
2001-05-02 03:10:43 +02:00
|
|
|
di->pDriverPath,
|
|
|
|
pi->pPrinterName,
|
|
|
|
pi->pPortName
|
|
|
|
);
|
2000-05-27 00:26:06 +02:00
|
|
|
GlobalUnlock(lppd->hDevMode);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
|
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
|
2001-05-02 03:10:43 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
|
2000-05-27 00:26:06 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, PrintStructures);
|
|
|
|
}
|
|
|
|
if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
|
2002-04-11 19:32:49 +02:00
|
|
|
bRet = PRINTDLG_CreateDCW(lppd);
|
2000-05-27 00:26:06 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("exit! (%d)\n", bRet);
|
|
|
|
return bRet;
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* PageSetupDlg
|
2001-05-05 02:44:03 +02:00
|
|
|
* rad1 - portrait
|
|
|
|
* rad2 - landscape
|
2007-02-14 16:22:07 +01:00
|
|
|
* cmb1 - printer select (not in standard dialog template)
|
2001-05-05 02:44:03 +02:00
|
|
|
* cmb2 - paper size
|
|
|
|
* cmb3 - source (tray?)
|
|
|
|
* edt4 - border left
|
|
|
|
* edt5 - border top
|
|
|
|
* edt6 - border right
|
|
|
|
* edt7 - border bottom
|
|
|
|
* psh3 - "Printer..."
|
2000-05-27 00:26:06 +02:00
|
|
|
*/
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
BOOL unicode;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
LPPAGESETUPDLGA dlga;
|
|
|
|
LPPAGESETUPDLGW dlgw;
|
|
|
|
} u;
|
|
|
|
HWND hDlg; /* Page Setup dialog handle */
|
|
|
|
RECT rtDrawRect; /* Drawing rect for page */
|
2009-01-22 13:24:07 +01:00
|
|
|
} pagesetup_data;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
2009-01-22 16:16:26 +01:00
|
|
|
static inline DWORD pagesetup_get_flags(const pagesetup_data *data)
|
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
return data->u.dlgw->Flags;
|
2009-01-22 16:16:26 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static inline BOOL is_metric(const pagesetup_data *data)
|
2009-01-16 13:08:18 +01:00
|
|
|
{
|
2009-01-22 16:16:26 +01:00
|
|
|
return pagesetup_get_flags(data) & PSD_INHUNDREDTHSOFMILLIMETERS;
|
2009-01-16 13:08:18 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static inline LONG tenths_mm_to_size(pagesetup_data *data, LONG size)
|
2009-01-21 19:12:21 +01:00
|
|
|
{
|
|
|
|
if (is_metric(data))
|
|
|
|
return 10 * size;
|
|
|
|
else
|
|
|
|
return 10 * size * 100 / 254;
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static inline LONG thousandths_inch_to_size(pagesetup_data *data, LONG size)
|
2009-01-21 19:13:51 +01:00
|
|
|
{
|
|
|
|
if (is_metric(data))
|
|
|
|
return size * 254 / 100;
|
|
|
|
else
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2009-01-19 15:28:43 +01:00
|
|
|
static WCHAR get_decimal_sep(void)
|
|
|
|
{
|
|
|
|
static WCHAR sep;
|
|
|
|
|
|
|
|
if(!sep)
|
|
|
|
{
|
|
|
|
WCHAR buf[2] = {'.',0};
|
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buf, sizeof(buf) / sizeof(buf[0]));
|
|
|
|
sep = buf[0];
|
|
|
|
}
|
|
|
|
return sep;
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void size2str(const pagesetup_data *data, DWORD size, LPWSTR strout)
|
2009-01-15 11:45:29 +01:00
|
|
|
{
|
2009-01-16 13:04:45 +01:00
|
|
|
WCHAR integer_fmt[] = {'%','d',0};
|
2009-01-19 15:28:43 +01:00
|
|
|
WCHAR hundredths_fmt[] = {'%','d','%','c','%','0','2','d',0};
|
|
|
|
WCHAR thousandths_fmt[] = {'%','d','%','c','%','0','3','d',0};
|
2009-01-16 13:04:45 +01:00
|
|
|
|
|
|
|
/* FIXME use LOCALE_SDECIMAL when the edit parsing code can cope */
|
2009-01-15 11:45:29 +01:00
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
if (is_metric(data))
|
2009-01-16 13:04:45 +01:00
|
|
|
{
|
|
|
|
if(size % 100)
|
2009-01-19 15:28:43 +01:00
|
|
|
wsprintfW(strout, hundredths_fmt, size / 100, get_decimal_sep(), size % 100);
|
2009-01-16 13:04:45 +01:00
|
|
|
else
|
|
|
|
wsprintfW(strout, integer_fmt, size / 100);
|
|
|
|
}
|
2009-01-15 11:45:29 +01:00
|
|
|
else
|
2009-01-16 13:04:45 +01:00
|
|
|
{
|
|
|
|
if(size % 1000)
|
2009-01-19 15:28:43 +01:00
|
|
|
wsprintfW(strout, thousandths_fmt, size / 1000, get_decimal_sep(), size % 1000);
|
2009-01-16 13:04:45 +01:00
|
|
|
else
|
|
|
|
wsprintfW(strout, integer_fmt, size / 1000);
|
|
|
|
|
|
|
|
}
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
2009-01-15 11:45:29 +01:00
|
|
|
|
2009-01-15 11:45:21 +01:00
|
|
|
static inline BOOL is_default_metric(void)
|
|
|
|
{
|
|
|
|
DWORD system;
|
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IMEASURE | LOCALE_RETURN_NUMBER,
|
|
|
|
(LPWSTR)&system, sizeof(system));
|
|
|
|
return system == 0;
|
|
|
|
}
|
|
|
|
|
2009-01-16 13:08:12 +01:00
|
|
|
/**********************************************
|
|
|
|
* rotate_rect
|
|
|
|
* Cyclically permute the four members of rc
|
|
|
|
* If sense is TRUE l -> t -> r -> b
|
|
|
|
* otherwise l <- t <- r <- b
|
|
|
|
*/
|
|
|
|
static inline void rotate_rect(RECT *rc, BOOL sense)
|
|
|
|
{
|
|
|
|
INT tmp;
|
|
|
|
if(sense)
|
|
|
|
{
|
|
|
|
tmp = rc->bottom;
|
|
|
|
rc->bottom = rc->right;
|
|
|
|
rc->right = rc->top;
|
|
|
|
rc->top = rc->left;
|
|
|
|
rc->left = tmp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmp = rc->left;
|
|
|
|
rc->left = rc->top;
|
|
|
|
rc->top = rc->right;
|
|
|
|
rc->right = rc->bottom;
|
|
|
|
rc->bottom = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_set_orientation(pagesetup_data *data, WORD orient)
|
2009-01-19 16:40:02 +01:00
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
|
2009-01-19 16:40:02 +01:00
|
|
|
|
|
|
|
assert(orient == DMORIENT_PORTRAIT || orient == DMORIENT_LANDSCAPE);
|
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
if(data->unicode)
|
|
|
|
dm->u1.s1.dmOrientation = orient;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DEVMODEA *dmA = (DEVMODEA *)dm;
|
|
|
|
dmA->u1.s1.dmOrientation = orient;
|
|
|
|
}
|
|
|
|
GlobalUnlock(data->u.dlgw->hDevMode);
|
2009-01-19 16:40:02 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static WORD pagesetup_get_orientation(const pagesetup_data *data)
|
2009-01-19 16:52:09 +01:00
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
|
|
|
|
WORD orient;
|
|
|
|
|
|
|
|
if(data->unicode)
|
|
|
|
orient = dm->u1.s1.dmOrientation;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DEVMODEA *dmA = (DEVMODEA *)dm;
|
|
|
|
orient = dmA->u1.s1.dmOrientation;
|
|
|
|
}
|
|
|
|
GlobalUnlock(data->u.dlgw->hDevMode);
|
2009-01-19 16:52:09 +01:00
|
|
|
return orient;
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_set_papersize(pagesetup_data *data, WORD paper)
|
2009-01-19 17:38:43 +01:00
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
|
|
|
|
|
|
|
|
if(data->unicode)
|
|
|
|
dm->u1.s1.dmPaperSize = paper;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DEVMODEA *dmA = (DEVMODEA *)dm;
|
|
|
|
dmA->u1.s1.dmPaperSize = paper;
|
|
|
|
}
|
|
|
|
GlobalUnlock(data->u.dlgw->hDevMode);
|
2009-01-19 17:38:43 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static WORD pagesetup_get_papersize(const pagesetup_data *data)
|
2009-01-19 17:38:43 +01:00
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
|
|
|
|
WORD paper;
|
|
|
|
|
|
|
|
if(data->unicode)
|
|
|
|
paper = dm->u1.s1.dmPaperSize;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DEVMODEA *dmA = (DEVMODEA *)dm;
|
|
|
|
paper = dmA->u1.s1.dmPaperSize;
|
|
|
|
}
|
|
|
|
GlobalUnlock(data->u.dlgw->hDevMode);
|
2009-01-19 17:38:43 +01:00
|
|
|
return paper;
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_set_defaultsource(pagesetup_data *data, WORD source)
|
2009-01-19 17:57:24 +01:00
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
|
|
|
|
|
|
|
|
if(data->unicode)
|
|
|
|
dm->u1.s1.dmDefaultSource = source;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DEVMODEA *dmA = (DEVMODEA *)dm;
|
|
|
|
dmA->u1.s1.dmDefaultSource = source;
|
|
|
|
}
|
|
|
|
GlobalUnlock(data->u.dlgw->hDevMode);
|
2009-01-19 17:57:24 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 17:49:52 +01:00
|
|
|
typedef enum
|
2009-01-21 11:45:19 +01:00
|
|
|
{
|
2009-01-22 17:49:52 +01:00
|
|
|
devnames_driver_name,
|
|
|
|
devnames_device_name,
|
|
|
|
devnames_output_name
|
|
|
|
} devnames_name;
|
2009-01-21 11:45:19 +01:00
|
|
|
|
|
|
|
|
2009-01-22 17:49:52 +01:00
|
|
|
static inline WORD get_devname_offset(DEVNAMES *dn, devnames_name which)
|
2009-01-21 11:45:19 +01:00
|
|
|
{
|
2009-01-22 17:49:52 +01:00
|
|
|
switch(which)
|
|
|
|
{
|
|
|
|
case devnames_driver_name: return dn->wDriverOffset;
|
|
|
|
case devnames_device_name: return dn->wDeviceOffset;
|
|
|
|
case devnames_output_name: return dn->wOutputOffset;
|
|
|
|
}
|
|
|
|
ERR("Souldn't be here\n");
|
|
|
|
return 0;
|
2009-01-21 11:45:19 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 17:49:52 +01:00
|
|
|
static WCHAR *pagesetup_get_a_devname(const pagesetup_data *data, devnames_name which)
|
2009-01-21 11:28:00 +01:00
|
|
|
{
|
|
|
|
DEVNAMES *dn;
|
|
|
|
WCHAR *name;
|
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
dn = GlobalLock(data->u.dlgw->hDevNames);
|
|
|
|
if(data->unicode)
|
|
|
|
name = strdupW((WCHAR *)dn + get_devname_offset(dn, which));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, (char*)dn + get_devname_offset(dn, which), -1, NULL, 0);
|
|
|
|
name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, (char*)dn + get_devname_offset(dn, which), -1, name, len);
|
|
|
|
}
|
|
|
|
GlobalUnlock(data->u.dlgw->hDevNames);
|
2009-01-21 11:28:00 +01:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2009-01-22 17:49:52 +01:00
|
|
|
static WCHAR *pagesetup_get_drvname(const pagesetup_data *data)
|
2009-01-21 11:30:26 +01:00
|
|
|
{
|
2009-01-22 17:49:52 +01:00
|
|
|
return pagesetup_get_a_devname(data, devnames_driver_name);
|
2009-01-21 11:30:26 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 17:49:52 +01:00
|
|
|
static WCHAR *pagesetup_get_devname(const pagesetup_data *data)
|
2009-01-21 11:30:26 +01:00
|
|
|
{
|
2009-01-22 17:49:52 +01:00
|
|
|
return pagesetup_get_a_devname(data, devnames_device_name);
|
|
|
|
}
|
2009-01-21 11:30:26 +01:00
|
|
|
|
2009-01-22 17:49:52 +01:00
|
|
|
static WCHAR *pagesetup_get_portname(const pagesetup_data *data)
|
|
|
|
{
|
|
|
|
return pagesetup_get_a_devname(data, devnames_output_name);
|
2009-01-21 11:30:26 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 17:49:52 +01:00
|
|
|
static void pagesetup_release_a_devname(const pagesetup_data *data, WCHAR *name)
|
2009-01-21 11:30:26 +01:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, name);
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_set_devnames(pagesetup_data *data, LPCWSTR drv, LPCWSTR devname, LPCWSTR port)
|
2009-01-21 11:41:36 +01:00
|
|
|
{
|
|
|
|
DEVNAMES *dn;
|
|
|
|
WCHAR def[256];
|
|
|
|
DWORD len = sizeof(DEVNAMES), drv_len, dev_len, port_len;
|
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
if(data->unicode)
|
|
|
|
{
|
|
|
|
drv_len = (strlenW(drv) + 1) * sizeof(WCHAR);
|
|
|
|
dev_len = (strlenW(devname) + 1) * sizeof(WCHAR);
|
|
|
|
port_len = (strlenW(port) + 1) * sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
drv_len = WideCharToMultiByte(CP_ACP, 0, drv, -1, NULL, 0, NULL, NULL);
|
|
|
|
dev_len = WideCharToMultiByte(CP_ACP, 0, devname, -1, NULL, 0, NULL, NULL);
|
|
|
|
port_len = WideCharToMultiByte(CP_ACP, 0, port, -1, NULL, 0, NULL, NULL);
|
|
|
|
}
|
2009-01-21 11:41:36 +01:00
|
|
|
len += drv_len + dev_len + port_len;
|
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
if(data->u.dlgw->hDevNames)
|
|
|
|
data->u.dlgw->hDevNames = GlobalReAlloc(data->u.dlgw->hDevNames, len, GMEM_MOVEABLE);
|
|
|
|
else
|
|
|
|
data->u.dlgw->hDevNames = GlobalAlloc(GMEM_MOVEABLE, len);
|
|
|
|
|
|
|
|
dn = GlobalLock(data->u.dlgw->hDevNames);
|
|
|
|
|
|
|
|
if(data->unicode)
|
|
|
|
{
|
|
|
|
WCHAR *ptr = (WCHAR *)(dn + 1);
|
|
|
|
len = sizeof(DEVNAMES) / sizeof(WCHAR);
|
|
|
|
dn->wDriverOffset = len;
|
|
|
|
strcpyW(ptr, drv);
|
|
|
|
ptr += drv_len / sizeof(WCHAR);
|
|
|
|
len += drv_len / sizeof(WCHAR);
|
|
|
|
dn->wDeviceOffset = len;
|
|
|
|
strcpyW(ptr, devname);
|
|
|
|
ptr += dev_len / sizeof(WCHAR);
|
|
|
|
len += dev_len / sizeof(WCHAR);
|
|
|
|
dn->wOutputOffset = len;
|
|
|
|
strcpyW(ptr, port);
|
|
|
|
}
|
2009-01-23 15:19:46 +01:00
|
|
|
else
|
2009-01-23 16:26:29 +01:00
|
|
|
{
|
|
|
|
char *ptr = (char *)(dn + 1);
|
|
|
|
len = sizeof(DEVNAMES);
|
|
|
|
dn->wDriverOffset = len;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, drv, -1, ptr, drv_len, NULL, NULL);
|
|
|
|
ptr += drv_len;
|
|
|
|
len += drv_len;
|
|
|
|
dn->wDeviceOffset = len;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, devname, -1, ptr, dev_len, NULL, NULL);
|
|
|
|
ptr += dev_len;
|
|
|
|
len += dev_len;
|
|
|
|
dn->wOutputOffset = len;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, port, -1, ptr, port_len, NULL, NULL);
|
|
|
|
}
|
2009-01-21 11:41:36 +01:00
|
|
|
|
|
|
|
dn->wDefault = 0;
|
|
|
|
len = sizeof(def) / sizeof(def[0]);
|
|
|
|
GetDefaultPrinterW(def, &len);
|
|
|
|
if(!lstrcmpW(def, devname))
|
|
|
|
dn->wDefault = 1;
|
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
GlobalUnlock(data->u.dlgw->hDevNames);
|
2009-01-21 11:41:36 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static DEVMODEW *pagesetup_get_devmode(const pagesetup_data *data)
|
2009-01-21 11:30:26 +01:00
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
|
|
|
|
DEVMODEW *ret;
|
2009-01-21 11:30:26 +01:00
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
if(data->unicode)
|
|
|
|
{
|
|
|
|
/* We make a copy even in the unicode case because the ptr
|
|
|
|
may get passed back to us in pagesetup_set_devmode. */
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, dm->dmSize + dm->dmDriverExtra);
|
|
|
|
memcpy(ret, dm, dm->dmSize + dm->dmDriverExtra);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = GdiConvertToDevmodeW((DEVMODEA *)dm);
|
|
|
|
|
|
|
|
GlobalUnlock(data->u.dlgw->hDevMode);
|
|
|
|
return ret;
|
2009-01-21 11:30:26 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_release_devmode(const pagesetup_data *data, DEVMODEW *dm)
|
2009-01-21 11:30:26 +01:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, dm);
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_set_devmode(pagesetup_data *data, DEVMODEW *dm)
|
2009-01-21 11:41:36 +01:00
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
DEVMODEA *dmA = NULL;
|
|
|
|
void *src, *dst;
|
|
|
|
DWORD size;
|
2009-01-21 11:41:36 +01:00
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
if(data->unicode)
|
|
|
|
{
|
|
|
|
size = dm->dmSize + dm->dmDriverExtra;
|
|
|
|
src = dm;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dmA = convert_to_devmodeA(dm);
|
|
|
|
size = dmA->dmSize + dmA->dmDriverExtra;
|
|
|
|
src = dmA;
|
|
|
|
}
|
2009-01-23 15:19:46 +01:00
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
if(data->u.dlgw->hDevMode)
|
|
|
|
data->u.dlgw->hDevMode = GlobalReAlloc(data->u.dlgw->hDevMode, size,
|
|
|
|
GMEM_MOVEABLE);
|
2009-01-23 15:19:46 +01:00
|
|
|
else
|
2009-01-23 16:26:29 +01:00
|
|
|
data->u.dlgw->hDevMode = GlobalAlloc(GMEM_MOVEABLE, size);
|
|
|
|
|
|
|
|
dst = GlobalLock(data->u.dlgw->hDevMode);
|
|
|
|
memcpy(dst, src, size);
|
|
|
|
GlobalUnlock(data->u.dlgw->hDevMode);
|
|
|
|
HeapFree(GetProcessHeap(), 0, dmA);
|
2009-01-21 11:41:36 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 16:33:09 +01:00
|
|
|
static inline POINT *pagesetup_get_papersize_pt(const pagesetup_data *data)
|
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
return &data->u.dlgw->ptPaperSize;
|
2009-01-22 16:33:09 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 16:47:07 +01:00
|
|
|
static inline RECT *pagesetup_get_margin_rect(const pagesetup_data *data)
|
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
return &data->u.dlgw->rtMargin;
|
2009-01-22 16:47:07 +01:00
|
|
|
}
|
|
|
|
|
2009-01-23 00:11:21 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
page_setup_hook,
|
|
|
|
page_paint_hook
|
|
|
|
} hook_type;
|
|
|
|
|
|
|
|
static inline LPPAGESETUPHOOK pagesetup_get_hook(const pagesetup_data *data, hook_type which)
|
|
|
|
{
|
|
|
|
switch(which)
|
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
case page_setup_hook: return data->u.dlgw->lpfnPageSetupHook;
|
|
|
|
case page_paint_hook: return data->u.dlgw->lpfnPagePaintHook;
|
2009-01-23 00:11:21 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-23 12:12:17 +01:00
|
|
|
/* This should only be used in calls to hook procs so we return the ptr
|
|
|
|
already cast to LPARAM */
|
|
|
|
static inline LPARAM pagesetup_get_dlg_struct(const pagesetup_data *data)
|
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
return (LPARAM)data->u.dlgw;
|
2009-01-23 12:12:17 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 16:33:09 +01:00
|
|
|
static inline void swap_point(POINT *pt)
|
|
|
|
{
|
|
|
|
LONG tmp = pt->x;
|
|
|
|
pt->x = pt->y;
|
|
|
|
pt->y = tmp;
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static BOOL pagesetup_update_papersize(pagesetup_data *data)
|
2009-01-13 13:18:28 +01:00
|
|
|
{
|
2009-01-20 13:06:46 +01:00
|
|
|
DEVMODEW *dm;
|
|
|
|
LPWSTR devname, portname;
|
2009-01-13 13:18:28 +01:00
|
|
|
int i, num;
|
2009-01-19 17:38:43 +01:00
|
|
|
WORD *words = NULL, paperword;
|
2009-01-13 13:18:28 +01:00
|
|
|
POINT *points = NULL;
|
|
|
|
BOOL retval = FALSE;
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
dm = pagesetup_get_devmode(data);
|
|
|
|
devname = pagesetup_get_devname(data);
|
|
|
|
portname = pagesetup_get_portname(data);
|
2009-01-13 13:18:28 +01:00
|
|
|
|
2009-01-20 13:06:46 +01:00
|
|
|
num = DeviceCapabilitiesW(devname, portname, DC_PAPERS, NULL, dm);
|
2009-01-13 13:18:28 +01:00
|
|
|
if (num <= 0)
|
|
|
|
{
|
2009-01-20 13:06:46 +01:00
|
|
|
FIXME("No papernames found for %s/%s\n", debugstr_w(devname), debugstr_w(portname));
|
2009-01-13 13:18:28 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
words = HeapAlloc(GetProcessHeap(), 0, num * sizeof(WORD));
|
|
|
|
points = HeapAlloc(GetProcessHeap(), 0, num * sizeof(POINT));
|
|
|
|
|
2009-01-20 13:06:46 +01:00
|
|
|
if (num != DeviceCapabilitiesW(devname, portname, DC_PAPERS, (LPWSTR)words, dm))
|
2009-01-13 13:18:28 +01:00
|
|
|
{
|
|
|
|
FIXME("Number of returned words is not %d\n", num);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2009-01-20 13:06:46 +01:00
|
|
|
if (num != DeviceCapabilitiesW(devname, portname, DC_PAPERSIZE, (LPWSTR)points, dm))
|
2009-01-13 13:18:28 +01:00
|
|
|
{
|
2009-01-20 13:06:46 +01:00
|
|
|
FIXME("Number of returned sizes is not %d\n", num);
|
2009-01-13 13:18:28 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
paperword = pagesetup_get_papersize(data);
|
2009-01-19 17:38:43 +01:00
|
|
|
|
2009-01-13 13:18:28 +01:00
|
|
|
for (i = 0; i < num; i++)
|
2009-01-19 17:38:43 +01:00
|
|
|
if (words[i] == paperword)
|
2009-01-13 13:18:28 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == num)
|
|
|
|
{
|
2009-01-19 17:38:43 +01:00
|
|
|
FIXME("Papersize %d not found in list?\n", paperword);
|
2009-01-13 13:18:28 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is _10ths_ of a millimeter */
|
2009-01-22 16:33:09 +01:00
|
|
|
pagesetup_get_papersize_pt(data)->x = tenths_mm_to_size(data, points[i].x);
|
|
|
|
pagesetup_get_papersize_pt(data)->y = tenths_mm_to_size(data, points[i].y);
|
2009-01-19 16:33:05 +01:00
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
if(pagesetup_get_orientation(data) == DMORIENT_LANDSCAPE)
|
2009-01-22 16:33:09 +01:00
|
|
|
swap_point(pagesetup_get_papersize_pt(data));
|
|
|
|
|
2009-01-13 13:18:28 +01:00
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
end:
|
|
|
|
HeapFree(GetProcessHeap(), 0, words);
|
|
|
|
HeapFree(GetProcessHeap(), 0, points);
|
2009-01-22 17:49:52 +01:00
|
|
|
pagesetup_release_a_devname(data, portname);
|
|
|
|
pagesetup_release_a_devname(data, devname);
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_release_devmode(data, dm);
|
2009-01-20 13:06:46 +01:00
|
|
|
|
2009-01-13 13:18:28 +01:00
|
|
|
return retval;
|
|
|
|
}
|
2004-09-22 21:11:05 +02:00
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
/**********************************************************************************************
|
2009-01-21 11:41:36 +01:00
|
|
|
* pagesetup_change_printer
|
2005-07-07 20:23:45 +02:00
|
|
|
*
|
|
|
|
* Redefines hDevMode and hDevNames HANDLES and initialises it.
|
|
|
|
*
|
|
|
|
*/
|
2009-01-22 13:24:07 +01:00
|
|
|
static BOOL pagesetup_change_printer(LPWSTR name, pagesetup_data *data)
|
2009-01-21 11:41:36 +01:00
|
|
|
{
|
|
|
|
HANDLE hprn;
|
|
|
|
DWORD needed;
|
|
|
|
PRINTER_INFO_2W *prn_info = NULL;
|
|
|
|
DRIVER_INFO_3W *drv_info = NULL;
|
|
|
|
DEVMODEW *dm = NULL;
|
|
|
|
BOOL retval = FALSE;
|
|
|
|
|
|
|
|
if(!OpenPrinterW(name, &hprn, NULL))
|
|
|
|
{
|
|
|
|
ERR("Can't open printer %s\n", debugstr_w(name));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetPrinterW(hprn, 2, NULL, 0, &needed);
|
|
|
|
prn_info = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
GetPrinterW(hprn, 2, (LPBYTE)prn_info, needed, &needed);
|
|
|
|
GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
|
|
|
|
drv_info = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
if(!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)drv_info, needed, &needed))
|
|
|
|
{
|
|
|
|
ERR("GetPrinterDriverA failed for %s, fix your config!\n", debugstr_w(prn_info->pPrinterName));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
ClosePrinter(hprn);
|
|
|
|
|
|
|
|
needed = DocumentPropertiesW(0, 0, name, NULL, NULL, 0);
|
|
|
|
if(needed == -1)
|
|
|
|
{
|
|
|
|
ERR("DocumentProperties fails on %s\n", debugstr_w(name));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
dm = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
DocumentPropertiesW(0, 0, name, dm, NULL, DM_OUT_BUFFER);
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_set_devmode(data, dm);
|
|
|
|
pagesetup_set_devnames(data, drv_info->pDriverPath, prn_info->pPrinterName,
|
2009-01-21 11:41:36 +01:00
|
|
|
prn_info->pPortName);
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
end:
|
|
|
|
HeapFree(GetProcessHeap(), 0, dm);
|
|
|
|
HeapFree(GetProcessHeap(), 0, prn_info);
|
|
|
|
HeapFree(GetProcessHeap(), 0, drv_info);
|
|
|
|
return retval;
|
2005-07-07 20:23:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************************
|
2009-01-20 11:35:02 +01:00
|
|
|
* pagesetup_init_combos
|
2005-07-07 20:23:45 +02:00
|
|
|
*
|
2009-01-20 11:35:02 +01:00
|
|
|
* Fills Printers, Paper and Source combos
|
2005-07-07 20:23:45 +02:00
|
|
|
*
|
2001-05-05 02:44:03 +02:00
|
|
|
*/
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_init_combos(HWND hDlg, pagesetup_data *data)
|
2009-01-20 11:35:02 +01:00
|
|
|
{
|
2009-01-21 11:30:26 +01:00
|
|
|
DEVMODEW *dm;
|
|
|
|
LPWSTR devname, portname;
|
2009-01-20 11:35:02 +01:00
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
dm = pagesetup_get_devmode(data);
|
|
|
|
devname = pagesetup_get_devname(data);
|
|
|
|
portname = pagesetup_get_portname(data);
|
2009-01-21 11:30:26 +01:00
|
|
|
|
|
|
|
PRINTDLG_SetUpPrinterListComboW(hDlg, cmb1, devname);
|
|
|
|
PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb2, devname, portname, dm);
|
|
|
|
PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb3, devname, portname, dm);
|
|
|
|
|
2009-01-22 17:49:52 +01:00
|
|
|
pagesetup_release_a_devname(data, portname);
|
|
|
|
pagesetup_release_a_devname(data, devname);
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_release_devmode(data, dm);
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
|
2009-01-21 11:45:19 +01:00
|
|
|
|
|
|
|
/****************************************************************************************
|
|
|
|
* pagesetup_change_printer_dialog
|
|
|
|
*
|
|
|
|
* Pops up another dialog that lets the user pick another printer.
|
|
|
|
*
|
|
|
|
* For now we display the PrintDlg, this should display a striped down version of it.
|
|
|
|
*/
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_change_printer_dialog(HWND hDlg, pagesetup_data *data)
|
2009-01-21 11:45:19 +01:00
|
|
|
{
|
|
|
|
PRINTDLGW prnt;
|
|
|
|
LPWSTR drvname, devname, portname;
|
|
|
|
DEVMODEW *tmp_dm, *dm;
|
|
|
|
|
|
|
|
memset(&prnt, 0, sizeof(prnt));
|
|
|
|
prnt.lStructSize = sizeof(prnt);
|
|
|
|
prnt.Flags = 0;
|
|
|
|
prnt.hwndOwner = hDlg;
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
drvname = pagesetup_get_drvname(data);
|
|
|
|
devname = pagesetup_get_devname(data);
|
|
|
|
portname = pagesetup_get_portname(data);
|
2009-01-21 11:45:19 +01:00
|
|
|
prnt.hDevNames = 0;
|
|
|
|
PRINTDLG_CreateDevNamesW(&prnt.hDevNames, drvname, devname, portname);
|
2009-01-22 17:49:52 +01:00
|
|
|
pagesetup_release_a_devname(data, portname);
|
|
|
|
pagesetup_release_a_devname(data, devname);
|
|
|
|
pagesetup_release_a_devname(data, drvname);
|
2009-01-21 11:45:19 +01:00
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
tmp_dm = pagesetup_get_devmode(data);
|
2009-01-21 11:45:19 +01:00
|
|
|
prnt.hDevMode = GlobalAlloc(GMEM_MOVEABLE, tmp_dm->dmSize + tmp_dm->dmDriverExtra);
|
|
|
|
dm = GlobalLock(prnt.hDevMode);
|
|
|
|
memcpy(dm, tmp_dm, tmp_dm->dmSize + tmp_dm->dmDriverExtra);
|
|
|
|
GlobalUnlock(prnt.hDevMode);
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_release_devmode(data, tmp_dm);
|
2009-01-21 11:45:19 +01:00
|
|
|
|
|
|
|
if (PrintDlgW(&prnt))
|
|
|
|
{
|
|
|
|
DEVMODEW *dm = GlobalLock(prnt.hDevMode);
|
|
|
|
DEVNAMES *dn = GlobalLock(prnt.hDevNames);
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_set_devnames(data, (WCHAR*)dn + dn->wDriverOffset,
|
2009-01-21 11:45:19 +01:00
|
|
|
(WCHAR*)dn + dn->wDeviceOffset, (WCHAR *)dn + dn->wOutputOffset);
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_set_devmode(data, dm);
|
2009-01-21 11:45:19 +01:00
|
|
|
GlobalUnlock(prnt.hDevNames);
|
|
|
|
GlobalUnlock(prnt.hDevMode);
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_init_combos(hDlg, data);
|
2009-01-21 11:45:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GlobalFree(prnt.hDevMode);
|
|
|
|
GlobalFree(prnt.hDevNames);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
/******************************************************************************************
|
2009-01-21 19:18:26 +01:00
|
|
|
* pagesetup_change_preview
|
2005-07-07 20:23:45 +02:00
|
|
|
*
|
2009-01-21 19:18:26 +01:00
|
|
|
* Changes paper preview size / position
|
2005-07-07 20:23:45 +02:00
|
|
|
*
|
|
|
|
*/
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_change_preview(const pagesetup_data *data)
|
2005-07-07 20:23:45 +02:00
|
|
|
{
|
|
|
|
LONG width, height, x, y;
|
2009-01-21 19:18:26 +01:00
|
|
|
RECT tmp;
|
|
|
|
const int shadow = 4;
|
|
|
|
|
|
|
|
if(pagesetup_get_orientation(data) == DMORIENT_LANDSCAPE)
|
|
|
|
{
|
|
|
|
width = data->rtDrawRect.right - data->rtDrawRect.left;
|
2009-01-22 16:33:09 +01:00
|
|
|
height = pagesetup_get_papersize_pt(data)->y * width / pagesetup_get_papersize_pt(data)->x;
|
2009-01-21 19:18:26 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
height = data->rtDrawRect.bottom - data->rtDrawRect.top;
|
2009-01-22 16:33:09 +01:00
|
|
|
width = pagesetup_get_papersize_pt(data)->x * height / pagesetup_get_papersize_pt(data)->y;
|
2009-01-21 19:18:26 +01:00
|
|
|
}
|
|
|
|
x = (data->rtDrawRect.right + data->rtDrawRect.left - width) / 2;
|
|
|
|
y = (data->rtDrawRect.bottom + data->rtDrawRect.top - height) / 2;
|
|
|
|
TRACE("draw rect %s x=%d, y=%d, w=%d, h=%d\n",
|
|
|
|
wine_dbgstr_rect(&data->rtDrawRect), x, y, width, height);
|
|
|
|
|
|
|
|
MoveWindow(GetDlgItem(data->hDlg, rct2), x + width, y + shadow, shadow, height, FALSE);
|
|
|
|
MoveWindow(GetDlgItem(data->hDlg, rct3), x + shadow, y + height, width, shadow, FALSE);
|
|
|
|
MoveWindow(GetDlgItem(data->hDlg, rct1), x, y, width, height, FALSE);
|
|
|
|
|
|
|
|
tmp = data->rtDrawRect;
|
|
|
|
tmp.right += shadow;
|
|
|
|
tmp.bottom += shadow;
|
|
|
|
InvalidateRect(data->hDlg, &tmp, TRUE);
|
2005-07-07 20:23:45 +02:00
|
|
|
}
|
|
|
|
|
2009-01-19 13:50:51 +01:00
|
|
|
static inline LONG *element_from_margin_id(RECT *rc, WORD id)
|
|
|
|
{
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case edt4: return &rc->left;
|
|
|
|
case edt5: return &rc->top;
|
|
|
|
case edt6: return &rc->right;
|
|
|
|
case edt7: return &rc->bottom;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void update_margin_edits(HWND hDlg, const pagesetup_data *data, WORD id)
|
2009-01-16 13:08:12 +01:00
|
|
|
{
|
|
|
|
WCHAR str[100];
|
2009-01-19 13:50:51 +01:00
|
|
|
WORD idx;
|
2009-01-16 13:08:12 +01:00
|
|
|
|
2009-01-19 13:50:51 +01:00
|
|
|
for(idx = edt4; idx <= edt7; idx++)
|
|
|
|
{
|
|
|
|
if(id == 0 || id == idx)
|
|
|
|
{
|
2009-01-22 16:47:07 +01:00
|
|
|
size2str(data, *element_from_margin_id(pagesetup_get_margin_rect(data), idx), str);
|
2009-01-19 13:50:51 +01:00
|
|
|
SetDlgItemTextW(hDlg, idx, str);
|
|
|
|
}
|
|
|
|
}
|
2009-01-16 13:08:12 +01:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void margin_edit_notification(HWND hDlg, pagesetup_data *data, WORD msg, WORD id)
|
2009-01-19 15:11:20 +01:00
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EN_CHANGE:
|
|
|
|
{
|
|
|
|
WCHAR buf[10];
|
|
|
|
LONG val = 0;
|
2009-01-22 16:47:07 +01:00
|
|
|
LONG *value = element_from_margin_id(pagesetup_get_margin_rect(data), id);
|
2009-01-19 15:11:20 +01:00
|
|
|
|
|
|
|
if (GetDlgItemTextW(hDlg, id, buf, sizeof(buf) / sizeof(buf[0])) != 0)
|
|
|
|
{
|
|
|
|
WCHAR *end;
|
2009-01-19 15:28:43 +01:00
|
|
|
WCHAR decimal = get_decimal_sep();
|
2009-01-19 15:11:20 +01:00
|
|
|
|
|
|
|
val = strtolW(buf, &end, 10);
|
|
|
|
if(end != buf || *end == decimal)
|
|
|
|
{
|
2009-01-22 13:24:07 +01:00
|
|
|
int mult = is_metric(data) ? 100 : 1000;
|
2009-01-19 15:11:20 +01:00
|
|
|
val *= mult;
|
|
|
|
if(*end == decimal)
|
|
|
|
{
|
|
|
|
while(mult > 1)
|
|
|
|
{
|
|
|
|
end++;
|
|
|
|
mult /= 10;
|
|
|
|
if(isdigitW(*end))
|
|
|
|
val += (*end - '0') * mult;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*value = val;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case EN_KILLFOCUS:
|
2009-01-22 13:24:07 +01:00
|
|
|
update_margin_edits(hDlg, data, id);
|
2009-01-19 15:11:20 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void set_margin_groupbox_title(HWND hDlg, const pagesetup_data *data)
|
2009-01-15 15:13:43 +01:00
|
|
|
{
|
|
|
|
WCHAR title[256];
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
if(LoadStringW(COMDLG32_hInstance, is_metric(data) ? PD32_MARGINS_IN_MILLIMETERS : PD32_MARGINS_IN_INCHES,
|
2009-01-15 15:13:43 +01:00
|
|
|
title, sizeof(title)/sizeof(title[0])))
|
|
|
|
SetDlgItemTextW(hDlg, grp4, title);
|
|
|
|
}
|
|
|
|
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_update_orientation_buttons(HWND hDlg, const pagesetup_data *data)
|
2009-01-19 18:12:43 +01:00
|
|
|
{
|
2009-01-22 13:24:07 +01:00
|
|
|
if (pagesetup_get_orientation(data) == DMORIENT_LANDSCAPE)
|
2009-01-19 18:12:43 +01:00
|
|
|
CheckRadioButton(hDlg, rad1, rad2, rad2);
|
|
|
|
else
|
|
|
|
CheckRadioButton(hDlg, rad1, rad2, rad1);
|
|
|
|
}
|
|
|
|
|
2009-01-21 19:10:50 +01:00
|
|
|
/****************************************************************************************
|
|
|
|
* pagesetup_printer_properties
|
|
|
|
*
|
|
|
|
* Handle invocation of the 'Properties' button (not present in the default template).
|
|
|
|
*/
|
2009-01-22 13:24:07 +01:00
|
|
|
static void pagesetup_printer_properties(HWND hDlg, pagesetup_data *data)
|
2009-01-21 19:10:50 +01:00
|
|
|
{
|
|
|
|
HANDLE hprn;
|
|
|
|
LPWSTR devname;
|
|
|
|
DEVMODEW *dm;
|
|
|
|
LRESULT count;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
devname = pagesetup_get_devname(data);
|
|
|
|
|
|
|
|
if (!OpenPrinterW(devname, &hprn, NULL))
|
|
|
|
{
|
|
|
|
FIXME("Call to OpenPrinter did not succeed!\n");
|
2009-01-22 17:49:52 +01:00
|
|
|
pagesetup_release_a_devname(data, devname);
|
2009-01-21 19:10:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dm = pagesetup_get_devmode(data);
|
|
|
|
DocumentPropertiesW(hDlg, hprn, devname, dm, dm, DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
|
|
|
|
pagesetup_set_devmode(data, dm);
|
|
|
|
pagesetup_release_devmode(data, dm);
|
2009-01-22 17:49:52 +01:00
|
|
|
pagesetup_release_a_devname(data, devname);
|
2009-01-21 19:10:50 +01:00
|
|
|
ClosePrinter(hprn);
|
|
|
|
|
|
|
|
/* Changing paper */
|
|
|
|
pagesetup_update_papersize(data);
|
|
|
|
pagesetup_update_orientation_buttons(hDlg, data);
|
|
|
|
|
|
|
|
/* Changing paper preview */
|
2009-01-21 19:18:26 +01:00
|
|
|
pagesetup_change_preview(data);
|
2009-01-21 19:10:50 +01:00
|
|
|
|
|
|
|
/* Selecting paper in combo */
|
|
|
|
count = SendDlgItemMessageW(hDlg, cmb2, CB_GETCOUNT, 0, 0);
|
|
|
|
if(count != CB_ERR)
|
|
|
|
{
|
|
|
|
WORD paperword = pagesetup_get_papersize(data);
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if(SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, i, 0) == paperword) {
|
|
|
|
SendDlgItemMessageW(hDlg, cmb2, CB_SETCURSEL, i, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
/********************************************************************************
|
2009-01-23 15:19:46 +01:00
|
|
|
* pagesetup_wm_command
|
|
|
|
* process WM_COMMAND message for PageSetupDlg
|
2005-07-07 20:23:45 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hDlg [in] Main dialog HANDLE
|
|
|
|
* wParam [in] WM_COMMAND wParam
|
|
|
|
* lParam [in] WM_COMMAND lParam
|
|
|
|
* pda [in/out] ptr to PageSetupDataA
|
|
|
|
*/
|
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
static BOOL pagesetup_wm_command(HWND hDlg, WPARAM wParam, LPARAM lParam, pagesetup_data *data)
|
2009-01-22 13:24:07 +01:00
|
|
|
{
|
2005-07-07 20:23:45 +02:00
|
|
|
WORD msg = HIWORD(wParam);
|
|
|
|
WORD id = LOWORD(wParam);
|
2009-01-19 15:11:20 +01:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("loword (lparam) %d, wparam 0x%lx, lparam %08lx\n",
|
2005-01-24 12:26:23 +01:00
|
|
|
LOWORD(lParam),wParam,lParam);
|
2005-07-07 20:23:45 +02:00
|
|
|
switch (id) {
|
2001-05-05 02:44:03 +02:00
|
|
|
case IDOK:
|
|
|
|
EndDialog(hDlg, TRUE);
|
|
|
|
return TRUE ;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, FALSE);
|
|
|
|
return FALSE ;
|
|
|
|
|
2009-01-21 11:45:19 +01:00
|
|
|
case psh3: /* Printer... */
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_change_printer_dialog(hDlg, data);
|
2009-01-13 13:18:28 +01:00
|
|
|
return TRUE;
|
2009-01-21 11:45:19 +01:00
|
|
|
|
|
|
|
case rad1: /* Portrait */
|
|
|
|
case rad2: /* Landscape */
|
2009-01-22 13:24:07 +01:00
|
|
|
if((id == rad1 && pagesetup_get_orientation(data) == DMORIENT_LANDSCAPE) ||
|
|
|
|
(id == rad2 && pagesetup_get_orientation(data) == DMORIENT_PORTRAIT))
|
2007-12-08 14:16:41 +01:00
|
|
|
{
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_set_orientation(data, (id == rad1) ? DMORIENT_PORTRAIT : DMORIENT_LANDSCAPE);
|
|
|
|
pagesetup_update_papersize(data);
|
2009-01-22 16:47:07 +01:00
|
|
|
rotate_rect(pagesetup_get_margin_rect(data), (id == rad2));
|
2009-01-22 13:24:07 +01:00
|
|
|
update_margin_edits(hDlg, data, 0);
|
|
|
|
pagesetup_change_preview(data);
|
2007-12-08 14:16:41 +01:00
|
|
|
}
|
|
|
|
break;
|
2005-07-07 20:23:45 +02:00
|
|
|
case cmb1: /* Printer combo */
|
2009-01-21 11:41:36 +01:00
|
|
|
if(msg == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
WCHAR name[256];
|
|
|
|
GetDlgItemTextW(hDlg, id, name, sizeof(name) / sizeof(name[0]));
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_change_printer(name, data);
|
|
|
|
pagesetup_init_combos(hDlg, data);
|
2009-01-21 11:41:36 +01:00
|
|
|
}
|
|
|
|
break;
|
2005-07-07 20:23:45 +02:00
|
|
|
case cmb2: /* Paper combo */
|
2009-01-20 13:01:16 +01:00
|
|
|
if(msg == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
DWORD paperword = SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA,
|
|
|
|
SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0), 0);
|
2009-01-14 15:43:00 +01:00
|
|
|
if (paperword != CB_ERR)
|
|
|
|
{
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_set_papersize(data, paperword);
|
|
|
|
pagesetup_update_papersize(data);
|
|
|
|
pagesetup_change_preview(data);
|
2005-07-07 20:23:45 +02:00
|
|
|
} else
|
2009-01-20 13:01:16 +01:00
|
|
|
FIXME("could not get dialog text for papersize cmbbox?\n");
|
|
|
|
}
|
|
|
|
break;
|
2009-01-19 17:57:24 +01:00
|
|
|
case cmb3: /* Paper Source */
|
|
|
|
if(msg == CBN_SELCHANGE)
|
|
|
|
{
|
2009-01-20 13:01:16 +01:00
|
|
|
WORD source = SendDlgItemMessageW(hDlg, cmb3, CB_GETITEMDATA,
|
|
|
|
SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0), 0);
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_set_defaultsource(data, source);
|
2009-01-19 17:57:24 +01:00
|
|
|
}
|
|
|
|
break;
|
2009-01-21 19:10:50 +01:00
|
|
|
case psh2: /* Printer Properties button */
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_printer_properties(hDlg, data);
|
2009-01-21 19:10:50 +01:00
|
|
|
break;
|
2005-07-07 20:23:45 +02:00
|
|
|
case edt4:
|
|
|
|
case edt5:
|
|
|
|
case edt6:
|
|
|
|
case edt7:
|
2009-01-22 13:24:07 +01:00
|
|
|
margin_edit_notification(hDlg, data, msg, id);
|
2009-01-19 15:11:20 +01:00
|
|
|
break;
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
2005-07-07 20:23:45 +02:00
|
|
|
InvalidateRect(GetDlgItem(hDlg, rct1), NULL, TRUE);
|
2002-04-11 19:32:49 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-23 18:45:39 +02:00
|
|
|
/***********************************************************************
|
2009-01-22 18:13:12 +01:00
|
|
|
* default_page_paint_hook
|
2005-06-23 18:45:39 +02:00
|
|
|
* Default hook paint procedure that receives WM_PSD_* messages from the dialog box
|
|
|
|
* whenever the sample page is redrawn.
|
2009-01-22 18:13:12 +01:00
|
|
|
*/
|
|
|
|
static UINT_PTR default_page_paint_hook(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam,
|
|
|
|
const pagesetup_data *data)
|
2005-06-23 18:45:39 +02:00
|
|
|
{
|
|
|
|
LPRECT lprc = (LPRECT) lParam;
|
|
|
|
HDC hdc = (HDC) wParam;
|
|
|
|
HPEN hpen, holdpen;
|
|
|
|
LOGFONTW lf;
|
|
|
|
HFONT hfont, holdfont;
|
|
|
|
INT oldbkmode;
|
|
|
|
TRACE("uMsg: WM_USER+%d\n",uMsg-WM_USER);
|
|
|
|
/* Call user paint hook if enable */
|
2009-01-22 16:16:26 +01:00
|
|
|
if (pagesetup_get_flags(data) & PSD_ENABLEPAGEPAINTHOOK)
|
2009-01-23 00:11:21 +01:00
|
|
|
if (pagesetup_get_hook(data, page_paint_hook)(hwndDlg, uMsg, wParam, lParam))
|
2005-06-23 18:45:39 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
/* LPPAGESETUPDLG in lParam */
|
|
|
|
case WM_PSD_PAGESETUPDLG:
|
|
|
|
/* Inform about the sample page rectangle */
|
|
|
|
case WM_PSD_FULLPAGERECT:
|
|
|
|
/* Inform about the margin rectangle */
|
|
|
|
case WM_PSD_MINMARGINRECT:
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Draw dashed rectangle showing margins */
|
|
|
|
case WM_PSD_MARGINRECT:
|
|
|
|
hpen = CreatePen(PS_DASH, 1, GetSysColor(COLOR_3DSHADOW));
|
|
|
|
holdpen = SelectObject(hdc, hpen);
|
|
|
|
Rectangle(hdc, lprc->left, lprc->top, lprc->right, lprc->bottom);
|
|
|
|
DeleteObject(SelectObject(hdc, holdpen));
|
|
|
|
return TRUE;
|
|
|
|
/* Draw the fake document */
|
|
|
|
case WM_PSD_GREEKTEXTRECT:
|
|
|
|
/* select a nice scalable font, because we want the text really small */
|
|
|
|
SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);
|
|
|
|
lf.lfHeight = 6; /* value chosen based on visual effect */
|
|
|
|
hfont = CreateFontIndirectW(&lf);
|
|
|
|
holdfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
/* if text not loaded, then do so now */
|
|
|
|
if (wszFakeDocumentText[0] == '\0')
|
|
|
|
LoadStringW(COMDLG32_hInstance,
|
|
|
|
IDS_FAKEDOCTEXT,
|
|
|
|
wszFakeDocumentText,
|
|
|
|
sizeof(wszFakeDocumentText)/sizeof(wszFakeDocumentText[0]));
|
|
|
|
|
|
|
|
oldbkmode = SetBkMode(hdc, TRANSPARENT);
|
|
|
|
DrawTextW(hdc, wszFakeDocumentText, -1, lprc, DT_TOP|DT_LEFT|DT_NOPREFIX|DT_WORDBREAK);
|
|
|
|
SetBkMode(hdc, oldbkmode);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, holdfont));
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* Envelope stamp */
|
|
|
|
case WM_PSD_ENVSTAMPRECT:
|
|
|
|
/* Return address */
|
|
|
|
case WM_PSD_YAFULLPAGERECT:
|
|
|
|
FIXME("envelope/stamp is not implemented\n");
|
|
|
|
return FALSE;
|
|
|
|
default:
|
|
|
|
FIXME("Unknown message %x\n",uMsg);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* PagePaintProc
|
|
|
|
* The main paint procedure for the PageSetupDlg function.
|
|
|
|
* The Page Setup dialog box includes an image of a sample page that shows how
|
|
|
|
* the user's selections affect the appearance of the printed output.
|
|
|
|
* The image consists of a rectangle that represents the selected paper
|
|
|
|
* or envelope type, with a dotted-line rectangle representing
|
|
|
|
* the current margins, and partial (Greek text) characters
|
|
|
|
* to show how text looks on the printed page.
|
|
|
|
*
|
|
|
|
* The following messages in the order sends to user hook procedure:
|
|
|
|
* WM_PSD_PAGESETUPDLG Draw the contents of the sample page
|
|
|
|
* WM_PSD_FULLPAGERECT Inform about the bounding rectangle
|
|
|
|
* WM_PSD_MINMARGINRECT Inform about the margin rectangle (min margin?)
|
|
|
|
* WM_PSD_MARGINRECT Draw the margin rectangle
|
|
|
|
* WM_PSD_GREEKTEXTRECT Draw the Greek text inside the margin rectangle
|
|
|
|
* If any of first three messages returns TRUE, painting done.
|
|
|
|
*
|
|
|
|
* PARAMS:
|
|
|
|
* hWnd [in] Handle to the Page Setup dialog box
|
|
|
|
* uMsg [in] Received message
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* WM_PSD_ENVSTAMPRECT Draw in the envelope-stamp rectangle (for envelopes only)
|
|
|
|
* WM_PSD_YAFULLPAGERECT Draw the return address portion (for envelopes and other paper sizes)
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* FALSE if all done correctly
|
|
|
|
*
|
|
|
|
*/
|
2005-07-07 20:23:45 +02:00
|
|
|
|
|
|
|
|
2005-01-24 12:26:23 +01:00
|
|
|
static LRESULT CALLBACK
|
2005-06-23 18:45:39 +02:00
|
|
|
PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2005-01-24 12:26:23 +01:00
|
|
|
{
|
2005-06-23 18:45:39 +02:00
|
|
|
PAINTSTRUCT ps;
|
|
|
|
RECT rcClient, rcMargin;
|
|
|
|
HPEN hpen, holdpen;
|
|
|
|
HDC hdc;
|
|
|
|
HBRUSH hbrush, holdbrush;
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_data *data;
|
2005-08-25 21:23:43 +02:00
|
|
|
int papersize=0, orientation=0; /* FIXME: set this values for user paint hook */
|
2005-07-07 20:23:45 +02:00
|
|
|
double scalx, scaly;
|
2005-06-23 18:45:39 +02:00
|
|
|
|
|
|
|
if (uMsg != WM_PAINT)
|
|
|
|
return CallWindowProcA(lpfnStaticWndProc, hWnd, uMsg, wParam, lParam);
|
|
|
|
|
|
|
|
/* Processing WM_PAINT message */
|
2009-01-22 13:24:07 +01:00
|
|
|
data = GetPropW(hWnd, pagesetupdlg_prop);
|
|
|
|
if (!data) {
|
2005-06-23 18:45:39 +02:00
|
|
|
WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-01-23 12:12:17 +01:00
|
|
|
if (default_page_paint_hook(hWnd, WM_PSD_PAGESETUPDLG, MAKELONG(papersize, orientation),
|
|
|
|
pagesetup_get_dlg_struct(data), data))
|
2005-06-23 18:45:39 +02:00
|
|
|
return FALSE;
|
2005-01-24 12:26:23 +01:00
|
|
|
|
2005-06-23 18:45:39 +02:00
|
|
|
hdc = BeginPaint(hWnd, &ps);
|
|
|
|
GetClientRect(hWnd, &rcClient);
|
2005-07-07 20:23:45 +02:00
|
|
|
|
2009-01-22 16:33:09 +01:00
|
|
|
scalx = rcClient.right / (double)pagesetup_get_papersize_pt(data)->x;
|
|
|
|
scaly = rcClient.bottom / (double)pagesetup_get_papersize_pt(data)->y;
|
2005-06-23 18:45:39 +02:00
|
|
|
rcMargin = rcClient;
|
2007-12-03 23:40:42 +01:00
|
|
|
|
2009-01-22 16:47:07 +01:00
|
|
|
rcMargin.left += pagesetup_get_margin_rect(data)->left * scalx;
|
2009-01-22 16:48:01 +01:00
|
|
|
rcMargin.top += pagesetup_get_margin_rect(data)->top * scaly;
|
|
|
|
rcMargin.right -= pagesetup_get_margin_rect(data)->right * scalx;
|
2009-01-22 16:47:07 +01:00
|
|
|
rcMargin.bottom -= pagesetup_get_margin_rect(data)->bottom * scaly;
|
2007-12-03 23:40:42 +01:00
|
|
|
|
2005-06-23 18:45:39 +02:00
|
|
|
/* if the space is too small then we make sure to not draw anything */
|
|
|
|
rcMargin.left = min(rcMargin.left, rcMargin.right);
|
|
|
|
rcMargin.top = min(rcMargin.top, rcMargin.bottom);
|
|
|
|
|
2009-01-22 18:13:12 +01:00
|
|
|
if (!default_page_paint_hook(hWnd, WM_PSD_FULLPAGERECT, (WPARAM)hdc, (LPARAM)&rcClient, data) &&
|
|
|
|
!default_page_paint_hook(hWnd, WM_PSD_MINMARGINRECT, (WPARAM)hdc, (LPARAM)&rcMargin, data) )
|
2005-06-23 18:45:39 +02:00
|
|
|
{
|
2005-01-24 12:26:23 +01:00
|
|
|
/* fill background */
|
|
|
|
hbrush = GetSysColorBrush(COLOR_3DHIGHLIGHT);
|
|
|
|
FillRect(hdc, &rcClient, hbrush);
|
|
|
|
holdbrush = SelectObject(hdc, hbrush);
|
|
|
|
|
|
|
|
hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
|
|
|
|
holdpen = SelectObject(hdc, hpen);
|
2005-06-23 18:45:39 +02:00
|
|
|
|
2005-01-24 12:26:23 +01:00
|
|
|
/* paint left edge */
|
|
|
|
MoveToEx(hdc, rcClient.left, rcClient.top, NULL);
|
|
|
|
LineTo(hdc, rcClient.left, rcClient.bottom-1);
|
|
|
|
|
|
|
|
/* paint top edge */
|
|
|
|
MoveToEx(hdc, rcClient.left, rcClient.top, NULL);
|
|
|
|
LineTo(hdc, rcClient.right, rcClient.top);
|
|
|
|
|
|
|
|
hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW));
|
|
|
|
DeleteObject(SelectObject(hdc, hpen));
|
|
|
|
|
|
|
|
/* paint right edge */
|
|
|
|
MoveToEx(hdc, rcClient.right-1, rcClient.top, NULL);
|
|
|
|
LineTo(hdc, rcClient.right-1, rcClient.bottom);
|
|
|
|
|
|
|
|
/* paint bottom edge */
|
|
|
|
MoveToEx(hdc, rcClient.left, rcClient.bottom-1, NULL);
|
|
|
|
LineTo(hdc, rcClient.right, rcClient.bottom-1);
|
|
|
|
|
2005-06-23 18:45:39 +02:00
|
|
|
DeleteObject(SelectObject(hdc, holdpen));
|
|
|
|
DeleteObject(SelectObject(hdc, holdbrush));
|
2005-01-24 12:26:23 +01:00
|
|
|
|
2009-01-22 18:13:12 +01:00
|
|
|
default_page_paint_hook(hWnd, WM_PSD_MARGINRECT, (WPARAM)hdc, (LPARAM)&rcMargin, data);
|
2005-01-24 12:26:23 +01:00
|
|
|
|
|
|
|
/* give text a bit of a space from the frame */
|
2005-06-23 18:45:39 +02:00
|
|
|
rcMargin.left += 2;
|
|
|
|
rcMargin.top += 2;
|
|
|
|
rcMargin.right -= 2;
|
|
|
|
rcMargin.bottom -= 2;
|
|
|
|
|
2005-01-24 12:26:23 +01:00
|
|
|
/* if the space is too small then we make sure to not draw anything */
|
2005-06-23 18:45:39 +02:00
|
|
|
rcMargin.left = min(rcMargin.left, rcMargin.right);
|
|
|
|
rcMargin.top = min(rcMargin.top, rcMargin.bottom);
|
2005-01-24 12:26:23 +01:00
|
|
|
|
2009-01-22 18:13:12 +01:00
|
|
|
default_page_paint_hook(hWnd, WM_PSD_GREEKTEXTRECT, (WPARAM)hdc, (LPARAM)&rcMargin, data);
|
2005-01-24 12:26:23 +01:00
|
|
|
}
|
2005-06-23 18:45:39 +02:00
|
|
|
|
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
return FALSE;
|
2005-01-24 12:26:23 +01:00
|
|
|
}
|
|
|
|
|
2009-01-16 14:51:18 +01:00
|
|
|
/*******************************************************
|
|
|
|
* The margin edit controls are subclassed to filter
|
|
|
|
* anything other than numbers and the decimal separator.
|
|
|
|
*/
|
|
|
|
static LRESULT CALLBACK pagesetup_margin_editproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
2009-03-03 22:14:04 +01:00
|
|
|
if (msg == WM_CHAR)
|
2009-01-16 14:51:18 +01:00
|
|
|
{
|
2009-01-19 15:28:43 +01:00
|
|
|
WCHAR decimal = get_decimal_sep();
|
2009-01-16 14:51:18 +01:00
|
|
|
WCHAR wc = (WCHAR)wparam;
|
|
|
|
if(!isdigitW(wc) && wc != decimal && wc != VK_BACK) return 0;
|
|
|
|
}
|
|
|
|
return CallWindowProcW(edit_wndproc, hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subclass_margin_edits(HWND hDlg)
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
WNDPROC old_proc;
|
|
|
|
|
|
|
|
for(id = edt4; id <= edt7; id++)
|
|
|
|
{
|
|
|
|
old_proc = (WNDPROC)SetWindowLongPtrW(GetDlgItem(hDlg, id),
|
|
|
|
GWLP_WNDPROC,
|
|
|
|
(ULONG_PTR)pagesetup_margin_editproc);
|
|
|
|
InterlockedCompareExchangePointer((void**)&edit_wndproc, old_proc, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-23 18:45:39 +02:00
|
|
|
/***********************************************************************
|
2009-01-23 15:19:46 +01:00
|
|
|
* pagesetup_dlg_proc
|
|
|
|
*
|
|
|
|
* Message handler for PageSetupDlg
|
2005-06-23 18:45:39 +02:00
|
|
|
*/
|
2009-01-23 15:19:46 +01:00
|
|
|
static INT_PTR CALLBACK pagesetup_dlg_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2001-05-05 02:44:03 +02:00
|
|
|
{
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_data *data;
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR res = FALSE;
|
2005-07-07 20:23:45 +02:00
|
|
|
HWND hDrawWnd;
|
2001-05-05 02:44:03 +02:00
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
if (uMsg == WM_INITDIALOG) { /*Init dialog*/
|
2009-01-22 13:24:07 +01:00
|
|
|
data = (pagesetup_data *)lParam;
|
|
|
|
data->hDlg = hDlg;
|
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
hDrawWnd = GetDlgItem(hDlg, rct1);
|
2009-01-22 13:24:07 +01:00
|
|
|
TRACE("set property to %p\n", data);
|
|
|
|
SetPropW(hDlg, pagesetupdlg_prop, data);
|
|
|
|
SetPropW(hDrawWnd, pagesetupdlg_prop, data);
|
|
|
|
GetWindowRect(hDrawWnd, &data->rtDrawRect); /* Calculating rect in client coordinates where paper draws */
|
|
|
|
ScreenToClient(hDlg, (LPPOINT)&data->rtDrawRect);
|
|
|
|
ScreenToClient(hDlg, (LPPOINT)(&data->rtDrawRect.right));
|
2005-01-24 12:26:23 +01:00
|
|
|
lpfnStaticWndProc = (WNDPROC)SetWindowLongPtrW(
|
2005-07-07 20:23:45 +02:00
|
|
|
hDrawWnd,
|
2005-01-24 12:26:23 +01:00
|
|
|
GWLP_WNDPROC,
|
2005-06-23 18:45:39 +02:00
|
|
|
(ULONG_PTR)PRINTDLG_PagePaintProc);
|
2005-07-07 20:23:45 +02:00
|
|
|
|
2008-02-13 22:11:01 +01:00
|
|
|
/* FIXME: Paint hook. Must it be at begin of initialization or at end? */
|
2001-05-05 02:44:03 +02:00
|
|
|
res = TRUE;
|
2009-01-22 16:16:26 +01:00
|
|
|
if (pagesetup_get_flags(data) & PSD_ENABLEPAGESETUPHOOK)
|
2009-01-22 13:24:07 +01:00
|
|
|
{
|
2009-01-23 12:12:17 +01:00
|
|
|
if (!pagesetup_get_hook(data, page_setup_hook)(hDlg, uMsg, wParam,
|
|
|
|
pagesetup_get_dlg_struct(data)))
|
2001-05-05 02:44:03 +02:00
|
|
|
FIXME("Setup page hook failed?\n");
|
|
|
|
}
|
2005-06-23 18:45:39 +02:00
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
/* if printer button disabled */
|
2009-01-22 16:16:26 +01:00
|
|
|
if (pagesetup_get_flags(data) & PSD_DISABLEPRINTER)
|
2002-06-01 01:06:46 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, psh3), FALSE);
|
2005-07-07 20:23:45 +02:00
|
|
|
/* if margin edit boxes disabled */
|
2009-01-22 16:16:26 +01:00
|
|
|
if (pagesetup_get_flags(data) & PSD_DISABLEMARGINS)
|
2009-01-22 13:24:07 +01:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg, edt4), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, edt5), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, edt6), FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg, edt7), FALSE);
|
2001-05-05 02:44:03 +02:00
|
|
|
}
|
2009-01-19 16:52:09 +01:00
|
|
|
|
2009-01-19 18:12:43 +01:00
|
|
|
/* Set orientation radiobuttons properly */
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_update_orientation_buttons(hDlg, data);
|
2005-08-25 21:23:43 +02:00
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
/* if orientation disabled */
|
2009-01-22 16:16:26 +01:00
|
|
|
if (pagesetup_get_flags(data) & PSD_DISABLEORIENTATION)
|
2009-01-22 13:24:07 +01:00
|
|
|
{
|
2001-05-05 02:44:03 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg,rad1),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,rad2),FALSE);
|
|
|
|
}
|
2009-01-15 11:45:25 +01:00
|
|
|
|
2001-05-05 02:44:03 +02:00
|
|
|
/* We fill them out enabled or not */
|
2009-01-22 16:16:26 +01:00
|
|
|
if (!(pagesetup_get_flags(data) & PSD_MARGINS))
|
2009-01-15 11:45:25 +01:00
|
|
|
{
|
2009-01-21 19:13:51 +01:00
|
|
|
/* default is 1 inch */
|
2009-01-22 13:24:07 +01:00
|
|
|
LONG size = thousandths_inch_to_size(data, 1000);
|
2009-01-22 16:47:07 +01:00
|
|
|
SetRect(pagesetup_get_margin_rect(data), size, size, size, size);
|
2009-01-15 11:45:25 +01:00
|
|
|
}
|
2009-01-22 13:24:07 +01:00
|
|
|
update_margin_edits(hDlg, data, 0);
|
2009-01-16 14:51:18 +01:00
|
|
|
subclass_margin_edits(hDlg);
|
2009-01-22 13:24:07 +01:00
|
|
|
set_margin_groupbox_title(hDlg, data);
|
2009-01-15 11:45:25 +01:00
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
/* if paper disabled */
|
2009-01-22 16:16:26 +01:00
|
|
|
if (pagesetup_get_flags(data) & PSD_DISABLEPAPER)
|
2009-01-22 13:24:07 +01:00
|
|
|
{
|
2002-04-11 19:32:49 +02:00
|
|
|
EnableWindow(GetDlgItem(hDlg,cmb2),FALSE);
|
|
|
|
EnableWindow(GetDlgItem(hDlg,cmb3),FALSE);
|
|
|
|
}
|
2009-01-19 17:57:24 +01:00
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
/* filling combos: printer, paper, source. selecting current printer (from DEVMODEA) */
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_init_combos(hDlg, data);
|
|
|
|
pagesetup_update_papersize(data);
|
|
|
|
pagesetup_set_defaultsource(data, DMBIN_FORMSOURCE); /* FIXME: This is the auto select bin. Is this correct? */
|
2009-01-19 17:57:24 +01:00
|
|
|
|
2005-07-07 20:23:45 +02:00
|
|
|
/* Drawing paper prev */
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_change_preview(data);
|
2002-04-11 19:32:49 +02:00
|
|
|
return TRUE;
|
|
|
|
} else {
|
2009-01-22 13:24:07 +01:00
|
|
|
data = GetPropW(hDlg, pagesetupdlg_prop);
|
|
|
|
if (!data)
|
|
|
|
{
|
2002-04-11 19:32:49 +02:00
|
|
|
WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-01-22 16:16:26 +01:00
|
|
|
if (pagesetup_get_flags(data) & PSD_ENABLEPAGESETUPHOOK)
|
2009-01-22 13:24:07 +01:00
|
|
|
{
|
2009-01-23 00:11:21 +01:00
|
|
|
res = pagesetup_get_hook(data, page_setup_hook)(hDlg, uMsg, wParam, lParam);
|
2002-04-11 19:32:49 +02:00
|
|
|
if (res) return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_COMMAND:
|
2009-01-23 15:19:46 +01:00
|
|
|
return pagesetup_wm_command(hDlg, wParam, lParam, data);
|
2002-04-11 19:32:49 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
static WCHAR *get_default_printer(void)
|
|
|
|
{
|
|
|
|
WCHAR *name = NULL;
|
|
|
|
DWORD len = 0;
|
2001-05-05 02:44:03 +02:00
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
GetDefaultPrinterW(NULL, &len);
|
|
|
|
if(len)
|
|
|
|
{
|
|
|
|
name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
GetDefaultPrinterW(name, &len);
|
2007-10-22 18:18:41 +02:00
|
|
|
}
|
2009-01-23 15:19:46 +01:00
|
|
|
return name;
|
|
|
|
}
|
2007-10-22 18:18:41 +02:00
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
static void pagesetup_dump_dlg_struct(pagesetup_data *data)
|
|
|
|
{
|
|
|
|
if(TRACE_ON(commdlg))
|
|
|
|
{
|
2001-05-05 02:44:03 +02:00
|
|
|
char flagstr[1000] = "";
|
2006-11-29 11:04:52 +01:00
|
|
|
const struct pd_flags *pflag = psd_flags;
|
2009-01-23 15:19:46 +01:00
|
|
|
for( ; pflag->name; pflag++)
|
|
|
|
{
|
|
|
|
if(pagesetup_get_flags(data) & pflag->flag)
|
|
|
|
{
|
|
|
|
strcat(flagstr, pflag->name);
|
|
|
|
strcat(flagstr, "|");
|
|
|
|
}
|
|
|
|
}
|
2009-01-23 16:26:29 +01:00
|
|
|
TRACE("%s: (%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
|
2006-10-13 15:04:43 +02:00
|
|
|
"hinst %p, flags %08x (%s)\n",
|
2009-01-23 16:26:29 +01:00
|
|
|
data->unicode ? "unicode" : "ansi",
|
|
|
|
data->u.dlgw, data->u.dlgw->hwndOwner, data->u.dlgw->hDevMode,
|
|
|
|
data->u.dlgw->hDevNames, data->u.dlgw->hInstance,
|
2009-01-23 15:19:46 +01:00
|
|
|
pagesetup_get_flags(data), flagstr);
|
2001-05-05 02:44:03 +02:00
|
|
|
}
|
2009-01-23 15:19:46 +01:00
|
|
|
}
|
2007-10-22 18:18:41 +02:00
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
static void *pagesetup_get_template(pagesetup_data *data)
|
|
|
|
{
|
|
|
|
HRSRC res;
|
|
|
|
HGLOBAL tmpl_handle;
|
|
|
|
|
|
|
|
if(pagesetup_get_flags(data) & PSD_ENABLEPAGESETUPTEMPLATEHANDLE)
|
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
tmpl_handle = data->u.dlgw->hPageSetupTemplate;
|
2005-07-07 20:23:45 +02:00
|
|
|
}
|
2009-01-23 15:19:46 +01:00
|
|
|
else if(pagesetup_get_flags(data) & PSD_ENABLEPAGESETUPTEMPLATE)
|
|
|
|
{
|
2009-01-23 16:26:29 +01:00
|
|
|
if(data->unicode)
|
|
|
|
res = FindResourceW(data->u.dlgw->hInstance,
|
|
|
|
data->u.dlgw->lpPageSetupTemplateName, MAKEINTRESOURCEW(RT_DIALOG));
|
|
|
|
else
|
|
|
|
res = FindResourceA(data->u.dlga->hInstance,
|
|
|
|
data->u.dlga->lpPageSetupTemplateName, MAKEINTRESOURCEA(RT_DIALOG));
|
|
|
|
tmpl_handle = LoadResource(data->u.dlgw->hInstance, res);
|
2009-01-23 15:19:46 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
res = FindResourceW(COMDLG32_hInstance, MAKEINTRESOURCEW(PAGESETUPDLGORD),
|
|
|
|
MAKEINTRESOURCEW(RT_DIALOG));
|
|
|
|
tmpl_handle = LoadResource(COMDLG32_hInstance, res);
|
|
|
|
}
|
|
|
|
return LockResource(tmpl_handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL pagesetup_common(pagesetup_data *data)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
void *tmpl;
|
2001-05-05 02:44:03 +02:00
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
if(!pagesetup_get_dlg_struct(data))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_INITIALIZATION);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pagesetup_dump_dlg_struct(data);
|
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
if(data->u.dlgw->lStructSize != sizeof(PAGESETUPDLGW))
|
2009-01-23 15:19:46 +01:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pagesetup_get_flags(data) & PSD_ENABLEPAGEPAINTHOOK) &&
|
|
|
|
(pagesetup_get_hook(data, page_paint_hook) == NULL))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(pagesetup_get_flags(data) & (PSD_INTHOUSANDTHSOFINCHES | PSD_INHUNDREDTHSOFMILLIMETERS)))
|
2009-01-23 16:26:29 +01:00
|
|
|
data->u.dlgw->Flags |= is_default_metric() ?
|
2009-01-15 11:45:21 +01:00
|
|
|
PSD_INHUNDREDTHSOFMILLIMETERS : PSD_INTHOUSANDTHSOFINCHES;
|
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
if (!data->u.dlgw->hDevMode || !data->u.dlgw->hDevNames)
|
2009-01-13 13:18:28 +01:00
|
|
|
{
|
2009-01-23 15:19:46 +01:00
|
|
|
WCHAR *def = get_default_printer();
|
|
|
|
if(!def)
|
2009-01-13 13:18:28 +01:00
|
|
|
{
|
2009-01-23 15:19:46 +01:00
|
|
|
if (!(pagesetup_get_flags(data) & PSD_NOWARNING))
|
|
|
|
{
|
2008-03-03 20:07:37 +01:00
|
|
|
WCHAR errstr[256];
|
|
|
|
LoadStringW(COMDLG32_hInstance, PD32_NO_DEFAULT_PRINTER, errstr, 255);
|
2009-01-23 16:26:29 +01:00
|
|
|
MessageBoxW(data->u.dlgw->hwndOwner, errstr, 0, MB_OK | MB_ICONERROR);
|
2006-01-11 12:10:33 +01:00
|
|
|
}
|
2009-01-26 13:15:22 +01:00
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
|
2006-01-11 12:10:33 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-01-23 15:19:46 +01:00
|
|
|
pagesetup_change_printer(def, data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, def);
|
2005-07-07 20:23:45 +02:00
|
|
|
}
|
2006-01-11 12:10:33 +01:00
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
if (pagesetup_get_flags(data) & PSD_RETURNDEFAULT)
|
|
|
|
{
|
2009-01-22 13:24:07 +01:00
|
|
|
pagesetup_update_papersize(data);
|
2007-08-09 19:10:02 +02:00
|
|
|
return TRUE;
|
2001-05-05 02:44:03 +02:00
|
|
|
}
|
2005-07-07 20:23:45 +02:00
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
tmpl = pagesetup_get_template(data);
|
2008-02-13 12:09:02 +01:00
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
ret = DialogBoxIndirectParamW(data->u.dlgw->hInstance, tmpl,
|
|
|
|
data->u.dlgw->hwndOwner,
|
2009-01-23 15:19:46 +01:00
|
|
|
pagesetup_dlg_proc, (LPARAM)data) > 0;
|
|
|
|
return ret;
|
|
|
|
}
|
2005-07-07 20:23:45 +02:00
|
|
|
|
2009-01-23 15:19:46 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* PageSetupDlgA (COMDLG32.@)
|
|
|
|
*
|
|
|
|
* Displays the PAGE SETUP dialog box, which enables the user to specify
|
|
|
|
* specific properties of a printed page such as
|
|
|
|
* size, source, orientation and the width of the page margins.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* setupdlg [IO] PAGESETUPDLGA struct
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if the user pressed the OK button
|
|
|
|
* FALSE if the user cancelled the window or an error occurred
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The values of hDevMode and hDevNames are filled on output and can be
|
|
|
|
* changed in PAGESETUPDLG when they are passed in PageSetupDlg.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg)
|
|
|
|
{
|
|
|
|
pagesetup_data data;
|
|
|
|
|
2009-01-23 16:26:29 +01:00
|
|
|
data.unicode = FALSE;
|
|
|
|
data.u.dlga = setupdlg;
|
2009-01-23 15:19:46 +01:00
|
|
|
|
|
|
|
return pagesetup_common(&data);
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
2009-01-23 15:19:46 +01:00
|
|
|
|
2000-05-27 00:26:06 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* PageSetupDlgW (COMDLG32.@)
|
2005-11-12 20:12:25 +01:00
|
|
|
*
|
|
|
|
* See PageSetupDlgA.
|
2000-05-27 00:26:06 +02:00
|
|
|
*/
|
2009-01-23 16:42:21 +01:00
|
|
|
BOOL WINAPI PageSetupDlgW(LPPAGESETUPDLGW setupdlg)
|
|
|
|
{
|
|
|
|
pagesetup_data data;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
2009-01-23 16:42:21 +01:00
|
|
|
data.unicode = TRUE;
|
|
|
|
data.u.dlgw = setupdlg;
|
2002-04-11 19:32:49 +02:00
|
|
|
|
2009-01-23 16:42:21 +01:00
|
|
|
return pagesetup_common(&data);
|
2000-05-27 00:26:06 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/***********************************************************************
|
2007-10-26 00:31:47 +02:00
|
|
|
* PrintDlgExA (COMDLG32.@)
|
2005-11-12 20:12:25 +01:00
|
|
|
*
|
|
|
|
* See PrintDlgExW.
|
|
|
|
*
|
2007-10-26 00:31:47 +02:00
|
|
|
* BUGS
|
|
|
|
* Only a Stub
|
|
|
|
*
|
2000-06-02 21:36:53 +02:00
|
|
|
*/
|
2007-10-26 00:31:47 +02:00
|
|
|
HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
|
2000-06-02 21:36:53 +02:00
|
|
|
{
|
2007-10-26 00:31:47 +02:00
|
|
|
|
|
|
|
FIXME("(%p) stub\n", lppd);
|
|
|
|
if ((lppd == NULL) || (lppd->lStructSize != sizeof(PRINTDLGEXA))) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsWindow(lppd->hwndOwner)) {
|
|
|
|
return E_HANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
2000-06-02 21:36:53 +02:00
|
|
|
}
|
2005-04-18 12:01:07 +02:00
|
|
|
|
2000-06-02 21:36:53 +02:00
|
|
|
/***********************************************************************
|
2007-10-26 00:31:47 +02:00
|
|
|
* PrintDlgExW (COMDLG32.@)
|
2005-11-12 20:12:25 +01:00
|
|
|
*
|
2007-10-26 00:31:47 +02:00
|
|
|
* Display the property sheet style PRINT dialog box
|
2005-11-12 20:12:25 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lppd [IO] ptr to PRINTDLGEX struct
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: One of the following COM error codes:
|
|
|
|
* E_OUTOFMEMORY Insufficient memory.
|
|
|
|
* E_INVALIDARG One or more arguments are invalid.
|
|
|
|
* E_POINTER Invalid pointer.
|
|
|
|
* E_HANDLE Invalid handle.
|
|
|
|
* E_FAIL Unspecified error.
|
|
|
|
*
|
2007-10-26 00:31:47 +02:00
|
|
|
* NOTES
|
|
|
|
* This Dialog enables the user to specify specific properties of the print job.
|
|
|
|
* The property sheet can also have additional application-specific and
|
|
|
|
* driver-specific property pages.
|
|
|
|
*
|
|
|
|
* BUGS
|
2008-07-10 19:19:27 +02:00
|
|
|
* Not fully implemented
|
2007-10-26 00:31:47 +02:00
|
|
|
*
|
2000-06-02 21:36:53 +02:00
|
|
|
*/
|
2007-10-26 00:31:47 +02:00
|
|
|
HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
|
2000-06-02 21:36:53 +02:00
|
|
|
{
|
2008-07-10 19:19:27 +02:00
|
|
|
DWORD ret = E_FAIL;
|
|
|
|
LPVOID ptr;
|
|
|
|
|
|
|
|
FIXME("(%p) not fully implemented\n", lppd);
|
2007-10-26 00:31:47 +02:00
|
|
|
|
|
|
|
if ((lppd == NULL) || (lppd->lStructSize != sizeof(PRINTDLGEXW))) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsWindow(lppd->hwndOwner)) {
|
|
|
|
return E_HANDLE;
|
|
|
|
}
|
|
|
|
|
2008-07-10 19:19:27 +02:00
|
|
|
if (lppd->Flags & PD_RETURNDEFAULT) {
|
|
|
|
PRINTER_INFO_2W *pbuf;
|
|
|
|
DRIVER_INFO_2W *dbuf;
|
|
|
|
HANDLE hprn;
|
|
|
|
DWORD needed = 1024;
|
|
|
|
BOOL bRet;
|
|
|
|
|
|
|
|
if (lppd->hDevMode || lppd->hDevNames) {
|
|
|
|
WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
|
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
if (!PRINTDLG_OpenDefaultPrinter(&hprn)) {
|
|
|
|
WARN("Can't find default printer\n");
|
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
bRet = GetPrinterW(hprn, 2, (LPBYTE)pbuf, needed, &needed);
|
|
|
|
if (!bRet && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, pbuf);
|
|
|
|
pbuf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
bRet = GetPrinterW(hprn, 2, (LPBYTE)pbuf, needed, &needed);
|
|
|
|
}
|
|
|
|
if (!bRet) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, pbuf);
|
|
|
|
ClosePrinter(hprn);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
needed = 1024;
|
|
|
|
dbuf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
bRet = GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed);
|
|
|
|
if (!bRet && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
|
|
|
dbuf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
bRet = GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed);
|
|
|
|
}
|
|
|
|
if (!bRet) {
|
|
|
|
ERR("GetPrinterDriverW failed, last error %d, fix your config for printer %s!\n",
|
|
|
|
GetLastError(), debugstr_w(pbuf->pPrinterName));
|
|
|
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pbuf);
|
|
|
|
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
|
|
|
|
ClosePrinter(hprn);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
ClosePrinter(hprn);
|
|
|
|
|
|
|
|
PRINTDLG_CreateDevNamesW(&(lppd->hDevNames),
|
|
|
|
dbuf->pDriverPath,
|
|
|
|
pbuf->pPrinterName,
|
|
|
|
pbuf->pPortName);
|
|
|
|
lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
|
|
|
|
pbuf->pDevMode->dmDriverExtra);
|
|
|
|
if (lppd->hDevMode) {
|
|
|
|
ptr = GlobalLock(lppd->hDevMode);
|
|
|
|
if (ptr) {
|
|
|
|
memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
|
|
|
|
pbuf->pDevMode->dmDriverExtra);
|
|
|
|
GlobalUnlock(lppd->hDevMode);
|
|
|
|
ret = S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, pbuf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, dbuf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-10-26 00:31:47 +02:00
|
|
|
return E_NOTIMPL;
|
2000-06-02 21:36:53 +02:00
|
|
|
}
|