2 * COMMDLG - Print Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
6 * Copyright 1999 Klaas van Gend
7 * Copyright 2000 Huw D M Davies
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
38 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
49 /* Yes these constants are the same, but we're just copying win98 */
50 #define UPDOWN_ID 0x270f
51 #define MAX_COPIES 9999
54 static struct pd_flags psd_flags
[] = {
55 {PSD_MINMARGINS
,"PSD_MINMARGINS"},
56 {PSD_MARGINS
,"PSD_MARGINS"},
57 {PSD_INTHOUSANDTHSOFINCHES
,"PSD_INTHOUSANDTHSOFINCHES"},
58 {PSD_INHUNDREDTHSOFMILLIMETERS
,"PSD_INHUNDREDTHSOFMILLIMETERS"},
59 {PSD_DISABLEMARGINS
,"PSD_DISABLEMARGINS"},
60 {PSD_DISABLEPRINTER
,"PSD_DISABLEPRINTER"},
61 {PSD_NOWARNING
,"PSD_NOWARNING"},
62 {PSD_DISABLEORIENTATION
,"PSD_DISABLEORIENTATION"},
63 {PSD_RETURNDEFAULT
,"PSD_RETURNDEFAULT"},
64 {PSD_DISABLEPAPER
,"PSD_DISABLEPAPER"},
65 {PSD_SHOWHELP
,"PSD_SHOWHELP"},
66 {PSD_ENABLEPAGESETUPHOOK
,"PSD_ENABLEPAGESETUPHOOK"},
67 {PSD_ENABLEPAGESETUPTEMPLATE
,"PSD_ENABLEPAGESETUPTEMPLATE"},
68 {PSD_ENABLEPAGESETUPTEMPLATEHANDLE
,"PSD_ENABLEPAGESETUPTEMPLATEHANDLE"},
69 {PSD_ENABLEPAGEPAINTHOOK
,"PSD_ENABLEPAGEPAINTHOOK"},
70 {PSD_DISABLEPAGEPAINTING
,"PSD_DISABLEPAGEPAINTING"},
74 /***********************************************************************
75 * PRINTDLG_OpenDefaultPrinter
77 * Returns a winspool printer handle to the default printer in *hprn
78 * Caller must call ClosePrinter on the handle
80 * Returns TRUE on success else FALSE
82 BOOL
PRINTDLG_OpenDefaultPrinter(HANDLE
*hprn
)
85 DWORD dwBufLen
= sizeof(buf
);
87 if(!GetDefaultPrinterA(buf
, &dwBufLen
))
89 res
= OpenPrinterA(buf
, hprn
, NULL
);
91 FIXME("Could not open printer %s?!\n",buf
);
95 /***********************************************************************
96 * PRINTDLG_SetUpPrinterListCombo
98 * Initializes printer list combox.
99 * hDlg: HWND of dialog
100 * id: Control id of combo
101 * name: Name of printer to select
103 * Initializes combo with list of available printers. Selects printer 'name'
104 * If name is NULL or does not exist select the default printer.
106 * Returns number of printers added to list.
108 INT
PRINTDLG_SetUpPrinterListComboA(HWND hDlg
, UINT id
, LPCSTR name
)
112 LPPRINTER_INFO_2A pi
;
113 EnumPrintersA(PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &needed
, &num
);
114 pi
= HeapAlloc(GetProcessHeap(), 0, needed
);
115 EnumPrintersA(PRINTER_ENUM_LOCAL
, NULL
, 2, (LPBYTE
)pi
, needed
, &needed
,
118 for(i
= 0; i
< num
; i
++) {
119 SendDlgItemMessageA(hDlg
, id
, CB_ADDSTRING
, 0,
120 (LPARAM
)pi
[i
].pPrinterName
);
122 HeapFree(GetProcessHeap(), 0, pi
);
124 (i
= SendDlgItemMessageA(hDlg
, id
, CB_FINDSTRINGEXACT
, -1,
125 (LPARAM
)name
)) == CB_ERR
) {
128 DWORD dwBufLen
= sizeof(buf
);
129 FIXME("Can't find '%s' in printer list so trying to find default\n",
131 if(!GetDefaultPrinterA(buf
, &dwBufLen
))
133 i
= SendDlgItemMessageA(hDlg
, id
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buf
);
135 FIXME("Can't find default printer in printer list\n");
137 SendDlgItemMessageA(hDlg
, id
, CB_SETCURSEL
, i
, 0);
141 static INT
PRINTDLG_SetUpPrinterListComboW(HWND hDlg
, UINT id
, LPCWSTR name
)
145 LPPRINTER_INFO_2W pi
;
146 EnumPrintersW(PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &needed
, &num
);
147 pi
= HeapAlloc(GetProcessHeap(), 0, needed
);
148 EnumPrintersW(PRINTER_ENUM_LOCAL
, NULL
, 2, (LPBYTE
)pi
, needed
, &needed
,
151 for(i
= 0; i
< num
; i
++) {
152 SendDlgItemMessageW(hDlg
, id
, CB_ADDSTRING
, 0,
153 (LPARAM
)pi
[i
].pPrinterName
);
155 HeapFree(GetProcessHeap(), 0, pi
);
157 (i
= SendDlgItemMessageW(hDlg
, id
, CB_FINDSTRINGEXACT
, -1,
158 (LPARAM
)name
)) == CB_ERR
) {
160 DWORD dwBufLen
= sizeof(buf
)/sizeof(buf
[0]);
161 TRACE("Can't find '%s' in printer list so trying to find default\n",
163 if(!GetDefaultPrinterW(buf
, &dwBufLen
))
165 i
= SendDlgItemMessageW(hDlg
, id
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buf
);
167 TRACE("Can't find default printer in printer list\n");
169 SendDlgItemMessageW(hDlg
, id
, CB_SETCURSEL
, i
, 0);
173 /***********************************************************************
174 * PRINTDLG_CreateDevNames [internal]
177 * creates a DevNames structure.
179 * (NB. when we handle unicode the offsets will be in wchars).
181 static BOOL
PRINTDLG_CreateDevNames(HGLOBAL
*hmem
, char* DeviceDriverName
,
182 char* DeviceName
, char* OutputPort
)
185 char* pDevNamesSpace
;
187 LPDEVNAMES lpDevNames
;
189 DWORD dwBufLen
= sizeof(buf
);
191 size
= strlen(DeviceDriverName
) + 1
192 + strlen(DeviceName
) + 1
193 + strlen(OutputPort
) + 1
197 *hmem
= GlobalReAlloc(*hmem
, size
, GMEM_MOVEABLE
);
199 *hmem
= GlobalAlloc(GMEM_MOVEABLE
, size
);
203 pDevNamesSpace
= GlobalLock(*hmem
);
204 lpDevNames
= (LPDEVNAMES
) pDevNamesSpace
;
206 pTempPtr
= pDevNamesSpace
+ sizeof(DEVNAMES
);
207 strcpy(pTempPtr
, DeviceDriverName
);
208 lpDevNames
->wDriverOffset
= pTempPtr
- pDevNamesSpace
;
210 pTempPtr
+= strlen(DeviceDriverName
) + 1;
211 strcpy(pTempPtr
, DeviceName
);
212 lpDevNames
->wDeviceOffset
= pTempPtr
- pDevNamesSpace
;
214 pTempPtr
+= strlen(DeviceName
) + 1;
215 strcpy(pTempPtr
, OutputPort
);
216 lpDevNames
->wOutputOffset
= pTempPtr
- pDevNamesSpace
;
218 GetDefaultPrinterA(buf
, &dwBufLen
);
219 lpDevNames
->wDefault
= (strcmp(buf
, DeviceName
) == 0) ? 1 : 0;
224 static BOOL
PRINTDLG_CreateDevNamesW(HGLOBAL
*hmem
, LPCWSTR DeviceDriverName
,
225 LPCWSTR DeviceName
, LPCWSTR OutputPort
)
228 LPWSTR pDevNamesSpace
;
230 LPDEVNAMES lpDevNames
;
232 DWORD dwBufLen
= sizeof(bufW
) / sizeof(WCHAR
);
234 size
= sizeof(WCHAR
)*lstrlenW(DeviceDriverName
) + 2
235 + sizeof(WCHAR
)*lstrlenW(DeviceName
) + 2
236 + sizeof(WCHAR
)*lstrlenW(OutputPort
) + 2
240 *hmem
= GlobalReAlloc(*hmem
, size
, GMEM_MOVEABLE
);
242 *hmem
= GlobalAlloc(GMEM_MOVEABLE
, size
);
246 pDevNamesSpace
= GlobalLock(*hmem
);
247 lpDevNames
= (LPDEVNAMES
) pDevNamesSpace
;
249 pTempPtr
= (LPWSTR
)((LPDEVNAMES
)pDevNamesSpace
+ 1);
250 lstrcpyW(pTempPtr
, DeviceDriverName
);
251 lpDevNames
->wDriverOffset
= pTempPtr
- pDevNamesSpace
;
253 pTempPtr
+= lstrlenW(DeviceDriverName
) + 1;
254 lstrcpyW(pTempPtr
, DeviceName
);
255 lpDevNames
->wDeviceOffset
= pTempPtr
- pDevNamesSpace
;
257 pTempPtr
+= lstrlenW(DeviceName
) + 1;
258 lstrcpyW(pTempPtr
, OutputPort
);
259 lpDevNames
->wOutputOffset
= pTempPtr
- pDevNamesSpace
;
261 GetDefaultPrinterW(bufW
, &dwBufLen
);
262 lpDevNames
->wDefault
= (lstrcmpW(bufW
, DeviceName
) == 0) ? 1 : 0;
267 /***********************************************************************
268 * PRINTDLG_UpdatePrintDlg [internal]
271 * updates the PrintDlg structure for return values.
274 * FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
275 * TRUE if successful.
277 static BOOL
PRINTDLG_UpdatePrintDlgA(HWND hDlg
,
278 PRINT_PTRA
* PrintStructures
)
280 LPPRINTDLGA lppd
= PrintStructures
->lpPrintDlg
;
281 PDEVMODEA lpdm
= PrintStructures
->lpDevMode
;
282 LPPRINTER_INFO_2A pi
= PrintStructures
->lpPrinterInfo
;
286 FIXME("No lpdm ptr?\n");
291 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
292 /* check whether nFromPage and nToPage are within range defined by
293 * nMinPage and nMaxPage
295 if (IsDlgButtonChecked(hDlg
, rad3
) == BST_CHECKED
) { /* Pages */
298 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
299 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
300 if (nFromPage
< lppd
->nMinPage
|| nFromPage
> lppd
->nMaxPage
||
301 nToPage
< lppd
->nMinPage
|| nToPage
> lppd
->nMaxPage
) {
302 char resourcestr
[256];
304 LoadStringA(COMDLG32_hInstance
, PD32_INVALID_PAGE_RANGE
,
306 sprintf(resultstr
,resourcestr
, lppd
->nMinPage
, lppd
->nMaxPage
);
307 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_TITLE
,
309 MessageBoxA(hDlg
, resultstr
, resourcestr
,
310 MB_OK
| MB_ICONWARNING
);
313 lppd
->nFromPage
= nFromPage
;
314 lppd
->nToPage
= nToPage
;
315 lppd
->Flags
|= PD_PAGENUMS
;
318 lppd
->Flags
&= ~PD_PAGENUMS
;
320 if (IsDlgButtonChecked(hDlg
, chx1
) == BST_CHECKED
) {/* Print to file */
321 lppd
->Flags
|= PD_PRINTTOFILE
;
322 pi
->pPortName
= "FILE:";
325 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
) { /* Collate */
326 FIXME("Collate lppd not yet implemented as output\n");
329 /* set PD_Collate and nCopies */
330 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
331 /* The application doesn't support multiple copies or collate...
333 lppd
->Flags
&= ~PD_COLLATE
;
335 /* if the printer driver supports it... store info there
336 * otherwise no collate & multiple copies !
338 if (lpdm
->dmFields
& DM_COLLATE
)
340 (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
);
341 if (lpdm
->dmFields
& DM_COPIES
)
342 lpdm
->dmCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
344 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
345 lppd
->Flags
|= PD_COLLATE
;
347 lppd
->Flags
&= ~PD_COLLATE
;
348 lppd
->nCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
354 static BOOL
PRINTDLG_UpdatePrintDlgW(HWND hDlg
,
355 PRINT_PTRW
* PrintStructures
)
357 LPPRINTDLGW lppd
= PrintStructures
->lpPrintDlg
;
358 PDEVMODEW lpdm
= PrintStructures
->lpDevMode
;
359 LPPRINTER_INFO_2W pi
= PrintStructures
->lpPrinterInfo
;
363 FIXME("No lpdm ptr?\n");
368 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
369 /* check whether nFromPage and nToPage are within range defined by
370 * nMinPage and nMaxPage
372 if (IsDlgButtonChecked(hDlg
, rad3
) == BST_CHECKED
) { /* Pages */
375 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
376 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
377 if (nFromPage
< lppd
->nMinPage
|| nFromPage
> lppd
->nMaxPage
||
378 nToPage
< lppd
->nMinPage
|| nToPage
> lppd
->nMaxPage
) {
379 WCHAR resourcestr
[256];
380 WCHAR resultstr
[256];
381 LoadStringW(COMDLG32_hInstance
, PD32_INVALID_PAGE_RANGE
,
383 wsprintfW(resultstr
,resourcestr
, lppd
->nMinPage
, lppd
->nMaxPage
);
384 LoadStringW(COMDLG32_hInstance
, PD32_PRINT_TITLE
,
386 MessageBoxW(hDlg
, resultstr
, resourcestr
,
387 MB_OK
| MB_ICONWARNING
);
390 lppd
->nFromPage
= nFromPage
;
391 lppd
->nToPage
= nToPage
;
394 if (IsDlgButtonChecked(hDlg
, chx1
) == BST_CHECKED
) {/* Print to file */
395 static WCHAR file
[] = {'F','I','L','E',':',0};
396 lppd
->Flags
|= PD_PRINTTOFILE
;
397 pi
->pPortName
= file
;
400 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
) { /* Collate */
401 FIXME("Collate lppd not yet implemented as output\n");
404 /* set PD_Collate and nCopies */
405 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
406 /* The application doesn't support multiple copies or collate...
408 lppd
->Flags
&= ~PD_COLLATE
;
410 /* if the printer driver supports it... store info there
411 * otherwise no collate & multiple copies !
413 if (lpdm
->dmFields
& DM_COLLATE
)
415 (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
);
416 if (lpdm
->dmFields
& DM_COPIES
)
417 lpdm
->dmCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
419 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
420 lppd
->Flags
|= PD_COLLATE
;
422 lppd
->Flags
&= ~PD_COLLATE
;
423 lppd
->nCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
429 static BOOL
PRINTDLG_PaperSizeA(
430 PRINTDLGA
*pdlga
,const char *PaperSize
,LPPOINT size
434 LPSTR devname
,portname
;
438 POINT
*points
= NULL
;
441 dn
= GlobalLock(pdlga
->hDevNames
);
442 dm
= GlobalLock(pdlga
->hDevMode
);
443 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
444 portname
= ((char*)dn
)+dn
->wOutputOffset
;
447 NrOfEntries
= DeviceCapabilitiesA(devname
,portname
,DC_PAPERNAMES
,NULL
,dm
);
449 FIXME("No papernames found for %s/%s\n",devname
,portname
);
452 if (NrOfEntries
== -1) {
453 ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n");
457 Names
= (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries
*64);
458 if (NrOfEntries
!= (ret
=DeviceCapabilitiesA(devname
,portname
,DC_PAPERNAMES
,Names
,dm
))) {
459 FIXME("Number of returned vals %d is not %d\n",NrOfEntries
,ret
);
462 for (i
=0;i
<NrOfEntries
;i
++)
463 if (!strcmp(PaperSize
,Names
+(64*i
)))
465 HeapFree(GetProcessHeap(),0,Names
);
466 if (i
==NrOfEntries
) {
467 FIXME("Papersize %s not found in list?\n",PaperSize
);
470 points
= HeapAlloc(GetProcessHeap(),0,sizeof(points
[0])*NrOfEntries
);
471 if (NrOfEntries
!=(ret
=DeviceCapabilitiesA(devname
,portname
,DC_PAPERSIZE
,(LPBYTE
)points
,dm
))) {
472 FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries
,ret
);
475 /* this is _10ths_ of a millimeter */
480 GlobalUnlock(pdlga
->hDevNames
);
481 GlobalUnlock(pdlga
->hDevMode
);
482 HeapFree(GetProcessHeap(),0,Names
);
483 HeapFree(GetProcessHeap(),0,points
);
487 static BOOL
PRINTDLG_PaperSizeW(
488 PRINTDLGW
*pdlga
,const WCHAR
*PaperSize
,LPPOINT size
492 LPWSTR devname
,portname
;
496 POINT
*points
= NULL
;
499 dn
= GlobalLock(pdlga
->hDevNames
);
500 dm
= GlobalLock(pdlga
->hDevMode
);
501 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
502 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
505 NrOfEntries
= DeviceCapabilitiesW(devname
,portname
,DC_PAPERNAMES
,NULL
,dm
);
507 FIXME("No papernames found for %s/%s\n",debugstr_w(devname
),debugstr_w(portname
));
510 if (NrOfEntries
== -1) {
511 ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n");
515 Names
= (WCHAR
*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*NrOfEntries
*64);
516 if (NrOfEntries
!= (ret
=DeviceCapabilitiesW(devname
,portname
,DC_PAPERNAMES
,Names
,dm
))) {
517 FIXME("Number of returned vals %d is not %d\n",NrOfEntries
,ret
);
520 for (i
=0;i
<NrOfEntries
;i
++)
521 if (!lstrcmpW(PaperSize
,Names
+(64*i
)))
523 HeapFree(GetProcessHeap(),0,Names
);
524 if (i
==NrOfEntries
) {
525 FIXME("Papersize %s not found in list?\n",debugstr_w(PaperSize
));
528 points
= HeapAlloc(GetProcessHeap(),0,sizeof(points
[0])*NrOfEntries
);
529 if (NrOfEntries
!=(ret
=DeviceCapabilitiesW(devname
,portname
,DC_PAPERSIZE
,(LPWSTR
)points
,dm
))) {
530 FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries
,ret
);
533 /* this is _10ths_ of a millimeter */
538 GlobalUnlock(pdlga
->hDevNames
);
539 GlobalUnlock(pdlga
->hDevMode
);
540 HeapFree(GetProcessHeap(),0,Names
);
541 HeapFree(GetProcessHeap(),0,points
);
546 /************************************************************************
547 * PRINTDLG_SetUpPaperComboBox
549 * Initialize either the papersize or inputslot combos of the Printer Setup
550 * dialog. We store the associated word (eg DMPAPER_A4) as the item data.
551 * We also try to re-select the old selection.
553 static BOOL
PRINTDLG_SetUpPaperComboBoxA(HWND hDlg
,
566 int fwCapability_Names
;
567 int fwCapability_Words
;
569 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",PrinterName
,PortName
,nIDComboBox
);
571 /* query the dialog box for the current selected value */
572 Sel
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETCURSEL
, 0, 0);
574 /* we enter here only if a different printer is selected after
575 * the Print Setup dialog is opened. The current settings are
576 * stored into the newly selected printer.
578 oldWord
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
,
581 if (nIDComboBox
== cmb2
)
582 dm
->u1
.s1
.dmPaperSize
= oldWord
;
584 dm
->dmDefaultSource
= oldWord
;
588 /* we enter here only when the Print setup dialog is initially
589 * opened. In this case the settings are restored from when
590 * the dialog was last closed.
593 if (nIDComboBox
== cmb2
)
594 oldWord
= dm
->u1
.s1
.dmPaperSize
;
596 oldWord
= dm
->dmDefaultSource
;
600 if (nIDComboBox
== cmb2
) {
602 fwCapability_Names
= DC_PAPERNAMES
;
603 fwCapability_Words
= DC_PAPERS
;
607 fwCapability_Names
= DC_BINNAMES
;
608 fwCapability_Words
= DC_BINS
;
611 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the
612 * paper settings. As Wine doesn't allow VXDs, this results in a crash.
614 WARN(" if your printer driver uses VXDs, expect a crash now!\n");
615 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
616 fwCapability_Names
, NULL
, dm
);
617 if (NrOfEntries
== 0)
618 WARN("no Name Entries found!\n");
619 else if (NrOfEntries
< 0)
622 if(DeviceCapabilitiesA(PrinterName
, PortName
, fwCapability_Words
, NULL
, dm
)
624 ERR("Number of caps is different\n");
628 Names
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(char)*NamesSize
);
629 Words
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WORD
));
630 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
631 fwCapability_Names
, Names
, dm
);
632 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
633 fwCapability_Words
, (LPSTR
)Words
, dm
);
635 /* reset any current content in the combobox */
636 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_RESETCONTENT
, 0, 0);
638 /* store new content */
639 for (i
= 0; i
< NrOfEntries
; i
++) {
640 DWORD pos
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_ADDSTRING
, 0,
641 (LPARAM
)(&Names
[i
*NamesSize
]) );
642 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_SETITEMDATA
, pos
,
646 /* Look for old selection - can't do this is previous loop since
647 item order will change as more items are added */
649 for (i
= 0; i
< NrOfEntries
; i
++) {
650 if(SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
, i
, 0) ==
656 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_SETCURSEL
, Sel
, 0);
658 HeapFree(GetProcessHeap(),0,Words
);
659 HeapFree(GetProcessHeap(),0,Names
);
663 static BOOL
PRINTDLG_SetUpPaperComboBoxW(HWND hDlg
,
676 int fwCapability_Names
;
677 int fwCapability_Words
;
679 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",debugstr_w(PrinterName
),debugstr_w(PortName
),nIDComboBox
);
681 /* query the dialog box for the current selected value */
682 Sel
= SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_GETCURSEL
, 0, 0);
684 /* we enter here only if a different printer is selected after
685 * the Print Setup dialog is opened. The current settings are
686 * stored into the newly selected printer.
688 oldWord
= SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_GETITEMDATA
,
691 if (nIDComboBox
== cmb2
)
692 dm
->u1
.s1
.dmPaperSize
= oldWord
;
694 dm
->dmDefaultSource
= oldWord
;
698 /* we enter here only when the Print setup dialog is initially
699 * opened. In this case the settings are restored from when
700 * the dialog was last closed.
703 if (nIDComboBox
== cmb2
)
704 oldWord
= dm
->u1
.s1
.dmPaperSize
;
706 oldWord
= dm
->dmDefaultSource
;
710 if (nIDComboBox
== cmb2
) {
712 fwCapability_Names
= DC_PAPERNAMES
;
713 fwCapability_Words
= DC_PAPERS
;
717 fwCapability_Names
= DC_BINNAMES
;
718 fwCapability_Words
= DC_BINS
;
721 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the
722 * paper settings. As Wine doesn't allow VXDs, this results in a crash.
724 WARN(" if your printer driver uses VXDs, expect a crash now!\n");
725 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
726 fwCapability_Names
, NULL
, dm
);
727 if (NrOfEntries
== 0)
728 WARN("no Name Entries found!\n");
729 else if (NrOfEntries
< 0)
732 if(DeviceCapabilitiesW(PrinterName
, PortName
, fwCapability_Words
, NULL
, dm
)
734 ERR("Number of caps is different\n");
738 Names
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WCHAR
)*NamesSize
);
739 Words
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WORD
));
740 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
741 fwCapability_Names
, Names
, dm
);
742 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
743 fwCapability_Words
, (LPWSTR
)Words
, dm
);
745 /* reset any current content in the combobox */
746 SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_RESETCONTENT
, 0, 0);
748 /* store new content */
749 for (i
= 0; i
< NrOfEntries
; i
++) {
750 DWORD pos
= SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_ADDSTRING
, 0,
751 (LPARAM
)(&Names
[i
*NamesSize
]) );
752 SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_SETITEMDATA
, pos
,
756 /* Look for old selection - can't do this is previous loop since
757 item order will change as more items are added */
759 for (i
= 0; i
< NrOfEntries
; i
++) {
760 if(SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_GETITEMDATA
, i
, 0) ==
766 SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_SETCURSEL
, Sel
, 0);
768 HeapFree(GetProcessHeap(),0,Words
);
769 HeapFree(GetProcessHeap(),0,Names
);
774 /***********************************************************************
775 * PRINTDLG_UpdatePrinterInfoTexts [internal]
777 static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg
, LPPRINTER_INFO_2A pi
)
780 char ResourceString
[256];
786 /* add all status messages */
787 for (i
= 0; i
< 25; i
++) {
788 if (pi
->Status
& (1<<i
)) {
789 LoadStringA(COMDLG32_hInstance
, PD32_PRINTER_STATUS_PAUSED
+i
,
790 ResourceString
, 255);
791 strcat(StatusMsg
,ResourceString
);
795 /* FIXME: status==ready must only be appended if really so.
796 but how to detect? */
797 LoadStringA(COMDLG32_hInstance
, PD32_PRINTER_STATUS_READY
,
798 ResourceString
, 255);
799 strcat(StatusMsg
,ResourceString
);
800 SetDlgItemTextA(hDlg
, stc12
, StatusMsg
);
802 /* set all other printer info texts */
803 SetDlgItemTextA(hDlg
, stc11
, pi
->pDriverName
);
805 if (pi
->pLocation
!= NULL
&& pi
->pLocation
[0] != '\0')
806 SetDlgItemTextA(hDlg
, stc14
, pi
->pLocation
);
808 SetDlgItemTextA(hDlg
, stc14
, pi
->pPortName
);
809 SetDlgItemTextA(hDlg
, stc13
, pi
->pComment
? pi
->pComment
: "");
813 static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg
, LPPRINTER_INFO_2W pi
)
815 WCHAR StatusMsg
[256];
816 WCHAR ResourceString
[256];
817 static const WCHAR emptyW
[] = {0};
823 /* add all status messages */
824 for (i
= 0; i
< 25; i
++) {
825 if (pi
->Status
& (1<<i
)) {
826 LoadStringW(COMDLG32_hInstance
, PD32_PRINTER_STATUS_PAUSED
+i
,
827 ResourceString
, 255);
828 lstrcatW(StatusMsg
,ResourceString
);
832 /* FIXME: status==ready must only be appended if really so.
833 but how to detect? */
834 LoadStringW(COMDLG32_hInstance
, PD32_PRINTER_STATUS_READY
,
835 ResourceString
, 255);
836 lstrcatW(StatusMsg
,ResourceString
);
837 SetDlgItemTextW(hDlg
, stc12
, StatusMsg
);
839 /* set all other printer info texts */
840 SetDlgItemTextW(hDlg
, stc11
, pi
->pDriverName
);
841 if (pi
->pLocation
!= NULL
&& pi
->pLocation
[0] != '\0')
842 SetDlgItemTextW(hDlg
, stc14
, pi
->pLocation
);
844 SetDlgItemTextW(hDlg
, stc14
, pi
->pPortName
);
845 SetDlgItemTextW(hDlg
, stc13
, pi
->pComment
? pi
->pComment
: emptyW
);
849 /*******************************************************************
851 * PRINTDLG_ChangePrinter
854 BOOL
PRINTDLG_ChangePrinterA(HWND hDlg
, char *name
,
855 PRINT_PTRA
*PrintStructures
)
857 LPPRINTDLGA lppd
= PrintStructures
->lpPrintDlg
;
858 LPDEVMODEA lpdm
= NULL
;
863 HeapFree(GetProcessHeap(),0, PrintStructures
->lpPrinterInfo
);
864 HeapFree(GetProcessHeap(),0, PrintStructures
->lpDriverInfo
);
865 if(!OpenPrinterA(name
, &hprn
, NULL
)) {
866 ERR("Can't open printer %s\n", name
);
869 GetPrinterA(hprn
, 2, NULL
, 0, &needed
);
870 PrintStructures
->lpPrinterInfo
= HeapAlloc(GetProcessHeap(),0,needed
);
871 GetPrinterA(hprn
, 2, (LPBYTE
)PrintStructures
->lpPrinterInfo
, needed
,
873 GetPrinterDriverA(hprn
, NULL
, 3, NULL
, 0, &needed
);
874 PrintStructures
->lpDriverInfo
= HeapAlloc(GetProcessHeap(),0,needed
);
875 if (!GetPrinterDriverA(hprn
, NULL
, 3, (LPBYTE
)PrintStructures
->lpDriverInfo
,
877 ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures
->lpPrinterInfo
->pPrinterName
);
882 PRINTDLG_UpdatePrinterInfoTextsA(hDlg
, PrintStructures
->lpPrinterInfo
);
884 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
885 PrintStructures
->lpDevMode
= NULL
;
887 dmSize
= DocumentPropertiesA(0, 0, name
, NULL
, NULL
, 0);
889 ERR("DocumentProperties fails on %s\n", debugstr_a(name
));
892 PrintStructures
->lpDevMode
= HeapAlloc(GetProcessHeap(), 0, dmSize
);
893 dmSize
= DocumentPropertiesA(0, 0, name
, PrintStructures
->lpDevMode
, NULL
,
895 if(lppd
->hDevMode
&& (lpdm
= GlobalLock(lppd
->hDevMode
)) &&
896 !strcmp(lpdm
->dmDeviceName
,
897 PrintStructures
->lpDevMode
->dmDeviceName
)) {
898 /* Supplied devicemode matches current printer so try to use it */
899 DocumentPropertiesA(0, 0, name
, PrintStructures
->lpDevMode
, lpdm
,
900 DM_OUT_BUFFER
| DM_IN_BUFFER
);
903 GlobalUnlock(lppd
->hDevMode
);
905 lpdm
= PrintStructures
->lpDevMode
; /* use this as a shortcut */
907 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
908 /* Print range (All/Range/Selection) */
909 SetDlgItemInt(hDlg
, edt1
, lppd
->nFromPage
, FALSE
);
910 SetDlgItemInt(hDlg
, edt2
, lppd
->nToPage
, FALSE
);
911 CheckRadioButton(hDlg
, rad1
, rad3
, rad1
); /* default */
912 if (lppd
->Flags
& PD_NOSELECTION
)
913 EnableWindow(GetDlgItem(hDlg
, rad2
), FALSE
);
915 if (lppd
->Flags
& PD_SELECTION
)
916 CheckRadioButton(hDlg
, rad1
, rad3
, rad2
);
917 if (lppd
->Flags
& PD_NOPAGENUMS
) {
918 EnableWindow(GetDlgItem(hDlg
, rad3
), FALSE
);
919 EnableWindow(GetDlgItem(hDlg
, stc2
),FALSE
);
920 EnableWindow(GetDlgItem(hDlg
, edt1
), FALSE
);
921 EnableWindow(GetDlgItem(hDlg
, stc3
),FALSE
);
922 EnableWindow(GetDlgItem(hDlg
, edt2
), FALSE
);
924 if (lppd
->Flags
& PD_PAGENUMS
)
925 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
930 * FIXME: The ico3 is not displayed for some reason. I don't know why.
932 if (lppd
->Flags
& PD_COLLATE
) {
933 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
934 (LPARAM
)PrintStructures
->hCollateIcon
);
935 CheckDlgButton(hDlg
, chx2
, 1);
937 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
938 (LPARAM
)PrintStructures
->hNoCollateIcon
);
939 CheckDlgButton(hDlg
, chx2
, 0);
942 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
943 /* if printer doesn't support it: no Collate */
944 if (!(lpdm
->dmFields
& DM_COLLATE
)) {
945 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
946 EnableWindow(GetDlgItem(hDlg
, ico3
), FALSE
);
953 if (lppd
->hDevMode
== 0)
954 copies
= lppd
->nCopies
;
956 copies
= lpdm
->dmCopies
;
957 if(copies
== 0) copies
= 1;
958 else if(copies
< 0) copies
= MAX_COPIES
;
959 SetDlgItemInt(hDlg
, edt3
, copies
, FALSE
);
962 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
963 /* if printer doesn't support it: no nCopies */
964 if (!(lpdm
->dmFields
& DM_COPIES
)) {
965 EnableWindow(GetDlgItem(hDlg
, edt3
), FALSE
);
966 EnableWindow(GetDlgItem(hDlg
, stc5
), FALSE
);
971 CheckDlgButton(hDlg
, chx1
, (lppd
->Flags
& PD_PRINTTOFILE
) ? 1 : 0);
972 if (lppd
->Flags
& PD_DISABLEPRINTTOFILE
)
973 EnableWindow(GetDlgItem(hDlg
, chx1
), FALSE
);
974 if (lppd
->Flags
& PD_HIDEPRINTTOFILE
)
975 ShowWindow(GetDlgItem(hDlg
, chx1
), SW_HIDE
);
977 } else { /* PD_PRINTSETUP */
978 BOOL bPortrait
= (lpdm
->u1
.s1
.dmOrientation
== DMORIENT_PORTRAIT
);
980 PRINTDLG_SetUpPaperComboBoxA(hDlg
, cmb2
,
981 PrintStructures
->lpPrinterInfo
->pPrinterName
,
982 PrintStructures
->lpPrinterInfo
->pPortName
,
984 PRINTDLG_SetUpPaperComboBoxA(hDlg
, cmb3
,
985 PrintStructures
->lpPrinterInfo
->pPrinterName
,
986 PrintStructures
->lpPrinterInfo
->pPortName
,
988 CheckRadioButton(hDlg
, rad1
, rad2
, bPortrait
? rad1
: rad2
);
989 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
990 (LPARAM
)(bPortrait
? PrintStructures
->hPortraitIcon
:
991 PrintStructures
->hLandscapeIcon
));
996 if ((lppd
->Flags
& PD_SHOWHELP
)==0) {
997 /* hide if PD_SHOWHELP not specified */
998 ShowWindow(GetDlgItem(hDlg
, pshHelp
), SW_HIDE
);
1003 static BOOL
PRINTDLG_ChangePrinterW(HWND hDlg
, WCHAR
*name
,
1004 PRINT_PTRW
*PrintStructures
)
1006 LPPRINTDLGW lppd
= PrintStructures
->lpPrintDlg
;
1007 LPDEVMODEW lpdm
= NULL
;
1012 HeapFree(GetProcessHeap(),0, PrintStructures
->lpPrinterInfo
);
1013 HeapFree(GetProcessHeap(),0, PrintStructures
->lpDriverInfo
);
1014 if(!OpenPrinterW(name
, &hprn
, NULL
)) {
1015 ERR("Can't open printer %s\n", debugstr_w(name
));
1018 GetPrinterW(hprn
, 2, NULL
, 0, &needed
);
1019 PrintStructures
->lpPrinterInfo
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
1020 GetPrinterW(hprn
, 2, (LPBYTE
)PrintStructures
->lpPrinterInfo
, needed
,
1022 GetPrinterDriverW(hprn
, NULL
, 3, NULL
, 0, &needed
);
1023 PrintStructures
->lpDriverInfo
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
1024 if (!GetPrinterDriverW(hprn
, NULL
, 3, (LPBYTE
)PrintStructures
->lpDriverInfo
,
1026 ERR("GetPrinterDriverA failed for %s, fix your config!\n",debugstr_w(PrintStructures
->lpPrinterInfo
->pPrinterName
));
1031 PRINTDLG_UpdatePrinterInfoTextsW(hDlg
, PrintStructures
->lpPrinterInfo
);
1033 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
1034 PrintStructures
->lpDevMode
= NULL
;
1036 dmSize
= DocumentPropertiesW(0, 0, name
, NULL
, NULL
, 0);
1038 ERR("DocumentProperties fails on %s\n", debugstr_w(name
));
1041 PrintStructures
->lpDevMode
= HeapAlloc(GetProcessHeap(), 0, dmSize
);
1042 dmSize
= DocumentPropertiesW(0, 0, name
, PrintStructures
->lpDevMode
, NULL
,
1044 if(lppd
->hDevMode
&& (lpdm
= GlobalLock(lppd
->hDevMode
)) &&
1045 !lstrcmpW(lpdm
->dmDeviceName
,
1046 PrintStructures
->lpDevMode
->dmDeviceName
)) {
1047 /* Supplied devicemode matches current printer so try to use it */
1048 DocumentPropertiesW(0, 0, name
, PrintStructures
->lpDevMode
, lpdm
,
1049 DM_OUT_BUFFER
| DM_IN_BUFFER
);
1052 GlobalUnlock(lppd
->hDevMode
);
1054 lpdm
= PrintStructures
->lpDevMode
; /* use this as a shortcut */
1056 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
1057 /* Print range (All/Range/Selection) */
1058 SetDlgItemInt(hDlg
, edt1
, lppd
->nFromPage
, FALSE
);
1059 SetDlgItemInt(hDlg
, edt2
, lppd
->nToPage
, FALSE
);
1060 CheckRadioButton(hDlg
, rad1
, rad3
, rad1
); /* default */
1061 if (lppd
->Flags
& PD_NOSELECTION
)
1062 EnableWindow(GetDlgItem(hDlg
, rad2
), FALSE
);
1064 if (lppd
->Flags
& PD_SELECTION
)
1065 CheckRadioButton(hDlg
, rad1
, rad3
, rad2
);
1066 if (lppd
->Flags
& PD_NOPAGENUMS
) {
1067 EnableWindow(GetDlgItem(hDlg
, rad3
), FALSE
);
1068 EnableWindow(GetDlgItem(hDlg
, stc2
),FALSE
);
1069 EnableWindow(GetDlgItem(hDlg
, edt1
), FALSE
);
1070 EnableWindow(GetDlgItem(hDlg
, stc3
),FALSE
);
1071 EnableWindow(GetDlgItem(hDlg
, edt2
), FALSE
);
1073 if (lppd
->Flags
& PD_PAGENUMS
)
1074 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1079 * FIXME: The ico3 is not displayed for some reason. I don't know why.
1081 if (lppd
->Flags
& PD_COLLATE
) {
1082 SendDlgItemMessageW(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1083 (LPARAM
)PrintStructures
->hCollateIcon
);
1084 CheckDlgButton(hDlg
, chx2
, 1);
1086 SendDlgItemMessageW(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1087 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1088 CheckDlgButton(hDlg
, chx2
, 0);
1091 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1092 /* if printer doesn't support it: no Collate */
1093 if (!(lpdm
->dmFields
& DM_COLLATE
)) {
1094 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1095 EnableWindow(GetDlgItem(hDlg
, ico3
), FALSE
);
1102 if (lppd
->hDevMode
== 0)
1103 copies
= lppd
->nCopies
;
1105 copies
= lpdm
->dmCopies
;
1106 if(copies
== 0) copies
= 1;
1107 else if(copies
< 0) copies
= MAX_COPIES
;
1108 SetDlgItemInt(hDlg
, edt3
, copies
, FALSE
);
1111 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1112 /* if printer doesn't support it: no nCopies */
1113 if (!(lpdm
->dmFields
& DM_COPIES
)) {
1114 EnableWindow(GetDlgItem(hDlg
, edt3
), FALSE
);
1115 EnableWindow(GetDlgItem(hDlg
, stc5
), FALSE
);
1120 CheckDlgButton(hDlg
, chx1
, (lppd
->Flags
& PD_PRINTTOFILE
) ? 1 : 0);
1121 if (lppd
->Flags
& PD_DISABLEPRINTTOFILE
)
1122 EnableWindow(GetDlgItem(hDlg
, chx1
), FALSE
);
1123 if (lppd
->Flags
& PD_HIDEPRINTTOFILE
)
1124 ShowWindow(GetDlgItem(hDlg
, chx1
), SW_HIDE
);
1126 } else { /* PD_PRINTSETUP */
1127 BOOL bPortrait
= (lpdm
->u1
.s1
.dmOrientation
== DMORIENT_PORTRAIT
);
1129 PRINTDLG_SetUpPaperComboBoxW(hDlg
, cmb2
,
1130 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1131 PrintStructures
->lpPrinterInfo
->pPortName
,
1133 PRINTDLG_SetUpPaperComboBoxW(hDlg
, cmb3
,
1134 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1135 PrintStructures
->lpPrinterInfo
->pPortName
,
1137 CheckRadioButton(hDlg
, rad1
, rad2
, bPortrait
? rad1
: rad2
);
1138 SendDlgItemMessageW(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1139 (LPARAM
)(bPortrait
? PrintStructures
->hPortraitIcon
:
1140 PrintStructures
->hLandscapeIcon
));
1145 if ((lppd
->Flags
& PD_SHOWHELP
)==0) {
1146 /* hide if PD_SHOWHELP not specified */
1147 ShowWindow(GetDlgItem(hDlg
, pshHelp
), SW_HIDE
);
1152 /***********************************************************************
1153 * PRINTDLG_WMInitDialog [internal]
1155 static LRESULT
PRINTDLG_WMInitDialog(HWND hDlg
, WPARAM wParam
,
1156 PRINT_PTRA
* PrintStructures
)
1158 LPPRINTDLGA lppd
= PrintStructures
->lpPrintDlg
;
1162 UINT comboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1164 /* load Collate ICONs */
1165 /* We load these with LoadImage because they are not a standard
1166 size and we don't want them rescaled */
1167 PrintStructures
->hCollateIcon
=
1168 LoadImageA(COMDLG32_hInstance
, "PD32_COLLATE", IMAGE_ICON
, 0, 0, 0);
1169 PrintStructures
->hNoCollateIcon
=
1170 LoadImageA(COMDLG32_hInstance
, "PD32_NOCOLLATE", IMAGE_ICON
, 0, 0, 0);
1172 /* These can be done with LoadIcon */
1173 PrintStructures
->hPortraitIcon
=
1174 LoadIconA(COMDLG32_hInstance
, "PD32_PORTRAIT");
1175 PrintStructures
->hLandscapeIcon
=
1176 LoadIconA(COMDLG32_hInstance
, "PD32_LANDSCAPE");
1178 /* display the collate/no_collate icon */
1179 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1180 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1182 if(PrintStructures
->hCollateIcon
== 0 ||
1183 PrintStructures
->hNoCollateIcon
== 0 ||
1184 PrintStructures
->hPortraitIcon
== 0 ||
1185 PrintStructures
->hLandscapeIcon
== 0) {
1186 ERR("no icon in resourcefile\n");
1187 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1188 EndDialog(hDlg
, FALSE
);
1192 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1193 * must be registered and the Help button must be shown.
1195 if (lppd
->Flags
& PD_SHOWHELP
) {
1196 if((PrintStructures
->HelpMessageID
=
1197 RegisterWindowMessageA(HELPMSGSTRINGA
)) == 0) {
1198 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL
);
1202 PrintStructures
->HelpMessageID
= 0;
1204 if(!(lppd
->Flags
&PD_PRINTSETUP
)) {
1205 PrintStructures
->hwndUpDown
=
1206 CreateUpDownControl(WS_CHILD
| WS_VISIBLE
| WS_BORDER
|
1207 UDS_NOTHOUSANDS
| UDS_ARROWKEYS
|
1208 UDS_ALIGNRIGHT
| UDS_SETBUDDYINT
, 0, 0, 0, 0,
1209 hDlg
, UPDOWN_ID
, COMDLG32_hInstance
,
1210 GetDlgItem(hDlg
, edt3
), MAX_COPIES
, 1, 1);
1213 /* FIXME: I allow more freedom than either Win95 or WinNT,
1214 * which do not agree to what errors should be thrown or not
1215 * in case nToPage or nFromPage is out-of-range.
1217 if (lppd
->nMaxPage
< lppd
->nMinPage
)
1218 lppd
->nMaxPage
= lppd
->nMinPage
;
1219 if (lppd
->nMinPage
== lppd
->nMaxPage
)
1220 lppd
->Flags
|= PD_NOPAGENUMS
;
1221 if (lppd
->nToPage
< lppd
->nMinPage
)
1222 lppd
->nToPage
= lppd
->nMinPage
;
1223 if (lppd
->nToPage
> lppd
->nMaxPage
)
1224 lppd
->nToPage
= lppd
->nMaxPage
;
1225 if (lppd
->nFromPage
< lppd
->nMinPage
)
1226 lppd
->nFromPage
= lppd
->nMinPage
;
1227 if (lppd
->nFromPage
> lppd
->nMaxPage
)
1228 lppd
->nFromPage
= lppd
->nMaxPage
;
1230 /* if we have the combo box, fill it */
1231 if (GetDlgItem(hDlg
,comboID
)) {
1234 pdn
= GlobalLock(lppd
->hDevNames
);
1235 pdm
= GlobalLock(lppd
->hDevMode
);
1237 name
= (char*)pdn
+ pdn
->wDeviceOffset
;
1239 name
= pdm
->dmDeviceName
;
1240 PRINTDLG_SetUpPrinterListComboA(hDlg
, comboID
, name
);
1241 if(pdm
) GlobalUnlock(lppd
->hDevMode
);
1242 if(pdn
) GlobalUnlock(lppd
->hDevNames
);
1244 /* Now find selected printer and update rest of dlg */
1245 name
= HeapAlloc(GetProcessHeap(),0,256);
1246 if (GetDlgItemTextA(hDlg
, comboID
, name
, 255))
1247 PRINTDLG_ChangePrinterA(hDlg
, name
, PrintStructures
);
1248 HeapFree(GetProcessHeap(),0,name
);
1250 /* else use default printer */
1252 DWORD dwBufLen
= sizeof(name
);
1253 BOOL ret
= GetDefaultPrinterA(name
, &dwBufLen
);
1256 PRINTDLG_ChangePrinterA(hDlg
, name
, PrintStructures
);
1258 FIXME("No default printer found, expect problems!\n");
1263 static LRESULT
PRINTDLG_WMInitDialogW(HWND hDlg
, WPARAM wParam
,
1264 PRINT_PTRW
* PrintStructures
)
1266 const static WCHAR PD32_COLLATE
[] = { 'P', 'D', '3', '2', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E', 0 };
1267 const static WCHAR PD32_NOCOLLATE
[] = { 'P', 'D', '3', '2', '_', 'N', 'O', 'C', 'O', 'L', 'L', 'A', 'T', 'E', 0 };
1268 const static WCHAR PD32_PORTRAIT
[] = { 'P', 'D', '3', '2', '_', 'P', 'O', 'R', 'T', 'R', 'A', 'I', 'T', 0 };
1269 const static WCHAR PD32_LANDSCAPE
[] = { 'P', 'D', '3', '2', '_', 'L', 'A', 'N', 'D', 'S', 'C', 'A', 'P', 'E', 0 };
1270 LPPRINTDLGW lppd
= PrintStructures
->lpPrintDlg
;
1274 UINT comboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1276 /* load Collate ICONs */
1277 /* We load these with LoadImage because they are not a standard
1278 size and we don't want them rescaled */
1279 PrintStructures
->hCollateIcon
=
1280 LoadImageW(COMDLG32_hInstance
, PD32_COLLATE
, IMAGE_ICON
, 0, 0, 0);
1281 PrintStructures
->hNoCollateIcon
=
1282 LoadImageW(COMDLG32_hInstance
, PD32_NOCOLLATE
, IMAGE_ICON
, 0, 0, 0);
1284 /* These can be done with LoadIcon */
1285 PrintStructures
->hPortraitIcon
=
1286 LoadIconW(COMDLG32_hInstance
, PD32_PORTRAIT
);
1287 PrintStructures
->hLandscapeIcon
=
1288 LoadIconW(COMDLG32_hInstance
, PD32_LANDSCAPE
);
1290 /* display the collate/no_collate icon */
1291 SendDlgItemMessageW(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1292 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1294 if(PrintStructures
->hCollateIcon
== 0 ||
1295 PrintStructures
->hNoCollateIcon
== 0 ||
1296 PrintStructures
->hPortraitIcon
== 0 ||
1297 PrintStructures
->hLandscapeIcon
== 0) {
1298 ERR("no icon in resourcefile\n");
1299 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1300 EndDialog(hDlg
, FALSE
);
1304 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1305 * must be registered and the Help button must be shown.
1307 if (lppd
->Flags
& PD_SHOWHELP
) {
1308 if((PrintStructures
->HelpMessageID
=
1309 RegisterWindowMessageW(HELPMSGSTRINGW
)) == 0) {
1310 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL
);
1314 PrintStructures
->HelpMessageID
= 0;
1316 if(!(lppd
->Flags
&PD_PRINTSETUP
)) {
1317 PrintStructures
->hwndUpDown
=
1318 CreateUpDownControl(WS_CHILD
| WS_VISIBLE
| WS_BORDER
|
1319 UDS_NOTHOUSANDS
| UDS_ARROWKEYS
|
1320 UDS_ALIGNRIGHT
| UDS_SETBUDDYINT
, 0, 0, 0, 0,
1321 hDlg
, UPDOWN_ID
, COMDLG32_hInstance
,
1322 GetDlgItem(hDlg
, edt3
), MAX_COPIES
, 1, 1);
1325 /* FIXME: I allow more freedom than either Win95 or WinNT,
1326 * which do not agree to what errors should be thrown or not
1327 * in case nToPage or nFromPage is out-of-range.
1329 if (lppd
->nMaxPage
< lppd
->nMinPage
)
1330 lppd
->nMaxPage
= lppd
->nMinPage
;
1331 if (lppd
->nMinPage
== lppd
->nMaxPage
)
1332 lppd
->Flags
|= PD_NOPAGENUMS
;
1333 if (lppd
->nToPage
< lppd
->nMinPage
)
1334 lppd
->nToPage
= lppd
->nMinPage
;
1335 if (lppd
->nToPage
> lppd
->nMaxPage
)
1336 lppd
->nToPage
= lppd
->nMaxPage
;
1337 if (lppd
->nFromPage
< lppd
->nMinPage
)
1338 lppd
->nFromPage
= lppd
->nMinPage
;
1339 if (lppd
->nFromPage
> lppd
->nMaxPage
)
1340 lppd
->nFromPage
= lppd
->nMaxPage
;
1342 /* if we have the combo box, fill it */
1343 if (GetDlgItem(hDlg
,comboID
)) {
1346 pdn
= GlobalLock(lppd
->hDevNames
);
1347 pdm
= GlobalLock(lppd
->hDevMode
);
1349 name
= (WCHAR
*)pdn
+ pdn
->wDeviceOffset
;
1351 name
= pdm
->dmDeviceName
;
1352 PRINTDLG_SetUpPrinterListComboW(hDlg
, comboID
, name
);
1353 if(pdm
) GlobalUnlock(lppd
->hDevMode
);
1354 if(pdn
) GlobalUnlock(lppd
->hDevNames
);
1356 /* Now find selected printer and update rest of dlg */
1357 /* ansi is ok here */
1358 name
= HeapAlloc(GetProcessHeap(),0,256*sizeof(WCHAR
));
1359 if (GetDlgItemTextW(hDlg
, comboID
, name
, 255))
1360 PRINTDLG_ChangePrinterW(hDlg
, name
, PrintStructures
);
1361 HeapFree(GetProcessHeap(),0,name
);
1363 /* else use default printer */
1365 DWORD dwBufLen
= sizeof(name
) / sizeof(WCHAR
);
1366 BOOL ret
= GetDefaultPrinterW(name
, &dwBufLen
);
1369 PRINTDLG_ChangePrinterW(hDlg
, name
, PrintStructures
);
1371 FIXME("No default printer found, expect problems!\n");
1376 /***********************************************************************
1377 * PRINTDLG_WMCommand [internal]
1379 LRESULT
PRINTDLG_WMCommandA(HWND hDlg
, WPARAM wParam
,
1380 LPARAM lParam
, PRINT_PTRA
* PrintStructures
)
1382 LPPRINTDLGA lppd
= PrintStructures
->lpPrintDlg
;
1383 UINT PrinterComboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1384 LPDEVMODEA lpdm
= PrintStructures
->lpDevMode
;
1386 switch (LOWORD(wParam
)) {
1388 TRACE(" OK button was hit\n");
1389 if (!PRINTDLG_UpdatePrintDlgA(hDlg
, PrintStructures
)) {
1390 FIXME("Update printdlg was not successful!\n");
1393 EndDialog(hDlg
, TRUE
);
1397 TRACE(" CANCEL button was hit\n");
1398 EndDialog(hDlg
, FALSE
);
1402 TRACE(" HELP button was hit\n");
1403 SendMessageA(lppd
->hwndOwner
, PrintStructures
->HelpMessageID
,
1404 (WPARAM
) hDlg
, (LPARAM
) lppd
);
1407 case chx2
: /* collate pages checkbox */
1408 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
1409 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1410 (LPARAM
)PrintStructures
->hCollateIcon
);
1412 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1413 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1415 case edt1
: /* from page nr editbox */
1416 case edt2
: /* to page nr editbox */
1417 if (HIWORD(wParam
)==EN_CHANGE
) {
1420 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
1421 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
1422 if (nFromPage
!= lppd
->nFromPage
|| nToPage
!= lppd
->nToPage
)
1423 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1428 if(HIWORD(wParam
) == EN_CHANGE
) {
1429 INT copies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
1431 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1433 EnableWindow(GetDlgItem(hDlg
, chx2
), TRUE
);
1438 case psh1
: /* Print Setup */
1442 if (!PrintStructures
->dlg
.lpPrintDlg16
) {
1443 FIXME("The 32bit print dialog does not have this button!?\n");
1447 memcpy(&pdlg
,PrintStructures
->dlg
.lpPrintDlg16
,sizeof(pdlg
));
1448 pdlg
.Flags
|= PD_PRINTSETUP
;
1449 pdlg
.hwndOwner
= HWND_16(hDlg
);
1450 if (!PrintDlg16(&pdlg
))
1455 case psh2
: /* Properties button */
1458 char PrinterName
[256];
1460 GetDlgItemTextA(hDlg
, PrinterComboID
, PrinterName
, 255);
1461 if (!OpenPrinterA(PrinterName
, &hPrinter
, NULL
)) {
1462 FIXME(" Call to OpenPrinter did not succeed!\n");
1465 DocumentPropertiesA(hDlg
, hPrinter
, PrinterName
,
1466 PrintStructures
->lpDevMode
,
1467 PrintStructures
->lpDevMode
,
1468 DM_IN_BUFFER
| DM_OUT_BUFFER
| DM_IN_PROMPT
);
1469 ClosePrinter(hPrinter
);
1473 case rad1
: /* Paperorientation */
1474 if (lppd
->Flags
& PD_PRINTSETUP
)
1476 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1477 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1478 (LPARAM
)(PrintStructures
->hPortraitIcon
));
1482 case rad2
: /* Paperorientation */
1483 if (lppd
->Flags
& PD_PRINTSETUP
)
1485 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1486 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1487 (LPARAM
)(PrintStructures
->hLandscapeIcon
));
1491 case cmb1
: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */
1492 if (PrinterComboID
!= LOWORD(wParam
)) {
1493 FIXME("No handling for print quality combo box yet.\n");
1497 case cmb4
: /* Printer combobox */
1498 if (HIWORD(wParam
)==CBN_SELCHANGE
) {
1499 char PrinterName
[256];
1500 GetDlgItemTextA(hDlg
, LOWORD(wParam
), PrinterName
, 255);
1501 PRINTDLG_ChangePrinterA(hDlg
, PrinterName
, PrintStructures
);
1505 case cmb2
: /* Papersize */
1507 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
1509 lpdm
->u1
.s1
.dmPaperSize
= SendDlgItemMessageA(hDlg
, cmb2
,
1515 case cmb3
: /* Bin */
1517 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
1519 lpdm
->dmDefaultSource
= SendDlgItemMessageA(hDlg
, cmb3
,
1520 CB_GETITEMDATA
, Sel
,
1525 if(lppd
->Flags
& PD_PRINTSETUP
) {
1526 switch (LOWORD(wParam
)) {
1527 case rad1
: /* orientation */
1529 if (IsDlgButtonChecked(hDlg
, rad1
) == BST_CHECKED
) {
1530 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_PORTRAIT
) {
1531 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1532 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1534 (LPARAM
)PrintStructures
->hPortraitIcon
);
1535 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1537 (LPARAM
)PrintStructures
->hPortraitIcon
);
1540 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_LANDSCAPE
) {
1541 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1542 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1544 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1545 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1547 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1556 static LRESULT
PRINTDLG_WMCommandW(HWND hDlg
, WPARAM wParam
,
1557 LPARAM lParam
, PRINT_PTRW
* PrintStructures
)
1559 LPPRINTDLGW lppd
= PrintStructures
->lpPrintDlg
;
1560 UINT PrinterComboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1561 LPDEVMODEW lpdm
= PrintStructures
->lpDevMode
;
1563 switch (LOWORD(wParam
)) {
1565 TRACE(" OK button was hit\n");
1566 if (!PRINTDLG_UpdatePrintDlgW(hDlg
, PrintStructures
)) {
1567 FIXME("Update printdlg was not successful!\n");
1570 EndDialog(hDlg
, TRUE
);
1574 TRACE(" CANCEL button was hit\n");
1575 EndDialog(hDlg
, FALSE
);
1579 TRACE(" HELP button was hit\n");
1580 SendMessageW(lppd
->hwndOwner
, PrintStructures
->HelpMessageID
,
1581 (WPARAM
) hDlg
, (LPARAM
) lppd
);
1584 case chx2
: /* collate pages checkbox */
1585 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
1586 SendDlgItemMessageW(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1587 (LPARAM
)PrintStructures
->hCollateIcon
);
1589 SendDlgItemMessageW(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1590 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1592 case edt1
: /* from page nr editbox */
1593 case edt2
: /* to page nr editbox */
1594 if (HIWORD(wParam
)==EN_CHANGE
) {
1597 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
1598 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
1599 if (nFromPage
!= lppd
->nFromPage
|| nToPage
!= lppd
->nToPage
)
1600 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1605 if(HIWORD(wParam
) == EN_CHANGE
) {
1606 INT copies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
1608 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1610 EnableWindow(GetDlgItem(hDlg
, chx2
), TRUE
);
1614 case psh1
: /* Print Setup */
1616 ERR("psh1 is called from 16bit code only, we should not get here.\n");
1619 case psh2
: /* Properties button */
1622 WCHAR PrinterName
[256];
1624 if (!GetDlgItemTextW(hDlg
, PrinterComboID
, PrinterName
, 255)) break;
1625 if (!OpenPrinterW(PrinterName
, &hPrinter
, NULL
)) {
1626 FIXME(" Call to OpenPrinter did not succeed!\n");
1629 DocumentPropertiesW(hDlg
, hPrinter
, PrinterName
,
1630 PrintStructures
->lpDevMode
,
1631 PrintStructures
->lpDevMode
,
1632 DM_IN_BUFFER
| DM_OUT_BUFFER
| DM_IN_PROMPT
);
1633 ClosePrinter(hPrinter
);
1637 case rad1
: /* Paperorientation */
1638 if (lppd
->Flags
& PD_PRINTSETUP
)
1640 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1641 SendDlgItemMessageW(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1642 (LPARAM
)(PrintStructures
->hPortraitIcon
));
1646 case rad2
: /* Paperorientation */
1647 if (lppd
->Flags
& PD_PRINTSETUP
)
1649 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1650 SendDlgItemMessageW(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1651 (LPARAM
)(PrintStructures
->hLandscapeIcon
));
1655 case cmb1
: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */
1656 if (PrinterComboID
!= LOWORD(wParam
)) {
1657 FIXME("No handling for print quality combo box yet.\n");
1661 case cmb4
: /* Printer combobox */
1662 if (HIWORD(wParam
)==CBN_SELCHANGE
) {
1663 WCHAR PrinterName
[256];
1664 GetDlgItemTextW(hDlg
, LOWORD(wParam
), PrinterName
, 255);
1665 PRINTDLG_ChangePrinterW(hDlg
, PrinterName
, PrintStructures
);
1669 case cmb2
: /* Papersize */
1671 DWORD Sel
= SendDlgItemMessageW(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
1673 lpdm
->u1
.s1
.dmPaperSize
= SendDlgItemMessageW(hDlg
, cmb2
,
1679 case cmb3
: /* Bin */
1681 DWORD Sel
= SendDlgItemMessageW(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
1683 lpdm
->dmDefaultSource
= SendDlgItemMessageW(hDlg
, cmb3
,
1684 CB_GETITEMDATA
, Sel
,
1689 if(lppd
->Flags
& PD_PRINTSETUP
) {
1690 switch (LOWORD(wParam
)) {
1691 case rad1
: /* orientation */
1693 if (IsDlgButtonChecked(hDlg
, rad1
) == BST_CHECKED
) {
1694 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_PORTRAIT
) {
1695 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1696 SendDlgItemMessageW(hDlg
, stc10
, STM_SETIMAGE
,
1698 (LPARAM
)PrintStructures
->hPortraitIcon
);
1699 SendDlgItemMessageW(hDlg
, ico1
, STM_SETIMAGE
,
1701 (LPARAM
)PrintStructures
->hPortraitIcon
);
1704 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_LANDSCAPE
) {
1705 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1706 SendDlgItemMessageW(hDlg
, stc10
, STM_SETIMAGE
,
1708 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1709 SendDlgItemMessageW(hDlg
, ico1
, STM_SETIMAGE
,
1711 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1720 /***********************************************************************
1721 * PrintDlgProcA [internal]
1723 static INT_PTR CALLBACK
PrintDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
1726 PRINT_PTRA
* PrintStructures
;
1727 INT_PTR res
= FALSE
;
1729 if (uMsg
!=WM_INITDIALOG
) {
1730 PrintStructures
= (PRINT_PTRA
*)GetPropA(hDlg
,"__WINE_PRINTDLGDATA");
1731 if (!PrintStructures
)
1734 PrintStructures
= (PRINT_PTRA
*) lParam
;
1735 SetPropA(hDlg
,"__WINE_PRINTDLGDATA",PrintStructures
);
1736 res
= PRINTDLG_WMInitDialog(hDlg
, wParam
, PrintStructures
);
1738 if(PrintStructures
->lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
)
1739 res
= PrintStructures
->lpPrintDlg
->lpfnPrintHook(
1740 hDlg
, uMsg
, wParam
, (LPARAM
)PrintStructures
->lpPrintDlg
1745 if(PrintStructures
->lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
) {
1746 res
= PrintStructures
->lpPrintDlg
->lpfnPrintHook(hDlg
,uMsg
,wParam
,
1753 return PRINTDLG_WMCommandA(hDlg
, wParam
, lParam
, PrintStructures
);
1756 DestroyIcon(PrintStructures
->hCollateIcon
);
1757 DestroyIcon(PrintStructures
->hNoCollateIcon
);
1758 DestroyIcon(PrintStructures
->hPortraitIcon
);
1759 DestroyIcon(PrintStructures
->hLandscapeIcon
);
1760 if(PrintStructures
->hwndUpDown
)
1761 DestroyWindow(PrintStructures
->hwndUpDown
);
1767 static INT_PTR CALLBACK
PrintDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
1770 static const WCHAR propW
[] = {'_','_','W','I','N','E','_','P','R','I','N','T','D','L','G','D','A','T','A',0};
1771 PRINT_PTRW
* PrintStructures
;
1772 INT_PTR res
= FALSE
;
1774 if (uMsg
!=WM_INITDIALOG
) {
1775 PrintStructures
= (PRINT_PTRW
*) GetPropW(hDlg
, propW
);
1776 if (!PrintStructures
)
1779 PrintStructures
= (PRINT_PTRW
*) lParam
;
1780 SetPropW(hDlg
, propW
, PrintStructures
);
1781 res
= PRINTDLG_WMInitDialogW(hDlg
, wParam
, PrintStructures
);
1783 if(PrintStructures
->lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
)
1784 res
= PrintStructures
->lpPrintDlg
->lpfnPrintHook(hDlg
, uMsg
, wParam
, (LPARAM
)PrintStructures
->lpPrintDlg
);
1788 if(PrintStructures
->lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
) {
1789 res
= PrintStructures
->lpPrintDlg
->lpfnPrintHook(hDlg
,uMsg
,wParam
, lParam
);
1795 return PRINTDLG_WMCommandW(hDlg
, wParam
, lParam
, PrintStructures
);
1798 DestroyIcon(PrintStructures
->hCollateIcon
);
1799 DestroyIcon(PrintStructures
->hNoCollateIcon
);
1800 DestroyIcon(PrintStructures
->hPortraitIcon
);
1801 DestroyIcon(PrintStructures
->hLandscapeIcon
);
1802 if(PrintStructures
->hwndUpDown
)
1803 DestroyWindow(PrintStructures
->hwndUpDown
);
1809 /************************************************************
1811 * PRINTDLG_GetDlgTemplate
1814 static HGLOBAL
PRINTDLG_GetDlgTemplateA(PRINTDLGA
*lppd
)
1819 if (lppd
->Flags
& PD_PRINTSETUP
) {
1820 if(lppd
->Flags
& PD_ENABLESETUPTEMPLATEHANDLE
) {
1821 hDlgTmpl
= lppd
->hSetupTemplate
;
1822 } else if(lppd
->Flags
& PD_ENABLESETUPTEMPLATE
) {
1823 hResInfo
= FindResourceA(lppd
->hInstance
,
1824 lppd
->lpSetupTemplateName
, (LPSTR
)RT_DIALOG
);
1825 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
1827 hResInfo
= FindResourceA(COMDLG32_hInstance
, "PRINT32_SETUP",
1829 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
1832 if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATEHANDLE
) {
1833 hDlgTmpl
= lppd
->hPrintTemplate
;
1834 } else if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATE
) {
1835 hResInfo
= FindResourceA(lppd
->hInstance
,
1836 lppd
->lpPrintTemplateName
,
1838 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
1840 hResInfo
= FindResourceA(COMDLG32_hInstance
, "PRINT32",
1842 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
1848 static HGLOBAL
PRINTDLG_GetDlgTemplateW(PRINTDLGW
*lppd
)
1852 static const WCHAR xpsetup
[] = { 'P','R','I','N','T','3','2','_','S','E','T','U','P',0};
1853 static const WCHAR xprint
[] = { 'P','R','I','N','T','3','2',0};
1855 if (lppd
->Flags
& PD_PRINTSETUP
) {
1856 if(lppd
->Flags
& PD_ENABLESETUPTEMPLATEHANDLE
) {
1857 hDlgTmpl
= lppd
->hSetupTemplate
;
1858 } else if(lppd
->Flags
& PD_ENABLESETUPTEMPLATE
) {
1859 hResInfo
= FindResourceW(lppd
->hInstance
,
1860 lppd
->lpSetupTemplateName
, (LPWSTR
)RT_DIALOG
);
1861 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
1863 hResInfo
= FindResourceW(COMDLG32_hInstance
, xpsetup
, (LPWSTR
)RT_DIALOG
);
1864 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
1867 if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATEHANDLE
) {
1868 hDlgTmpl
= lppd
->hPrintTemplate
;
1869 } else if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATE
) {
1870 hResInfo
= FindResourceW(lppd
->hInstance
,
1871 lppd
->lpPrintTemplateName
,
1873 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
1875 hResInfo
= FindResourceW(COMDLG32_hInstance
, xprint
, (LPWSTR
)RT_DIALOG
);
1876 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
1882 /***********************************************************************
1887 static BOOL
PRINTDLG_CreateDCA(LPPRINTDLGA lppd
)
1889 DEVNAMES
*pdn
= GlobalLock(lppd
->hDevNames
);
1890 DEVMODEA
*pdm
= GlobalLock(lppd
->hDevMode
);
1892 if(lppd
->Flags
& PD_RETURNDC
) {
1893 lppd
->hDC
= CreateDCA((char*)pdn
+ pdn
->wDriverOffset
,
1894 (char*)pdn
+ pdn
->wDeviceOffset
,
1895 (char*)pdn
+ pdn
->wOutputOffset
,
1897 } else if(lppd
->Flags
& PD_RETURNIC
) {
1898 lppd
->hDC
= CreateICA((char*)pdn
+ pdn
->wDriverOffset
,
1899 (char*)pdn
+ pdn
->wDeviceOffset
,
1900 (char*)pdn
+ pdn
->wOutputOffset
,
1903 GlobalUnlock(lppd
->hDevNames
);
1904 GlobalUnlock(lppd
->hDevMode
);
1905 return lppd
->hDC
? TRUE
: FALSE
;
1908 static BOOL
PRINTDLG_CreateDCW(LPPRINTDLGW lppd
)
1910 DEVNAMES
*pdn
= GlobalLock(lppd
->hDevNames
);
1911 DEVMODEW
*pdm
= GlobalLock(lppd
->hDevMode
);
1913 if(lppd
->Flags
& PD_RETURNDC
) {
1914 lppd
->hDC
= CreateDCW((WCHAR
*)pdn
+ pdn
->wDriverOffset
,
1915 (WCHAR
*)pdn
+ pdn
->wDeviceOffset
,
1916 (WCHAR
*)pdn
+ pdn
->wOutputOffset
,
1918 } else if(lppd
->Flags
& PD_RETURNIC
) {
1919 lppd
->hDC
= CreateICW((WCHAR
*)pdn
+ pdn
->wDriverOffset
,
1920 (WCHAR
*)pdn
+ pdn
->wDeviceOffset
,
1921 (WCHAR
*)pdn
+ pdn
->wOutputOffset
,
1924 GlobalUnlock(lppd
->hDevNames
);
1925 GlobalUnlock(lppd
->hDevMode
);
1926 return lppd
->hDC
? TRUE
: FALSE
;
1929 /***********************************************************************
1930 * PrintDlgA (COMDLG32.@)
1932 * Displays the the PRINT dialog box, which enables the user to specify
1933 * specific properties of the print job.
1936 * nonzero if the user pressed the OK button
1937 * zero if the user cancelled the window or an error occurred
1941 * * The Collate Icons do not display, even though they are in the code.
1942 * * The Properties Button(s) should call DocumentPropertiesA().
1944 * * The Paper Orientation Icons are not implemented yet.
1945 * * The Properties Button(s) should call DocumentPropertiesA().
1946 * * Settings are not yet taken from a provided DevMode or
1947 * default printer settings.
1950 BOOL WINAPI
PrintDlgA(
1951 LPPRINTDLGA lppd
/* [in/out] ptr to PRINTDLG32 struct */
1956 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongPtrA( lppd
->hwndOwner
, GWLP_HINSTANCE
);
1958 if(TRACE_ON(commdlg
)) {
1959 char flagstr
[1000] = "";
1960 struct pd_flags
*pflag
= pd_flags
;
1961 for( ; pflag
->name
; pflag
++) {
1962 if(lppd
->Flags
& pflag
->flag
)
1963 strcat(flagstr
, pflag
->name
);
1965 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
1966 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
1967 "flags %08lx (%s)\n",
1968 lppd
, lppd
->hwndOwner
, lppd
->hDevMode
, lppd
->hDevNames
,
1969 lppd
->nFromPage
, lppd
->nToPage
, lppd
->nMinPage
, lppd
->nMaxPage
,
1970 lppd
->nCopies
, lppd
->hInstance
, lppd
->Flags
, flagstr
);
1973 if(lppd
->lStructSize
!= sizeof(PRINTDLGA
)) {
1974 WARN("structure size failure !!!\n");
1975 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE
);
1979 if(lppd
->Flags
& PD_RETURNDEFAULT
) {
1980 PRINTER_INFO_2A
*pbuf
;
1981 DRIVER_INFO_3A
*dbuf
;
1985 if(lppd
->hDevMode
|| lppd
->hDevNames
) {
1986 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
1987 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
1990 if(!PRINTDLG_OpenDefaultPrinter(&hprn
)) {
1991 WARN("Can't find default printer\n");
1992 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN
);
1996 GetPrinterA(hprn
, 2, NULL
, 0, &needed
);
1997 pbuf
= HeapAlloc(GetProcessHeap(), 0, needed
);
1998 GetPrinterA(hprn
, 2, (LPBYTE
)pbuf
, needed
, &needed
);
2000 GetPrinterDriverA(hprn
, NULL
, 3, NULL
, 0, &needed
);
2001 dbuf
= HeapAlloc(GetProcessHeap(),0,needed
);
2002 if (!GetPrinterDriverA(hprn
, NULL
, 3, (LPBYTE
)dbuf
, needed
, &needed
)) {
2003 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf
->pPrinterName
);
2004 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2009 PRINTDLG_CreateDevNames(&(lppd
->hDevNames
),
2013 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
, pbuf
->pDevMode
->dmSize
+
2014 pbuf
->pDevMode
->dmDriverExtra
);
2015 ptr
= GlobalLock(lppd
->hDevMode
);
2016 memcpy(ptr
, pbuf
->pDevMode
, pbuf
->pDevMode
->dmSize
+
2017 pbuf
->pDevMode
->dmDriverExtra
);
2018 GlobalUnlock(lppd
->hDevMode
);
2019 HeapFree(GetProcessHeap(), 0, pbuf
);
2020 HeapFree(GetProcessHeap(), 0, dbuf
);
2024 PRINT_PTRA
*PrintStructures
;
2026 /* load Dialog resources,
2027 * depending on Flags indicates Print32 or Print32_setup dialog
2029 hDlgTmpl
= PRINTDLG_GetDlgTemplateA(lppd
);
2031 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2034 ptr
= LockResource( hDlgTmpl
);
2036 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2040 PrintStructures
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2041 sizeof(PRINT_PTRA
));
2042 PrintStructures
->lpPrintDlg
= lppd
;
2044 /* and create & process the dialog .
2045 * -1 is failure, 0 is broken hwnd, everything else is ok.
2047 bRet
= (0<DialogBoxIndirectParamA(hInst
, ptr
, lppd
->hwndOwner
,
2049 (LPARAM
)PrintStructures
));
2052 DEVMODEA
*lpdm
= PrintStructures
->lpDevMode
, *lpdmReturn
;
2053 PRINTER_INFO_2A
*pi
= PrintStructures
->lpPrinterInfo
;
2054 DRIVER_INFO_3A
*di
= PrintStructures
->lpDriverInfo
;
2056 if (lppd
->hDevMode
== 0) {
2057 TRACE(" No hDevMode yet... Need to create my own\n");
2058 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
,
2059 lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2062 if((locks
= (GlobalFlags(lppd
->hDevMode
) & GMEM_LOCKCOUNT
))) {
2063 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks
);
2065 GlobalUnlock(lppd
->hDevMode
);
2066 TRACE("Now got %d locks\n", locks
);
2069 lppd
->hDevMode
= GlobalReAlloc(lppd
->hDevMode
,
2070 lpdm
->dmSize
+ lpdm
->dmDriverExtra
,
2073 lpdmReturn
= GlobalLock(lppd
->hDevMode
);
2074 memcpy(lpdmReturn
, lpdm
, lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2076 if (lppd
->hDevNames
!= 0) {
2078 if((locks
= (GlobalFlags(lppd
->hDevNames
) & GMEM_LOCKCOUNT
))) {
2079 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks
);
2081 GlobalUnlock(lppd
->hDevNames
);
2084 PRINTDLG_CreateDevNames(&(lppd
->hDevNames
),
2089 GlobalUnlock(lppd
->hDevMode
);
2091 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
2092 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpPrinterInfo
);
2093 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDriverInfo
);
2094 HeapFree(GetProcessHeap(), 0, PrintStructures
);
2096 if(bRet
&& (lppd
->Flags
& PD_RETURNDC
|| lppd
->Flags
& PD_RETURNIC
))
2097 bRet
= PRINTDLG_CreateDCA(lppd
);
2099 TRACE("exit! (%d)\n", bRet
);
2103 /***********************************************************************
2104 * PrintDlgW (COMDLG32.@)
2106 BOOL WINAPI
PrintDlgW(
2107 LPPRINTDLGW lppd
/* [in/out] ptr to PRINTDLG32 struct */
2112 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongPtrW( lppd
->hwndOwner
, GWLP_HINSTANCE
);
2114 if(TRACE_ON(commdlg
)) {
2115 char flagstr
[1000] = "";
2116 struct pd_flags
*pflag
= pd_flags
;
2117 for( ; pflag
->name
; pflag
++) {
2118 if(lppd
->Flags
& pflag
->flag
)
2119 strcat(flagstr
, pflag
->name
);
2121 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2122 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
2123 "flags %08lx (%s)\n",
2124 lppd
, lppd
->hwndOwner
, lppd
->hDevMode
, lppd
->hDevNames
,
2125 lppd
->nFromPage
, lppd
->nToPage
, lppd
->nMinPage
, lppd
->nMaxPage
,
2126 lppd
->nCopies
, lppd
->hInstance
, lppd
->Flags
, flagstr
);
2129 if(lppd
->lStructSize
!= sizeof(PRINTDLGW
)) {
2130 WARN("structure size failure !!!\n");
2131 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE
);
2135 if(lppd
->Flags
& PD_RETURNDEFAULT
) {
2136 PRINTER_INFO_2W
*pbuf
;
2137 DRIVER_INFO_3W
*dbuf
;
2141 if(lppd
->hDevMode
|| lppd
->hDevNames
) {
2142 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
2143 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2146 if(!PRINTDLG_OpenDefaultPrinter(&hprn
)) {
2147 WARN("Can't find default printer\n");
2148 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN
);
2152 GetPrinterW(hprn
, 2, NULL
, 0, &needed
);
2153 pbuf
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*needed
);
2154 GetPrinterW(hprn
, 2, (LPBYTE
)pbuf
, needed
, &needed
);
2156 GetPrinterDriverW(hprn
, NULL
, 3, NULL
, 0, &needed
);
2157 dbuf
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
2158 if (!GetPrinterDriverW(hprn
, NULL
, 3, (LPBYTE
)dbuf
, needed
, &needed
)) {
2159 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),debugstr_w(pbuf
->pPrinterName
));
2160 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2165 PRINTDLG_CreateDevNamesW(&(lppd
->hDevNames
),
2169 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
, pbuf
->pDevMode
->dmSize
+
2170 pbuf
->pDevMode
->dmDriverExtra
);
2171 ptr
= GlobalLock(lppd
->hDevMode
);
2172 memcpy(ptr
, pbuf
->pDevMode
, pbuf
->pDevMode
->dmSize
+
2173 pbuf
->pDevMode
->dmDriverExtra
);
2174 GlobalUnlock(lppd
->hDevMode
);
2175 HeapFree(GetProcessHeap(), 0, pbuf
);
2176 HeapFree(GetProcessHeap(), 0, dbuf
);
2180 PRINT_PTRW
*PrintStructures
;
2182 /* load Dialog resources,
2183 * depending on Flags indicates Print32 or Print32_setup dialog
2185 hDlgTmpl
= PRINTDLG_GetDlgTemplateW(lppd
);
2187 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2190 ptr
= LockResource( hDlgTmpl
);
2192 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2196 PrintStructures
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2197 sizeof(PRINT_PTRW
));
2198 PrintStructures
->lpPrintDlg
= lppd
;
2200 /* and create & process the dialog .
2201 * -1 is failure, 0 is broken hwnd, everything else is ok.
2203 bRet
= (0<DialogBoxIndirectParamW(hInst
, ptr
, lppd
->hwndOwner
,
2205 (LPARAM
)PrintStructures
));
2208 DEVMODEW
*lpdm
= PrintStructures
->lpDevMode
, *lpdmReturn
;
2209 PRINTER_INFO_2W
*pi
= PrintStructures
->lpPrinterInfo
;
2210 DRIVER_INFO_3W
*di
= PrintStructures
->lpDriverInfo
;
2212 if (lppd
->hDevMode
== 0) {
2213 TRACE(" No hDevMode yet... Need to create my own\n");
2214 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
,
2215 lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2218 if((locks
= (GlobalFlags(lppd
->hDevMode
) & GMEM_LOCKCOUNT
))) {
2219 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks
);
2221 GlobalUnlock(lppd
->hDevMode
);
2222 TRACE("Now got %d locks\n", locks
);
2225 lppd
->hDevMode
= GlobalReAlloc(lppd
->hDevMode
,
2226 lpdm
->dmSize
+ lpdm
->dmDriverExtra
,
2229 lpdmReturn
= GlobalLock(lppd
->hDevMode
);
2230 memcpy(lpdmReturn
, lpdm
, lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2232 if (lppd
->hDevNames
!= 0) {
2234 if((locks
= (GlobalFlags(lppd
->hDevNames
) & GMEM_LOCKCOUNT
))) {
2235 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks
);
2237 GlobalUnlock(lppd
->hDevNames
);
2240 PRINTDLG_CreateDevNamesW(&(lppd
->hDevNames
),
2245 GlobalUnlock(lppd
->hDevMode
);
2247 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
2248 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpPrinterInfo
);
2249 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDriverInfo
);
2250 HeapFree(GetProcessHeap(), 0, PrintStructures
);
2252 if(bRet
&& (lppd
->Flags
& PD_RETURNDC
|| lppd
->Flags
& PD_RETURNIC
))
2253 bRet
= PRINTDLG_CreateDCW(lppd
);
2255 TRACE("exit! (%d)\n", bRet
);
2259 /***********************************************************************
2265 * cmb3 - source (tray?)
2266 * edt4 - border left
2268 * edt6 - border right
2269 * edt7 - border bottom
2270 * psh3 - "Printer..."
2274 LPPAGESETUPDLGA dlga
;
2279 LPPAGESETUPDLGW dlga
;
2283 static HGLOBAL
PRINTDLG_GetPGSTemplateA(PAGESETUPDLGA
*lppd
)
2288 if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATEHANDLE
) {
2289 hDlgTmpl
= lppd
->hPageSetupTemplate
;
2290 } else if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATE
) {
2291 hResInfo
= FindResourceA(lppd
->hInstance
,
2292 lppd
->lpPageSetupTemplateName
, (LPSTR
)RT_DIALOG
);
2293 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2295 hResInfo
= FindResourceA(COMDLG32_hInstance
,(LPCSTR
)PAGESETUPDLGORD
,(LPSTR
)RT_DIALOG
);
2296 hDlgTmpl
= LoadResource(COMDLG32_hInstance
,hResInfo
);
2301 static HGLOBAL
PRINTDLG_GetPGSTemplateW(PAGESETUPDLGW
*lppd
)
2306 if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATEHANDLE
) {
2307 hDlgTmpl
= lppd
->hPageSetupTemplate
;
2308 } else if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATE
) {
2309 hResInfo
= FindResourceW(lppd
->hInstance
,
2310 lppd
->lpPageSetupTemplateName
, (LPWSTR
)RT_DIALOG
);
2311 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2313 hResInfo
= FindResourceW(COMDLG32_hInstance
,(LPCWSTR
)PAGESETUPDLGORD
,(LPWSTR
)RT_DIALOG
);
2314 hDlgTmpl
= LoadResource(COMDLG32_hInstance
,hResInfo
);
2320 _c_10mm2size(PAGESETUPDLGA
*dlga
,DWORD size
) {
2321 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2322 return 10*size
*10/25.4;
2323 /* If we don't have a flag, we can choose one. Use millimeters
2324 * to avoid confusing me
2326 dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2332 _c_inch2size(PAGESETUPDLGA
*dlga
,DWORD size
) {
2333 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2335 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
)
2336 return (size
*254)/10;
2337 /* if we don't have a flag, we can choose one. Use millimeters
2338 * to avoid confusing me
2340 dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2341 return (size
*254)/10;
2345 _c_size2strA(PageSetupDataA
*pda
,DWORD size
,LPSTR strout
) {
2346 strcpy(strout
,"<undef>");
2347 if (pda
->dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2348 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2351 if (pda
->dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2352 sprintf(strout
,"%.2fin",(size
*1.0)/1000.0);
2355 pda
->dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2356 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2360 _c_size2strW(PageSetupDataW
*pda
,DWORD size
,LPWSTR strout
) {
2361 const static WCHAR UNDEF
[] = { '<', 'u', 'n', 'd', 'e', 'f', '>', 0 };
2362 const static WCHAR mm_fmt
[] = { '%', '.', '2', 'f', 'm', 'm', 0 };
2363 const static WCHAR in_fmt
[] = { '%', '.', '2', 'f', 'i', 'n', 0 };
2364 lstrcpyW(strout
, UNDEF
);
2365 if (pda
->dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2366 wsprintfW(strout
,mm_fmt
,(size
*1.0)/100.0);
2369 if (pda
->dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2370 wsprintfW(strout
,in_fmt
,(size
*1.0)/1000.0);
2373 pda
->dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2374 wsprintfW(strout
,mm_fmt
,(size
*1.0)/100.0);
2379 _c_str2sizeA(PAGESETUPDLGA
*dlga
,LPCSTR strin
) {
2384 if (!sscanf(strin
,"%f%s",&val
,rest
))
2387 if (!strcmp(rest
,"in") || !strcmp(rest
,"inch")) {
2388 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2391 return val
*25.4*100;
2393 if (!strcmp(rest
,"cm")) { rest
[0]='m'; val
= val
*10.0; }
2394 if (!strcmp(rest
,"m")) { strcpy(rest
,"mm"); val
= val
*1000.0; }
2396 if (!strcmp(rest
,"mm")) {
2397 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
)
2400 return 1000.0*val
/25.4;
2402 if (rest
[0]=='\0') {
2403 /* use application supplied default */
2404 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2408 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2413 ERR("Did not find a conversion for type '%s'!\n",rest
);
2419 _c_str2sizeW(PAGESETUPDLGW
*dlga
, LPCWSTR strin
) {
2422 /* this W -> A transition is OK */
2423 /* we need a unicode version of sscanf to avoid it */
2424 WideCharToMultiByte(CP_ACP
, 0, strin
, -1, buf
, sizeof(buf
), NULL
, NULL
);
2425 return _c_str2sizeA((PAGESETUPDLGA
*)dlga
, buf
);
2430 * This is called on finish and will update the output fields of the
2434 PRINTDLG_PS_UpdateDlgStructA(HWND hDlg
, PageSetupDataA
*pda
) {
2437 LPSTR devname
,portname
;
2441 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
2442 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
2443 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
2444 portname
= ((char*)dn
)+dn
->wOutputOffset
;
2445 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb2
,devname
,portname
,dm
);
2446 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb3
,devname
,portname
,dm
);
2448 if (GetDlgItemTextA(hDlg
,cmb2
,papername
,sizeof(papername
))>0) {
2449 PRINTDLG_PaperSizeA(&(pda
->pdlg
),papername
,&(pda
->dlga
->ptPaperSize
));
2450 pda
->dlga
->ptPaperSize
.x
= _c_10mm2size(pda
->dlga
,pda
->dlga
->ptPaperSize
.x
);
2451 pda
->dlga
->ptPaperSize
.y
= _c_10mm2size(pda
->dlga
,pda
->dlga
->ptPaperSize
.y
);
2453 FIXME("could not get dialog text for papersize cmbbox?\n");
2454 #define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2sizeA(pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }
2455 GETVAL(edt4
,pda
->dlga
->rtMargin
.left
);
2456 GETVAL(edt5
,pda
->dlga
->rtMargin
.top
);
2457 GETVAL(edt6
,pda
->dlga
->rtMargin
.right
);
2458 GETVAL(edt7
,pda
->dlga
->rtMargin
.bottom
);
2461 /* If we are in landscape, swap x and y of page size */
2462 if (IsDlgButtonChecked(hDlg
, rad2
)) {
2464 tmp
= pda
->dlga
->ptPaperSize
.x
;
2465 pda
->dlga
->ptPaperSize
.x
= pda
->dlga
->ptPaperSize
.y
;
2466 pda
->dlga
->ptPaperSize
.y
= tmp
;
2468 GlobalUnlock(pda
->pdlg
.hDevNames
);
2469 GlobalUnlock(pda
->pdlg
.hDevMode
);
2474 PRINTDLG_PS_UpdateDlgStructW(HWND hDlg
, PageSetupDataW
*pda
) {
2477 LPWSTR devname
,portname
;
2478 WCHAR papername
[64];
2481 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
2482 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
2483 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
2484 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
2485 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb2
,devname
,portname
,dm
);
2486 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb3
,devname
,portname
,dm
);
2488 if (GetDlgItemTextW(hDlg
,cmb2
,papername
,sizeof(papername
))>0) {
2489 PRINTDLG_PaperSizeW(&(pda
->pdlg
),papername
,&(pda
->dlga
->ptPaperSize
));
2490 pda
->dlga
->ptPaperSize
.x
= _c_10mm2size((LPPAGESETUPDLGA
)pda
->dlga
,pda
->dlga
->ptPaperSize
.x
);
2491 pda
->dlga
->ptPaperSize
.y
= _c_10mm2size((LPPAGESETUPDLGA
)pda
->dlga
,pda
->dlga
->ptPaperSize
.y
);
2493 FIXME("could not get dialog text for papersize cmbbox?\n");
2494 #define GETVAL(id,val) if (GetDlgItemTextW(hDlg,id,buf,sizeof(buf)/sizeof(buf[0]))>0) { val = _c_str2sizeW(pda->dlga,buf); } else { FIXME("could not get dlgitemtextw for %x\n",id); }
2495 GETVAL(edt4
,pda
->dlga
->rtMargin
.left
);
2496 GETVAL(edt5
,pda
->dlga
->rtMargin
.top
);
2497 GETVAL(edt6
,pda
->dlga
->rtMargin
.right
);
2498 GETVAL(edt7
,pda
->dlga
->rtMargin
.bottom
);
2501 /* If we are in landscape, swap x and y of page size */
2502 if (IsDlgButtonChecked(hDlg
, rad2
)) {
2504 tmp
= pda
->dlga
->ptPaperSize
.x
;
2505 pda
->dlga
->ptPaperSize
.x
= pda
->dlga
->ptPaperSize
.y
;
2506 pda
->dlga
->ptPaperSize
.y
= tmp
;
2508 GlobalUnlock(pda
->pdlg
.hDevNames
);
2509 GlobalUnlock(pda
->pdlg
.hDevMode
);
2514 * This is called after returning from PrintDlg().
2517 PRINTDLG_PS_ChangePrinterA(HWND hDlg
, PageSetupDataA
*pda
) {
2520 LPSTR devname
,portname
;
2522 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
2523 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
2524 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
2525 portname
= ((char*)dn
)+dn
->wOutputOffset
;
2526 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb2
,devname
,portname
,dm
);
2527 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb3
,devname
,portname
,dm
);
2528 GlobalUnlock(pda
->pdlg
.hDevNames
);
2529 GlobalUnlock(pda
->pdlg
.hDevMode
);
2534 PRINTDLG_PS_ChangePrinterW(HWND hDlg
, PageSetupDataW
*pda
) {
2537 LPWSTR devname
,portname
;
2539 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
2540 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
2541 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
2542 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
2543 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb2
,devname
,portname
,dm
);
2544 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb3
,devname
,portname
,dm
);
2545 GlobalUnlock(pda
->pdlg
.hDevNames
);
2546 GlobalUnlock(pda
->pdlg
.hDevMode
);
2551 PRINTDLG_PS_WMCommandA(
2552 HWND hDlg
, WPARAM wParam
, LPARAM lParam
, PageSetupDataA
*pda
2554 switch (LOWORD(wParam
)) {
2556 if (!PRINTDLG_PS_UpdateDlgStructA(hDlg
, pda
))
2558 EndDialog(hDlg
, TRUE
);
2562 EndDialog(hDlg
, FALSE
);
2566 pda
->pdlg
.Flags
= 0;
2567 pda
->pdlg
.hwndOwner
= hDlg
;
2568 if (PrintDlgA(&(pda
->pdlg
)))
2569 PRINTDLG_PS_ChangePrinterA(hDlg
,pda
);
2573 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
2574 LOWORD(lParam
),wParam
,lParam
2580 PRINTDLG_PS_WMCommandW(
2581 HWND hDlg
, WPARAM wParam
, LPARAM lParam
, PageSetupDataW
*pda
2583 switch (LOWORD(wParam
)) {
2585 if (!PRINTDLG_PS_UpdateDlgStructW(hDlg
, pda
))
2587 EndDialog(hDlg
, TRUE
);
2591 EndDialog(hDlg
, FALSE
);
2595 pda
->pdlg
.Flags
= 0;
2596 pda
->pdlg
.hwndOwner
= hDlg
;
2597 if (PrintDlgW(&(pda
->pdlg
)))
2598 PRINTDLG_PS_ChangePrinterW(hDlg
,pda
);
2602 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
2603 LOWORD(lParam
),wParam
,lParam
2609 static INT_PTR CALLBACK
2610 PageDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2612 PageSetupDataA
*pda
;
2613 INT_PTR res
= FALSE
;
2615 if (uMsg
==WM_INITDIALOG
) {
2617 pda
= (PageSetupDataA
*)lParam
;
2618 SetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA",pda
);
2619 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
2620 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,(LPARAM
)pda
->dlga
);
2622 FIXME("Setup page hook failed?\n");
2626 if (pda
->dlga
->Flags
& PSD_ENABLEPAGEPAINTHOOK
) {
2627 FIXME("PagePaintHook not yet implemented!\n");
2629 if (pda
->dlga
->Flags
& PSD_DISABLEPRINTER
)
2630 EnableWindow(GetDlgItem(hDlg
, psh3
), FALSE
);
2631 if (pda
->dlga
->Flags
& PSD_DISABLEMARGINS
) {
2632 EnableWindow(GetDlgItem(hDlg
, edt4
), FALSE
);
2633 EnableWindow(GetDlgItem(hDlg
, edt5
), FALSE
);
2634 EnableWindow(GetDlgItem(hDlg
, edt6
), FALSE
);
2635 EnableWindow(GetDlgItem(hDlg
, edt7
), FALSE
);
2637 /* width larger as height -> landscape */
2638 if (pda
->dlga
->ptPaperSize
.x
> pda
->dlga
->ptPaperSize
.y
)
2639 CheckRadioButton(hDlg
, rad1
, rad2
, rad2
);
2640 else /* this is default if papersize is not set */
2641 CheckRadioButton(hDlg
, rad1
, rad2
, rad1
);
2642 if (pda
->dlga
->Flags
& PSD_DISABLEORIENTATION
) {
2643 EnableWindow(GetDlgItem(hDlg
,rad1
),FALSE
);
2644 EnableWindow(GetDlgItem(hDlg
,rad2
),FALSE
);
2646 /* We fill them out enabled or not */
2647 if (pda
->dlga
->Flags
& PSD_MARGINS
) {
2649 _c_size2strA(pda
,pda
->dlga
->rtMargin
.left
,str
);
2650 SetDlgItemTextA(hDlg
,edt4
,str
);
2651 _c_size2strA(pda
,pda
->dlga
->rtMargin
.top
,str
);
2652 SetDlgItemTextA(hDlg
,edt5
,str
);
2653 _c_size2strA(pda
,pda
->dlga
->rtMargin
.right
,str
);
2654 SetDlgItemTextA(hDlg
,edt6
,str
);
2655 _c_size2strA(pda
,pda
->dlga
->rtMargin
.bottom
,str
);
2656 SetDlgItemTextA(hDlg
,edt7
,str
);
2658 /* default is 1 inch */
2659 DWORD size
= _c_inch2size(pda
->dlga
,1000);
2661 _c_size2strA(pda
,size
,str
);
2662 SetDlgItemTextA(hDlg
,edt4
,str
);
2663 SetDlgItemTextA(hDlg
,edt5
,str
);
2664 SetDlgItemTextA(hDlg
,edt6
,str
);
2665 SetDlgItemTextA(hDlg
,edt7
,str
);
2667 PRINTDLG_PS_ChangePrinterA(hDlg
,pda
);
2668 if (pda
->dlga
->Flags
& PSD_DISABLEPAPER
) {
2669 EnableWindow(GetDlgItem(hDlg
,cmb2
),FALSE
);
2670 EnableWindow(GetDlgItem(hDlg
,cmb3
),FALSE
);
2674 pda
= (PageSetupDataA
*)GetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA");
2676 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
2679 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
2680 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
2681 if (res
) return res
;
2686 return PRINTDLG_PS_WMCommandA(hDlg
, wParam
, lParam
, pda
);
2691 static INT_PTR CALLBACK
2692 PageDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2694 const static WCHAR __WINE_PAGESETUPDLGDATA
[] =
2695 { '_', '_', 'W', 'I', 'N', 'E', '_', 'P', 'A', 'G', 'E',
2696 'S', 'E', 'T', 'U', 'P', 'D', 'L', 'G', 'D', 'A', 'T', 'A', 0 };
2697 PageSetupDataW
*pda
;
2700 if (uMsg
==WM_INITDIALOG
) {
2702 pda
= (PageSetupDataW
*)lParam
;
2703 SetPropW(hDlg
, __WINE_PAGESETUPDLGDATA
, pda
);
2704 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
2705 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,(LPARAM
)pda
->dlga
);
2707 FIXME("Setup page hook failed?\n");
2711 if (pda
->dlga
->Flags
& PSD_ENABLEPAGEPAINTHOOK
) {
2712 FIXME("PagePaintHook not yet implemented!\n");
2714 if (pda
->dlga
->Flags
& PSD_DISABLEPRINTER
)
2715 EnableWindow(GetDlgItem(hDlg
, psh3
), FALSE
);
2716 if (pda
->dlga
->Flags
& PSD_DISABLEMARGINS
) {
2717 EnableWindow(GetDlgItem(hDlg
, edt4
), FALSE
);
2718 EnableWindow(GetDlgItem(hDlg
, edt5
), FALSE
);
2719 EnableWindow(GetDlgItem(hDlg
, edt6
), FALSE
);
2720 EnableWindow(GetDlgItem(hDlg
, edt7
), FALSE
);
2722 /* width larger as height -> landscape */
2723 if (pda
->dlga
->ptPaperSize
.x
> pda
->dlga
->ptPaperSize
.y
)
2724 CheckRadioButton(hDlg
, rad1
, rad2
, rad2
);
2725 else /* this is default if papersize is not set */
2726 CheckRadioButton(hDlg
, rad1
, rad2
, rad1
);
2727 if (pda
->dlga
->Flags
& PSD_DISABLEORIENTATION
) {
2728 EnableWindow(GetDlgItem(hDlg
,rad1
),FALSE
);
2729 EnableWindow(GetDlgItem(hDlg
,rad2
),FALSE
);
2731 /* We fill them out enabled or not */
2732 if (pda
->dlga
->Flags
& PSD_MARGINS
) {
2734 _c_size2strW(pda
,pda
->dlga
->rtMargin
.left
,str
);
2735 SetDlgItemTextW(hDlg
,edt4
,str
);
2736 _c_size2strW(pda
,pda
->dlga
->rtMargin
.top
,str
);
2737 SetDlgItemTextW(hDlg
,edt5
,str
);
2738 _c_size2strW(pda
,pda
->dlga
->rtMargin
.right
,str
);
2739 SetDlgItemTextW(hDlg
,edt6
,str
);
2740 _c_size2strW(pda
,pda
->dlga
->rtMargin
.bottom
,str
);
2741 SetDlgItemTextW(hDlg
,edt7
,str
);
2743 /* default is 1 inch */
2744 DWORD size
= _c_inch2size((LPPAGESETUPDLGA
)pda
->dlga
,1000);
2746 _c_size2strW(pda
,size
,str
);
2747 SetDlgItemTextW(hDlg
,edt4
,str
);
2748 SetDlgItemTextW(hDlg
,edt5
,str
);
2749 SetDlgItemTextW(hDlg
,edt6
,str
);
2750 SetDlgItemTextW(hDlg
,edt7
,str
);
2752 PRINTDLG_PS_ChangePrinterW(hDlg
,pda
);
2753 if (pda
->dlga
->Flags
& PSD_DISABLEPAPER
) {
2754 EnableWindow(GetDlgItem(hDlg
,cmb2
),FALSE
);
2755 EnableWindow(GetDlgItem(hDlg
,cmb3
),FALSE
);
2759 pda
= (PageSetupDataW
*)GetPropW(hDlg
, __WINE_PAGESETUPDLGDATA
);
2761 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
2764 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
2765 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
2766 if (res
) return res
;
2771 return PRINTDLG_PS_WMCommandW(hDlg
, wParam
, lParam
, pda
);
2776 /***********************************************************************
2777 * PageSetupDlgA (COMDLG32.@)
2779 BOOL WINAPI
PageSetupDlgA(LPPAGESETUPDLGA setupdlg
) {
2783 PageSetupDataA
*pda
;
2786 if(TRACE_ON(commdlg
)) {
2787 char flagstr
[1000] = "";
2788 struct pd_flags
*pflag
= psd_flags
;
2789 for( ; pflag
->name
; pflag
++) {
2790 if(setupdlg
->Flags
& pflag
->flag
) {
2791 strcat(flagstr
, pflag
->name
);
2792 strcat(flagstr
, "|");
2795 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2796 "hinst %p, flags %08lx (%s)\n",
2797 setupdlg
, setupdlg
->hwndOwner
, setupdlg
->hDevMode
,
2798 setupdlg
->hDevNames
,
2799 setupdlg
->hInstance
, setupdlg
->Flags
, flagstr
);
2802 /* First get default printer data, we need it right after that. */
2803 memset(&pdlg
,0,sizeof(pdlg
));
2804 pdlg
.lStructSize
= sizeof(pdlg
);
2805 pdlg
.Flags
= PD_RETURNDEFAULT
;
2806 bRet
= PrintDlgA(&pdlg
);
2807 if (!bRet
) return FALSE
;
2809 /* short cut exit, just return default values */
2810 if (setupdlg
->Flags
& PSD_RETURNDEFAULT
) {
2811 setupdlg
->hDevMode
= pdlg
.hDevMode
;
2812 setupdlg
->hDevNames
= pdlg
.hDevNames
;
2813 /* FIXME: Just return "A4" for now. */
2814 PRINTDLG_PaperSizeA(&pdlg
,"A4",&setupdlg
->ptPaperSize
);
2815 setupdlg
->ptPaperSize
.x
=_c_10mm2size(setupdlg
,setupdlg
->ptPaperSize
.x
);
2816 setupdlg
->ptPaperSize
.y
=_c_10mm2size(setupdlg
,setupdlg
->ptPaperSize
.y
);
2819 hDlgTmpl
= PRINTDLG_GetPGSTemplateA(setupdlg
);
2821 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2824 ptr
= LockResource( hDlgTmpl
);
2826 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2829 pda
= HeapAlloc(GetProcessHeap(),0,sizeof(*pda
));
2830 pda
->dlga
= setupdlg
;
2831 memcpy(&pda
->pdlg
,&pdlg
,sizeof(pdlg
));
2833 bRet
= (0<DialogBoxIndirectParamA(
2834 setupdlg
->hInstance
,
2836 setupdlg
->hwndOwner
,
2842 /***********************************************************************
2843 * PageSetupDlgW (COMDLG32.@)
2845 BOOL WINAPI
PageSetupDlgW(LPPAGESETUPDLGW setupdlg
) {
2849 PageSetupDataW
*pdw
;
2852 if(TRACE_ON(commdlg
)) {
2853 char flagstr
[1000] = "";
2854 struct pd_flags
*pflag
= psd_flags
;
2855 for( ; pflag
->name
; pflag
++) {
2856 if(setupdlg
->Flags
& pflag
->flag
) {
2857 strcat(flagstr
, pflag
->name
);
2858 strcat(flagstr
, "|");
2861 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2862 "hinst %p, flags %08lx (%s)\n",
2863 setupdlg
, setupdlg
->hwndOwner
, setupdlg
->hDevMode
,
2864 setupdlg
->hDevNames
,
2865 setupdlg
->hInstance
, setupdlg
->Flags
, flagstr
);
2868 /* First get default printer data, we need it right after that. */
2869 memset(&pdlg
,0,sizeof(pdlg
));
2870 pdlg
.lStructSize
= sizeof(pdlg
);
2871 pdlg
.Flags
= PD_RETURNDEFAULT
;
2872 bRet
= PrintDlgW(&pdlg
);
2873 if (!bRet
) return FALSE
;
2875 /* short cut exit, just return default values */
2876 if (setupdlg
->Flags
& PSD_RETURNDEFAULT
) {
2877 static const WCHAR a4
[] = {'A','4',0};
2878 setupdlg
->hDevMode
= pdlg
.hDevMode
;
2879 setupdlg
->hDevNames
= pdlg
.hDevNames
;
2880 /* FIXME: Just return "A4" for now. */
2881 PRINTDLG_PaperSizeW(&pdlg
,a4
,&setupdlg
->ptPaperSize
);
2882 setupdlg
->ptPaperSize
.x
=_c_10mm2size((LPPAGESETUPDLGA
)setupdlg
,setupdlg
->ptPaperSize
.x
);
2883 setupdlg
->ptPaperSize
.y
=_c_10mm2size((LPPAGESETUPDLGA
)setupdlg
,setupdlg
->ptPaperSize
.y
);
2886 hDlgTmpl
= PRINTDLG_GetPGSTemplateW(setupdlg
);
2888 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2891 ptr
= LockResource( hDlgTmpl
);
2893 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2896 pdw
= HeapAlloc(GetProcessHeap(),0,sizeof(*pdw
));
2897 pdw
->dlga
= setupdlg
;
2898 memcpy(&pdw
->pdlg
,&pdlg
,sizeof(pdlg
));
2900 bRet
= (0<DialogBoxIndirectParamW(
2901 setupdlg
->hInstance
,
2903 setupdlg
->hwndOwner
,
2910 /***********************************************************************
2911 * PrintDlgExA (COMDLG32.@)
2913 HRESULT WINAPI
PrintDlgExA(LPVOID lpPrintDlgExA
) /* [???] FIXME: LPPRINTDLGEXA */
2918 /***********************************************************************
2919 * PrintDlgExW (COMDLG32.@)
2921 HRESULT WINAPI
PrintDlgExW(LPVOID lpPrintDlgExW
) /* [???] FIXME: LPPRINTDLGEXW */