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_GetDefaultPrinterName
77 * Returns the default printer name in buf.
78 * Even under WinNT/2000 default printer is retrieved via GetProfileString -
79 * these entries are mapped somewhere in the registry rather than win.ini.
81 * Returns TRUE on success else FALSE
83 BOOL
PRINTDLG_GetDefaultPrinterNameA(LPSTR buf
, DWORD len
)
87 if(!GetProfileStringA("windows", "device", "", buf
, len
)) {
88 TRACE("No profile entry for default printer found.\n");
91 if((ptr
= strchr(buf
, ',')) == NULL
) {
92 FIXME("bad format for default printer (%s)!\n",buf
);
99 static BOOL
PRINTDLG_GetDefaultPrinterNameW(LPWSTR buf
, DWORD len
)
101 LPSTR ptr
, bufA
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len
+1);
104 if(!GetProfileStringA("windows", "device", "", bufA
, len
)) {
105 TRACE("No profile entry for default printer found.\n");
106 HeapFree(GetProcessHeap(),0,bufA
);
109 if((ptr
= strchr(bufA
, ',')) == NULL
) {
110 FIXME("bad format for default printer (%s)!\n",bufA
);
111 HeapFree(GetProcessHeap(),0,bufA
);
115 MultiByteToWideChar( CP_ACP
, 0, bufA
, -1, buf
, len
);
116 HeapFree(GetProcessHeap(),0,bufA
);
120 /***********************************************************************
121 * PRINTDLG_OpenDefaultPrinter
123 * Returns a winspool printer handle to the default printer in *hprn
124 * Caller must call ClosePrinter on the handle
126 * Returns TRUE on success else FALSE
128 BOOL
PRINTDLG_OpenDefaultPrinter(HANDLE
*hprn
)
132 if(!PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
)))
134 res
= OpenPrinterA(buf
, hprn
, NULL
);
136 FIXME("Could not open printer %s?!\n",buf
);
140 /***********************************************************************
141 * PRINTDLG_SetUpPrinterListCombo
143 * Initializes printer list combox.
144 * hDlg: HWND of dialog
145 * id: Control id of combo
146 * name: Name of printer to select
148 * Initializes combo with list of available printers. Selects printer 'name'
149 * If name is NULL or does not exist select the default printer.
151 * Returns number of printers added to list.
153 INT
PRINTDLG_SetUpPrinterListComboA(HWND hDlg
, UINT id
, LPCSTR name
)
157 LPPRINTER_INFO_2A pi
;
158 EnumPrintersA(PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &needed
, &num
);
159 pi
= HeapAlloc(GetProcessHeap(), 0, needed
);
160 EnumPrintersA(PRINTER_ENUM_LOCAL
, NULL
, 2, (LPBYTE
)pi
, needed
, &needed
,
163 for(i
= 0; i
< num
; i
++) {
164 SendDlgItemMessageA(hDlg
, id
, CB_ADDSTRING
, 0,
165 (LPARAM
)pi
[i
].pPrinterName
);
167 HeapFree(GetProcessHeap(), 0, pi
);
169 (i
= SendDlgItemMessageA(hDlg
, id
, CB_FINDSTRINGEXACT
, -1,
170 (LPARAM
)name
)) == CB_ERR
) {
173 FIXME("Can't find '%s' in printer list so trying to find default\n",
175 if(!PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
)))
177 i
= SendDlgItemMessageA(hDlg
, id
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buf
);
179 FIXME("Can't find default printer in printer list\n");
181 SendDlgItemMessageA(hDlg
, id
, CB_SETCURSEL
, i
, 0);
185 static INT
PRINTDLG_SetUpPrinterListComboW(HWND hDlg
, UINT id
, LPCWSTR name
)
189 LPPRINTER_INFO_2W pi
;
190 EnumPrintersW(PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &needed
, &num
);
191 pi
= HeapAlloc(GetProcessHeap(), 0, needed
);
192 EnumPrintersW(PRINTER_ENUM_LOCAL
, NULL
, 2, (LPBYTE
)pi
, needed
, &needed
,
195 for(i
= 0; i
< num
; i
++) {
196 SendDlgItemMessageW(hDlg
, id
, CB_ADDSTRING
, 0,
197 (LPARAM
)pi
[i
].pPrinterName
);
199 HeapFree(GetProcessHeap(), 0, pi
);
201 (i
= SendDlgItemMessageW(hDlg
, id
, CB_FINDSTRINGEXACT
, -1,
202 (LPARAM
)name
)) == CB_ERR
) {
206 FIXME("Can't find '%s' in printer list so trying to find default\n",
208 if(!PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
)))
210 i
= SendDlgItemMessageA(hDlg
, id
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buf
);
212 FIXME("Can't find default printer in printer list\n");
214 SendDlgItemMessageW(hDlg
, id
, CB_SETCURSEL
, i
, 0);
218 /***********************************************************************
219 * PRINTDLG_CreateDevNames [internal]
222 * creates a DevNames structure.
224 * (NB. when we handle unicode the offsets will be in wchars).
226 static BOOL
PRINTDLG_CreateDevNames(HGLOBAL
*hmem
, char* DeviceDriverName
,
227 char* DeviceName
, char* OutputPort
)
230 char* pDevNamesSpace
;
232 LPDEVNAMES lpDevNames
;
235 size
= strlen(DeviceDriverName
) + 1
236 + strlen(DeviceName
) + 1
237 + strlen(OutputPort
) + 1
241 *hmem
= GlobalReAlloc(*hmem
, size
, GMEM_MOVEABLE
);
243 *hmem
= GlobalAlloc(GMEM_MOVEABLE
, size
);
247 pDevNamesSpace
= GlobalLock(*hmem
);
248 lpDevNames
= (LPDEVNAMES
) pDevNamesSpace
;
250 pTempPtr
= pDevNamesSpace
+ sizeof(DEVNAMES
);
251 strcpy(pTempPtr
, DeviceDriverName
);
252 lpDevNames
->wDriverOffset
= pTempPtr
- pDevNamesSpace
;
254 pTempPtr
+= strlen(DeviceDriverName
) + 1;
255 strcpy(pTempPtr
, DeviceName
);
256 lpDevNames
->wDeviceOffset
= pTempPtr
- pDevNamesSpace
;
258 pTempPtr
+= strlen(DeviceName
) + 1;
259 strcpy(pTempPtr
, OutputPort
);
260 lpDevNames
->wOutputOffset
= pTempPtr
- pDevNamesSpace
;
262 PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
));
263 lpDevNames
->wDefault
= (strcmp(buf
, DeviceName
) == 0) ? 1 : 0;
268 static BOOL
PRINTDLG_CreateDevNamesW(HGLOBAL
*hmem
, LPCWSTR DeviceDriverName
,
269 LPCWSTR DeviceName
, LPCWSTR OutputPort
)
272 LPWSTR pDevNamesSpace
;
274 LPDEVNAMES lpDevNames
;
278 size
= sizeof(WCHAR
)*lstrlenW(DeviceDriverName
) + 2
279 + sizeof(WCHAR
)*lstrlenW(DeviceName
) + 2
280 + sizeof(WCHAR
)*lstrlenW(OutputPort
) + 2
284 *hmem
= GlobalReAlloc(*hmem
, size
, GMEM_MOVEABLE
);
286 *hmem
= GlobalAlloc(GMEM_MOVEABLE
, size
);
290 pDevNamesSpace
= GlobalLock(*hmem
);
291 lpDevNames
= (LPDEVNAMES
) pDevNamesSpace
;
293 pTempPtr
= (LPWSTR
)((LPDEVNAMES
)pDevNamesSpace
+ 1);
294 lstrcpyW(pTempPtr
, DeviceDriverName
);
295 lpDevNames
->wDriverOffset
= pTempPtr
- pDevNamesSpace
;
297 pTempPtr
+= lstrlenW(DeviceDriverName
) + 1;
298 lstrcpyW(pTempPtr
, DeviceName
);
299 lpDevNames
->wDeviceOffset
= pTempPtr
- pDevNamesSpace
;
301 pTempPtr
+= lstrlenW(DeviceName
) + 1;
302 lstrcpyW(pTempPtr
, OutputPort
);
303 lpDevNames
->wOutputOffset
= pTempPtr
- pDevNamesSpace
;
305 PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
));
306 MultiByteToWideChar(CP_ACP
, 0, buf
, -1, bufW
, -1);
307 lpDevNames
->wDefault
= (lstrcmpW(bufW
, DeviceName
) == 0) ? 1 : 0;
312 /***********************************************************************
313 * PRINTDLG_UpdatePrintDlg [internal]
316 * updates the PrintDlg structure for return values.
319 * FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
320 * TRUE if successful.
322 static BOOL
PRINTDLG_UpdatePrintDlgA(HWND hDlg
,
323 PRINT_PTRA
* PrintStructures
)
325 LPPRINTDLGA lppd
= PrintStructures
->dlg
.lpPrintDlg
;
326 PDEVMODEA lpdm
= PrintStructures
->lpDevMode
;
327 LPPRINTER_INFO_2A pi
= PrintStructures
->lpPrinterInfo
;
331 FIXME("No lpdm ptr?\n");
336 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
337 /* check whether nFromPage and nToPage are within range defined by
338 * nMinPage and nMaxPage
340 if (IsDlgButtonChecked(hDlg
, rad3
) == BST_CHECKED
) { /* Pages */
343 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
344 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
345 if (nFromPage
< lppd
->nMinPage
|| nFromPage
> lppd
->nMaxPage
||
346 nToPage
< lppd
->nMinPage
|| nToPage
> lppd
->nMaxPage
) {
347 char resourcestr
[256];
349 LoadStringA(COMDLG32_hInstance
, PD32_INVALID_PAGE_RANGE
,
351 sprintf(resultstr
,resourcestr
, lppd
->nMinPage
, lppd
->nMaxPage
);
352 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_TITLE
,
354 MessageBoxA(hDlg
, resultstr
, resourcestr
,
355 MB_OK
| MB_ICONWARNING
);
358 lppd
->nFromPage
= nFromPage
;
359 lppd
->nToPage
= nToPage
;
360 lppd
->Flags
|= PD_PAGENUMS
;
363 lppd
->Flags
&= ~PD_PAGENUMS
;
365 if (IsDlgButtonChecked(hDlg
, chx1
) == BST_CHECKED
) {/* Print to file */
366 lppd
->Flags
|= PD_PRINTTOFILE
;
367 pi
->pPortName
= "FILE:";
370 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
) { /* Collate */
371 FIXME("Collate lppd not yet implemented as output\n");
374 /* set PD_Collate and nCopies */
375 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
376 /* The application doesn't support multiple copies or collate...
378 lppd
->Flags
&= ~PD_COLLATE
;
380 /* if the printer driver supports it... store info there
381 * otherwise no collate & multiple copies !
383 if (lpdm
->dmFields
& DM_COLLATE
)
385 (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
);
386 if (lpdm
->dmFields
& DM_COPIES
)
387 lpdm
->dmCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
389 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
390 lppd
->Flags
|= PD_COLLATE
;
392 lppd
->Flags
&= ~PD_COLLATE
;
393 lppd
->nCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
399 static BOOL
PRINTDLG_UpdatePrintDlgW(HWND hDlg
,
400 PRINT_PTRW
* PrintStructures
)
402 LPPRINTDLGW lppd
= PrintStructures
->dlg
.lpPrintDlg
;
403 PDEVMODEW lpdm
= PrintStructures
->lpDevMode
;
404 LPPRINTER_INFO_2W pi
= PrintStructures
->lpPrinterInfo
;
408 FIXME("No lpdm ptr?\n");
413 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
414 /* check whether nFromPage and nToPage are within range defined by
415 * nMinPage and nMaxPage
417 if (IsDlgButtonChecked(hDlg
, rad3
) == BST_CHECKED
) { /* Pages */
420 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
421 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
422 if (nFromPage
< lppd
->nMinPage
|| nFromPage
> lppd
->nMaxPage
||
423 nToPage
< lppd
->nMinPage
|| nToPage
> lppd
->nMaxPage
) {
424 char resourcestr
[256];
426 LoadStringA(COMDLG32_hInstance
, PD32_INVALID_PAGE_RANGE
,
428 sprintf(resultstr
,resourcestr
, lppd
->nMinPage
, lppd
->nMaxPage
);
429 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_TITLE
,
431 MessageBoxA(hDlg
, resultstr
, resourcestr
,
432 MB_OK
| MB_ICONWARNING
);
435 lppd
->nFromPage
= nFromPage
;
436 lppd
->nToPage
= nToPage
;
439 if (IsDlgButtonChecked(hDlg
, chx1
) == BST_CHECKED
) {/* Print to file */
440 static WCHAR file
[] = {'F','I','L','E',':',0};
441 lppd
->Flags
|= PD_PRINTTOFILE
;
442 pi
->pPortName
= file
;
445 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
) { /* Collate */
446 FIXME("Collate lppd not yet implemented as output\n");
449 /* set PD_Collate and nCopies */
450 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
451 /* The application doesn't support multiple copies or collate...
453 lppd
->Flags
&= ~PD_COLLATE
;
455 /* if the printer driver supports it... store info there
456 * otherwise no collate & multiple copies !
458 if (lpdm
->dmFields
& DM_COLLATE
)
460 (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
);
461 if (lpdm
->dmFields
& DM_COPIES
)
462 lpdm
->dmCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
464 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
465 lppd
->Flags
|= PD_COLLATE
;
467 lppd
->Flags
&= ~PD_COLLATE
;
468 lppd
->nCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
474 static BOOL
PRINTDLG_PaperSizeA(
475 PRINTDLGA
*pdlga
,const char *PaperSize
,LPPOINT size
479 LPSTR devname
,portname
;
483 POINT
*points
= NULL
;
486 dn
= GlobalLock(pdlga
->hDevNames
);
487 dm
= GlobalLock(pdlga
->hDevMode
);
488 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
489 portname
= ((char*)dn
)+dn
->wOutputOffset
;
492 NrOfEntries
= DeviceCapabilitiesA(devname
,portname
,DC_PAPERNAMES
,NULL
,dm
);
494 FIXME("No papernames found for %s/%s\n",devname
,portname
);
497 if (NrOfEntries
== -1) {
498 ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n");
502 Names
= (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries
*64);
503 if (NrOfEntries
!= (ret
=DeviceCapabilitiesA(devname
,portname
,DC_PAPERNAMES
,Names
,dm
))) {
504 FIXME("Number of returned vals %d is not %d\n",NrOfEntries
,ret
);
507 for (i
=0;i
<NrOfEntries
;i
++)
508 if (!strcmp(PaperSize
,Names
+(64*i
)))
510 HeapFree(GetProcessHeap(),0,Names
);
511 if (i
==NrOfEntries
) {
512 FIXME("Papersize %s not found in list?\n",PaperSize
);
515 points
= HeapAlloc(GetProcessHeap(),0,sizeof(points
[0])*NrOfEntries
);
516 if (NrOfEntries
!=(ret
=DeviceCapabilitiesA(devname
,portname
,DC_PAPERSIZE
,(LPBYTE
)points
,dm
))) {
517 FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries
,ret
);
520 /* this is _10ths_ of a millimeter */
525 GlobalUnlock(pdlga
->hDevNames
);
526 GlobalUnlock(pdlga
->hDevMode
);
527 if (Names
) HeapFree(GetProcessHeap(),0,Names
);
528 if (points
) HeapFree(GetProcessHeap(),0,points
);
532 static BOOL
PRINTDLG_PaperSizeW(
533 PRINTDLGW
*pdlga
,const WCHAR
*PaperSize
,LPPOINT size
537 LPWSTR devname
,portname
;
541 POINT
*points
= NULL
;
544 dn
= GlobalLock(pdlga
->hDevNames
);
545 dm
= GlobalLock(pdlga
->hDevMode
);
546 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
547 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
550 NrOfEntries
= DeviceCapabilitiesW(devname
,portname
,DC_PAPERNAMES
,NULL
,dm
);
552 FIXME("No papernames found for %s/%s\n",debugstr_w(devname
),debugstr_w(portname
));
555 if (NrOfEntries
== -1) {
556 ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n");
560 Names
= (WCHAR
*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*NrOfEntries
*64);
561 if (NrOfEntries
!= (ret
=DeviceCapabilitiesW(devname
,portname
,DC_PAPERNAMES
,Names
,dm
))) {
562 FIXME("Number of returned vals %d is not %d\n",NrOfEntries
,ret
);
565 for (i
=0;i
<NrOfEntries
;i
++)
566 if (!lstrcmpW(PaperSize
,Names
+(64*i
)))
568 HeapFree(GetProcessHeap(),0,Names
);
569 if (i
==NrOfEntries
) {
570 FIXME("Papersize %s not found in list?\n",debugstr_w(PaperSize
));
573 points
= HeapAlloc(GetProcessHeap(),0,sizeof(points
[0])*NrOfEntries
);
574 if (NrOfEntries
!=(ret
=DeviceCapabilitiesW(devname
,portname
,DC_PAPERSIZE
,(LPWSTR
)points
,dm
))) {
575 FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries
,ret
);
578 /* this is _10ths_ of a millimeter */
583 GlobalUnlock(pdlga
->hDevNames
);
584 GlobalUnlock(pdlga
->hDevMode
);
585 if (Names
) HeapFree(GetProcessHeap(),0,Names
);
586 if (points
) HeapFree(GetProcessHeap(),0,points
);
591 /************************************************************************
592 * PRINTDLG_SetUpPaperComboBox
594 * Initialize either the papersize or inputslot combos of the Printer Setup
595 * dialog. We store the associated word (eg DMPAPER_A4) as the item data.
596 * We also try to re-select the old selection.
598 static BOOL
PRINTDLG_SetUpPaperComboBoxA(HWND hDlg
,
611 int fwCapability_Names
;
612 int fwCapability_Words
;
614 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",PrinterName
,PortName
,nIDComboBox
);
616 /* query the dialog box for the current selected value */
617 Sel
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETCURSEL
, 0, 0);
619 /* we enter here only if a different printer is selected after
620 * the Print Setup dialog is opened. The current settings are
621 * stored into the newly selected printer.
623 oldWord
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
,
626 if (nIDComboBox
== cmb2
)
627 dm
->u1
.s1
.dmPaperSize
= oldWord
;
629 dm
->dmDefaultSource
= oldWord
;
633 /* we enter here only when the Print setup dialog is initially
634 * opened. In this case the settings are restored from when
635 * the dialog was last closed.
638 if (nIDComboBox
== cmb2
)
639 oldWord
= dm
->u1
.s1
.dmPaperSize
;
641 oldWord
= dm
->dmDefaultSource
;
645 if (nIDComboBox
== cmb2
) {
647 fwCapability_Names
= DC_PAPERNAMES
;
648 fwCapability_Words
= DC_PAPERS
;
652 fwCapability_Names
= DC_BINNAMES
;
653 fwCapability_Words
= DC_BINS
;
656 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the
657 * paper settings. As Wine doesn't allow VXDs, this results in a crash.
659 WARN(" if your printer driver uses VXDs, expect a crash now!\n");
660 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
661 fwCapability_Names
, NULL
, dm
);
662 if (NrOfEntries
== 0)
663 WARN("no Name Entries found!\n");
664 else if (NrOfEntries
< 0)
667 if(DeviceCapabilitiesA(PrinterName
, PortName
, fwCapability_Words
, NULL
, dm
)
669 ERR("Number of caps is different\n");
673 Names
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(char)*NamesSize
);
674 Words
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WORD
));
675 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
676 fwCapability_Names
, Names
, dm
);
677 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
678 fwCapability_Words
, (LPSTR
)Words
, dm
);
680 /* reset any current content in the combobox */
681 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_RESETCONTENT
, 0, 0);
683 /* store new content */
684 for (i
= 0; i
< NrOfEntries
; i
++) {
685 DWORD pos
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_ADDSTRING
, 0,
686 (LPARAM
)(&Names
[i
*NamesSize
]) );
687 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_SETITEMDATA
, pos
,
691 /* Look for old selection - can't do this is previous loop since
692 item order will change as more items are added */
694 for (i
= 0; i
< NrOfEntries
; i
++) {
695 if(SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
, i
, 0) ==
701 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_SETCURSEL
, Sel
, 0);
703 HeapFree(GetProcessHeap(),0,Words
);
704 HeapFree(GetProcessHeap(),0,Names
);
708 static BOOL
PRINTDLG_SetUpPaperComboBoxW(HWND hDlg
,
721 int fwCapability_Names
;
722 int fwCapability_Words
;
724 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",debugstr_w(PrinterName
),debugstr_w(PortName
),nIDComboBox
);
726 /* query the dialog box for the current selected value */
727 Sel
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETCURSEL
, 0, 0);
729 /* we enter here only if a different printer is selected after
730 * the Print Setup dialog is opened. The current settings are
731 * stored into the newly selected printer.
733 oldWord
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
,
736 if (nIDComboBox
== cmb2
)
737 dm
->u1
.s1
.dmPaperSize
= oldWord
;
739 dm
->dmDefaultSource
= oldWord
;
743 /* we enter here only when the Print setup dialog is initially
744 * opened. In this case the settings are restored from when
745 * the dialog was last closed.
748 if (nIDComboBox
== cmb2
)
749 oldWord
= dm
->u1
.s1
.dmPaperSize
;
751 oldWord
= dm
->dmDefaultSource
;
755 if (nIDComboBox
== cmb2
) {
757 fwCapability_Names
= DC_PAPERNAMES
;
758 fwCapability_Words
= DC_PAPERS
;
762 fwCapability_Names
= DC_BINNAMES
;
763 fwCapability_Words
= DC_BINS
;
766 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the
767 * paper settings. As Wine doesn't allow VXDs, this results in a crash.
769 WARN(" if your printer driver uses VXDs, expect a crash now!\n");
770 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
771 fwCapability_Names
, NULL
, dm
);
772 if (NrOfEntries
== 0)
773 WARN("no Name Entries found!\n");
774 else if (NrOfEntries
< 0)
777 if(DeviceCapabilitiesW(PrinterName
, PortName
, fwCapability_Words
, NULL
, dm
)
779 ERR("Number of caps is different\n");
783 Names
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WCHAR
)*NamesSize
);
784 Words
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WORD
));
785 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
786 fwCapability_Names
, Names
, dm
);
787 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
788 fwCapability_Words
, (LPWSTR
)Words
, dm
);
790 /* reset any current content in the combobox */
791 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_RESETCONTENT
, 0, 0);
793 /* store new content */
794 for (i
= 0; i
< NrOfEntries
; i
++) {
795 DWORD pos
= SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_ADDSTRING
, 0,
796 (LPARAM
)(&Names
[i
*NamesSize
]) );
797 SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_SETITEMDATA
, pos
,
801 /* Look for old selection - can't do this is previous loop since
802 item order will change as more items are added */
804 for (i
= 0; i
< NrOfEntries
; i
++) {
805 if(SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
, i
, 0) ==
811 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_SETCURSEL
, Sel
, 0);
813 HeapFree(GetProcessHeap(),0,Words
);
814 HeapFree(GetProcessHeap(),0,Names
);
819 /***********************************************************************
820 * PRINTDLG_UpdatePrinterInfoTexts [internal]
822 static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg
, LPPRINTER_INFO_2A pi
)
825 char ResourceString
[256];
831 /* add all status messages */
832 for (i
= 0; i
< 25; i
++) {
833 if (pi
->Status
& (1<<i
)) {
834 LoadStringA(COMDLG32_hInstance
, PD32_PRINTER_STATUS_PAUSED
+i
,
835 ResourceString
, 255);
836 strcat(StatusMsg
,ResourceString
);
840 /* FIXME: status==ready must only be appended if really so.
841 but how to detect? */
842 LoadStringA(COMDLG32_hInstance
, PD32_PRINTER_STATUS_READY
,
843 ResourceString
, 255);
844 strcat(StatusMsg
,ResourceString
);
845 SetDlgItemTextA(hDlg
, stc12
, StatusMsg
);
847 /* set all other printer info texts */
848 SetDlgItemTextA(hDlg
, stc11
, pi
->pDriverName
);
850 if (pi
->pLocation
!= NULL
&& pi
->pLocation
[0] != '\0')
851 SetDlgItemTextA(hDlg
, stc14
, pi
->pLocation
);
853 SetDlgItemTextA(hDlg
, stc14
, pi
->pPortName
);
854 SetDlgItemTextA(hDlg
, stc13
, pi
->pComment
? pi
->pComment
: "");
858 static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg
, LPPRINTER_INFO_2W pi
)
860 WCHAR StatusMsg
[256];
861 WCHAR ResourceString
[256];
862 static const WCHAR emptyW
[] = {0};
868 /* add all status messages */
869 for (i
= 0; i
< 25; i
++) {
870 if (pi
->Status
& (1<<i
)) {
871 LoadStringW(COMDLG32_hInstance
, PD32_PRINTER_STATUS_PAUSED
+i
,
872 ResourceString
, 255);
873 lstrcatW(StatusMsg
,ResourceString
);
877 /* FIXME: status==ready must only be appended if really so.
878 but how to detect? */
879 LoadStringW(COMDLG32_hInstance
, PD32_PRINTER_STATUS_READY
,
880 ResourceString
, 255);
881 lstrcatW(StatusMsg
,ResourceString
);
882 SetDlgItemTextW(hDlg
, stc12
, StatusMsg
);
884 /* set all other printer info texts */
885 SetDlgItemTextW(hDlg
, stc11
, pi
->pDriverName
);
886 if (pi
->pLocation
!= NULL
&& pi
->pLocation
[0] != '\0')
887 SetDlgItemTextW(hDlg
, stc14
, pi
->pLocation
);
889 SetDlgItemTextW(hDlg
, stc14
, pi
->pPortName
);
890 SetDlgItemTextW(hDlg
, stc13
, pi
->pComment
? pi
->pComment
: emptyW
);
894 /*******************************************************************
896 * PRINTDLG_ChangePrinter
899 BOOL
PRINTDLG_ChangePrinterA(HWND hDlg
, char *name
,
900 PRINT_PTRA
*PrintStructures
)
902 LPPRINTDLGA lppd
= PrintStructures
->dlg
.lpPrintDlg
;
903 LPDEVMODEA lpdm
= NULL
;
908 if(PrintStructures
->lpPrinterInfo
)
909 HeapFree(GetProcessHeap(),0, PrintStructures
->lpPrinterInfo
);
910 if(PrintStructures
->lpDriverInfo
)
911 HeapFree(GetProcessHeap(),0, PrintStructures
->lpDriverInfo
);
912 if(!OpenPrinterA(name
, &hprn
, NULL
)) {
913 ERR("Can't open printer %s\n", name
);
916 GetPrinterA(hprn
, 2, NULL
, 0, &needed
);
917 PrintStructures
->lpPrinterInfo
= HeapAlloc(GetProcessHeap(),0,needed
);
918 GetPrinterA(hprn
, 2, (LPBYTE
)PrintStructures
->lpPrinterInfo
, needed
,
920 GetPrinterDriverA(hprn
, NULL
, 3, NULL
, 0, &needed
);
921 PrintStructures
->lpDriverInfo
= HeapAlloc(GetProcessHeap(),0,needed
);
922 if (!GetPrinterDriverA(hprn
, NULL
, 3, (LPBYTE
)PrintStructures
->lpDriverInfo
,
924 ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures
->lpPrinterInfo
->pPrinterName
);
929 PRINTDLG_UpdatePrinterInfoTextsA(hDlg
, PrintStructures
->lpPrinterInfo
);
931 if(PrintStructures
->lpDevMode
) {
932 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
933 PrintStructures
->lpDevMode
= NULL
;
936 dmSize
= DocumentPropertiesA(0, 0, name
, NULL
, NULL
, 0);
938 ERR("DocumentProperties fails on %s\n", debugstr_a(name
));
941 PrintStructures
->lpDevMode
= HeapAlloc(GetProcessHeap(), 0, dmSize
);
942 dmSize
= DocumentPropertiesA(0, 0, name
, PrintStructures
->lpDevMode
, NULL
,
944 if(lppd
->hDevMode
&& (lpdm
= GlobalLock(lppd
->hDevMode
)) &&
945 !strcmp(lpdm
->dmDeviceName
,
946 PrintStructures
->lpDevMode
->dmDeviceName
)) {
947 /* Supplied devicemode matches current printer so try to use it */
948 DocumentPropertiesA(0, 0, name
, PrintStructures
->lpDevMode
, lpdm
,
949 DM_OUT_BUFFER
| DM_IN_BUFFER
);
952 GlobalUnlock(lppd
->hDevMode
);
954 lpdm
= PrintStructures
->lpDevMode
; /* use this as a shortcut */
956 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
957 /* Print range (All/Range/Selection) */
958 SetDlgItemInt(hDlg
, edt1
, lppd
->nFromPage
, FALSE
);
959 SetDlgItemInt(hDlg
, edt2
, lppd
->nToPage
, FALSE
);
960 CheckRadioButton(hDlg
, rad1
, rad3
, rad1
); /* default */
961 if (lppd
->Flags
& PD_NOSELECTION
)
962 EnableWindow(GetDlgItem(hDlg
, rad2
), FALSE
);
964 if (lppd
->Flags
& PD_SELECTION
)
965 CheckRadioButton(hDlg
, rad1
, rad3
, rad2
);
966 if (lppd
->Flags
& PD_NOPAGENUMS
) {
967 EnableWindow(GetDlgItem(hDlg
, rad3
), FALSE
);
968 EnableWindow(GetDlgItem(hDlg
, stc2
),FALSE
);
969 EnableWindow(GetDlgItem(hDlg
, edt1
), FALSE
);
970 EnableWindow(GetDlgItem(hDlg
, stc3
),FALSE
);
971 EnableWindow(GetDlgItem(hDlg
, edt2
), FALSE
);
973 if (lppd
->Flags
& PD_PAGENUMS
)
974 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
976 /* "All xxx pages"... */
978 char resourcestr
[64];
980 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_ALL_X_PAGES
,
982 sprintf(result
,resourcestr
,lppd
->nMaxPage
- lppd
->nMinPage
+ 1);
983 SendDlgItemMessageA(hDlg
, rad1
, WM_SETTEXT
, 0, (LPARAM
) result
);
988 * FIXME: The ico3 is not displayed for some reason. I don't know why.
990 if (lppd
->Flags
& PD_COLLATE
) {
991 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
992 (LPARAM
)PrintStructures
->hCollateIcon
);
993 CheckDlgButton(hDlg
, chx2
, 1);
995 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
996 (LPARAM
)PrintStructures
->hNoCollateIcon
);
997 CheckDlgButton(hDlg
, chx2
, 0);
1000 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1001 /* if printer doesn't support it: no Collate */
1002 if (!(lpdm
->dmFields
& DM_COLLATE
)) {
1003 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1004 EnableWindow(GetDlgItem(hDlg
, ico3
), FALSE
);
1011 if (lppd
->hDevMode
== 0)
1012 copies
= lppd
->nCopies
;
1014 copies
= lpdm
->dmCopies
;
1015 if(copies
== 0) copies
= 1;
1016 else if(copies
< 0) copies
= MAX_COPIES
;
1017 SetDlgItemInt(hDlg
, edt3
, copies
, FALSE
);
1020 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1021 /* if printer doesn't support it: no nCopies */
1022 if (!(lpdm
->dmFields
& DM_COPIES
)) {
1023 EnableWindow(GetDlgItem(hDlg
, edt3
), FALSE
);
1024 EnableWindow(GetDlgItem(hDlg
, stc5
), FALSE
);
1029 CheckDlgButton(hDlg
, chx1
, (lppd
->Flags
& PD_PRINTTOFILE
) ? 1 : 0);
1030 if (lppd
->Flags
& PD_DISABLEPRINTTOFILE
)
1031 EnableWindow(GetDlgItem(hDlg
, chx1
), FALSE
);
1032 if (lppd
->Flags
& PD_HIDEPRINTTOFILE
)
1033 ShowWindow(GetDlgItem(hDlg
, chx1
), SW_HIDE
);
1035 } else { /* PD_PRINTSETUP */
1036 BOOL bPortrait
= (lpdm
->u1
.s1
.dmOrientation
== DMORIENT_PORTRAIT
);
1038 PRINTDLG_SetUpPaperComboBoxA(hDlg
, cmb2
,
1039 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1040 PrintStructures
->lpPrinterInfo
->pPortName
,
1042 PRINTDLG_SetUpPaperComboBoxA(hDlg
, cmb3
,
1043 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1044 PrintStructures
->lpPrinterInfo
->pPortName
,
1046 CheckRadioButton(hDlg
, rad1
, rad2
, bPortrait
? rad1
: rad2
);
1047 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1048 (LPARAM
)(bPortrait
? PrintStructures
->hPortraitIcon
:
1049 PrintStructures
->hLandscapeIcon
));
1054 if ((lppd
->Flags
& PD_SHOWHELP
)==0) {
1055 /* hide if PD_SHOWHELP not specified */
1056 ShowWindow(GetDlgItem(hDlg
, pshHelp
), SW_HIDE
);
1061 static BOOL
PRINTDLG_ChangePrinterW(HWND hDlg
, WCHAR
*name
,
1062 PRINT_PTRW
*PrintStructures
)
1064 LPPRINTDLGW lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1065 LPDEVMODEW lpdm
= NULL
;
1070 if(PrintStructures
->lpPrinterInfo
)
1071 HeapFree(GetProcessHeap(),0, PrintStructures
->lpPrinterInfo
);
1072 if(PrintStructures
->lpDriverInfo
)
1073 HeapFree(GetProcessHeap(),0, PrintStructures
->lpDriverInfo
);
1074 if(!OpenPrinterW(name
, &hprn
, NULL
)) {
1075 ERR("Can't open printer %s\n", debugstr_w(name
));
1078 GetPrinterW(hprn
, 2, NULL
, 0, &needed
);
1079 PrintStructures
->lpPrinterInfo
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
1080 GetPrinterW(hprn
, 2, (LPBYTE
)PrintStructures
->lpPrinterInfo
, needed
,
1082 GetPrinterDriverW(hprn
, NULL
, 3, NULL
, 0, &needed
);
1083 PrintStructures
->lpDriverInfo
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
1084 if (!GetPrinterDriverW(hprn
, NULL
, 3, (LPBYTE
)PrintStructures
->lpDriverInfo
,
1086 ERR("GetPrinterDriverA failed for %s, fix your config!\n",debugstr_w(PrintStructures
->lpPrinterInfo
->pPrinterName
));
1091 PRINTDLG_UpdatePrinterInfoTextsW(hDlg
, PrintStructures
->lpPrinterInfo
);
1093 if(PrintStructures
->lpDevMode
) {
1094 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
1095 PrintStructures
->lpDevMode
= NULL
;
1098 dmSize
= DocumentPropertiesW(0, 0, name
, NULL
, NULL
, 0);
1100 ERR("DocumentProperties fails on %s\n", debugstr_w(name
));
1103 PrintStructures
->lpDevMode
= HeapAlloc(GetProcessHeap(), 0, dmSize
);
1104 dmSize
= DocumentPropertiesW(0, 0, name
, PrintStructures
->lpDevMode
, NULL
,
1106 if(lppd
->hDevMode
&& (lpdm
= GlobalLock(lppd
->hDevMode
)) &&
1107 !lstrcmpW(lpdm
->dmDeviceName
,
1108 PrintStructures
->lpDevMode
->dmDeviceName
)) {
1109 /* Supplied devicemode matches current printer so try to use it */
1110 DocumentPropertiesW(0, 0, name
, PrintStructures
->lpDevMode
, lpdm
,
1111 DM_OUT_BUFFER
| DM_IN_BUFFER
);
1114 GlobalUnlock(lppd
->hDevMode
);
1116 lpdm
= PrintStructures
->lpDevMode
; /* use this as a shortcut */
1118 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
1119 /* Print range (All/Range/Selection) */
1120 SetDlgItemInt(hDlg
, edt1
, lppd
->nFromPage
, FALSE
);
1121 SetDlgItemInt(hDlg
, edt2
, lppd
->nToPage
, FALSE
);
1122 CheckRadioButton(hDlg
, rad1
, rad3
, rad1
); /* default */
1123 if (lppd
->Flags
& PD_NOSELECTION
)
1124 EnableWindow(GetDlgItem(hDlg
, rad2
), FALSE
);
1126 if (lppd
->Flags
& PD_SELECTION
)
1127 CheckRadioButton(hDlg
, rad1
, rad3
, rad2
);
1128 if (lppd
->Flags
& PD_NOPAGENUMS
) {
1129 EnableWindow(GetDlgItem(hDlg
, rad3
), FALSE
);
1130 EnableWindow(GetDlgItem(hDlg
, stc2
),FALSE
);
1131 EnableWindow(GetDlgItem(hDlg
, edt1
), FALSE
);
1132 EnableWindow(GetDlgItem(hDlg
, stc3
),FALSE
);
1133 EnableWindow(GetDlgItem(hDlg
, edt2
), FALSE
);
1135 if (lppd
->Flags
& PD_PAGENUMS
)
1136 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1138 /* "All xxx pages"... */
1141 char resourcestr
[64];
1143 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_ALL_X_PAGES
,
1145 sprintf(result
,resourcestr
,lppd
->nMaxPage
- lppd
->nMinPage
+ 1);
1146 SendDlgItemMessageA(hDlg
, rad1
, WM_SETTEXT
, 0, (LPARAM
) result
);
1151 * FIXME: The ico3 is not displayed for some reason. I don't know why.
1153 if (lppd
->Flags
& PD_COLLATE
) {
1154 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1155 (LPARAM
)PrintStructures
->hCollateIcon
);
1156 CheckDlgButton(hDlg
, chx2
, 1);
1158 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1159 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1160 CheckDlgButton(hDlg
, chx2
, 0);
1163 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1164 /* if printer doesn't support it: no Collate */
1165 if (!(lpdm
->dmFields
& DM_COLLATE
)) {
1166 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1167 EnableWindow(GetDlgItem(hDlg
, ico3
), FALSE
);
1174 if (lppd
->hDevMode
== 0)
1175 copies
= lppd
->nCopies
;
1177 copies
= lpdm
->dmCopies
;
1178 if(copies
== 0) copies
= 1;
1179 else if(copies
< 0) copies
= MAX_COPIES
;
1180 SetDlgItemInt(hDlg
, edt3
, copies
, FALSE
);
1183 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1184 /* if printer doesn't support it: no nCopies */
1185 if (!(lpdm
->dmFields
& DM_COPIES
)) {
1186 EnableWindow(GetDlgItem(hDlg
, edt3
), FALSE
);
1187 EnableWindow(GetDlgItem(hDlg
, stc5
), FALSE
);
1192 CheckDlgButton(hDlg
, chx1
, (lppd
->Flags
& PD_PRINTTOFILE
) ? 1 : 0);
1193 if (lppd
->Flags
& PD_DISABLEPRINTTOFILE
)
1194 EnableWindow(GetDlgItem(hDlg
, chx1
), FALSE
);
1195 if (lppd
->Flags
& PD_HIDEPRINTTOFILE
)
1196 ShowWindow(GetDlgItem(hDlg
, chx1
), SW_HIDE
);
1198 } else { /* PD_PRINTSETUP */
1199 BOOL bPortrait
= (lpdm
->u1
.s1
.dmOrientation
== DMORIENT_PORTRAIT
);
1201 PRINTDLG_SetUpPaperComboBoxW(hDlg
, cmb2
,
1202 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1203 PrintStructures
->lpPrinterInfo
->pPortName
,
1205 PRINTDLG_SetUpPaperComboBoxW(hDlg
, cmb3
,
1206 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1207 PrintStructures
->lpPrinterInfo
->pPortName
,
1209 CheckRadioButton(hDlg
, rad1
, rad2
, bPortrait
? rad1
: rad2
);
1210 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1211 (LPARAM
)(bPortrait
? PrintStructures
->hPortraitIcon
:
1212 PrintStructures
->hLandscapeIcon
));
1217 if ((lppd
->Flags
& PD_SHOWHELP
)==0) {
1218 /* hide if PD_SHOWHELP not specified */
1219 ShowWindow(GetDlgItem(hDlg
, pshHelp
), SW_HIDE
);
1224 /***********************************************************************
1225 * PRINTDLG_WMInitDialog [internal]
1227 static LRESULT
PRINTDLG_WMInitDialog(HWND hDlg
, WPARAM wParam
,
1228 PRINT_PTRA
* PrintStructures
)
1230 LPPRINTDLGA lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1234 UINT comboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1236 /* load Collate ICONs */
1237 /* We load these with LoadImage because they are not a standard
1238 size and we don't want them rescaled */
1239 PrintStructures
->hCollateIcon
=
1240 LoadImageA(COMDLG32_hInstance
, "PD32_COLLATE", IMAGE_ICON
, 0, 0, 0);
1241 PrintStructures
->hNoCollateIcon
=
1242 LoadImageA(COMDLG32_hInstance
, "PD32_NOCOLLATE", IMAGE_ICON
, 0, 0, 0);
1244 /* These can be done with LoadIcon */
1245 PrintStructures
->hPortraitIcon
=
1246 LoadIconA(COMDLG32_hInstance
, "PD32_PORTRAIT");
1247 PrintStructures
->hLandscapeIcon
=
1248 LoadIconA(COMDLG32_hInstance
, "PD32_LANDSCAPE");
1250 if(PrintStructures
->hCollateIcon
== 0 ||
1251 PrintStructures
->hNoCollateIcon
== 0 ||
1252 PrintStructures
->hPortraitIcon
== 0 ||
1253 PrintStructures
->hLandscapeIcon
== 0) {
1254 ERR("no icon in resourcefile\n");
1255 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1256 EndDialog(hDlg
, FALSE
);
1260 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1261 * must be registered and the Help button must be shown.
1263 if (lppd
->Flags
& PD_SHOWHELP
) {
1264 if((PrintStructures
->HelpMessageID
=
1265 RegisterWindowMessageA(HELPMSGSTRINGA
)) == 0) {
1266 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL
);
1270 PrintStructures
->HelpMessageID
= 0;
1272 if(!(lppd
->Flags
&PD_PRINTSETUP
)) {
1273 PrintStructures
->hwndUpDown
=
1274 CreateUpDownControl(WS_CHILD
| WS_VISIBLE
| WS_BORDER
|
1275 UDS_NOTHOUSANDS
| UDS_ARROWKEYS
|
1276 UDS_ALIGNRIGHT
| UDS_SETBUDDYINT
, 0, 0, 0, 0,
1277 hDlg
, UPDOWN_ID
, COMDLG32_hInstance
,
1278 GetDlgItem(hDlg
, edt3
), MAX_COPIES
, 1, 1);
1281 /* FIXME: I allow more freedom than either Win95 or WinNT,
1282 * which do not agree to what errors should be thrown or not
1283 * in case nToPage or nFromPage is out-of-range.
1285 if (lppd
->nMaxPage
< lppd
->nMinPage
)
1286 lppd
->nMaxPage
= lppd
->nMinPage
;
1287 if (lppd
->nMinPage
== lppd
->nMaxPage
)
1288 lppd
->Flags
|= PD_NOPAGENUMS
;
1289 if (lppd
->nToPage
< lppd
->nMinPage
)
1290 lppd
->nToPage
= lppd
->nMinPage
;
1291 if (lppd
->nToPage
> lppd
->nMaxPage
)
1292 lppd
->nToPage
= lppd
->nMaxPage
;
1293 if (lppd
->nFromPage
< lppd
->nMinPage
)
1294 lppd
->nFromPage
= lppd
->nMinPage
;
1295 if (lppd
->nFromPage
> lppd
->nMaxPage
)
1296 lppd
->nFromPage
= lppd
->nMaxPage
;
1298 /* if we have the combo box, fill it */
1299 if (GetDlgItem(hDlg
,comboID
)) {
1302 pdn
= GlobalLock(lppd
->hDevNames
);
1303 pdm
= GlobalLock(lppd
->hDevMode
);
1305 name
= (char*)pdn
+ pdn
->wDeviceOffset
;
1307 name
= pdm
->dmDeviceName
;
1308 PRINTDLG_SetUpPrinterListComboA(hDlg
, comboID
, name
);
1309 if(pdm
) GlobalUnlock(lppd
->hDevMode
);
1310 if(pdn
) GlobalUnlock(lppd
->hDevNames
);
1312 /* Now find selected printer and update rest of dlg */
1313 name
= HeapAlloc(GetProcessHeap(),0,256);
1314 if (GetDlgItemTextA(hDlg
, comboID
, name
, 255))
1315 PRINTDLG_ChangePrinterA(hDlg
, name
, PrintStructures
);
1316 HeapFree(GetProcessHeap(),0,name
);
1318 /* else use default printer */
1320 BOOL ret
= PRINTDLG_GetDefaultPrinterNameA(name
, sizeof(name
));
1323 PRINTDLG_ChangePrinterA(hDlg
, name
, PrintStructures
);
1325 FIXME("No default printer found, expect problems!\n");
1330 static LRESULT
PRINTDLG_WMInitDialogW(HWND hDlg
, WPARAM wParam
,
1331 PRINT_PTRW
* PrintStructures
)
1333 LPPRINTDLGW lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1337 UINT comboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1339 /* load Collate ICONs */
1340 /* We load these with LoadImage because they are not a standard
1341 size and we don't want them rescaled */
1342 PrintStructures
->hCollateIcon
=
1343 LoadImageA(COMDLG32_hInstance
, "PD32_COLLATE", IMAGE_ICON
, 0, 0, 0);
1344 PrintStructures
->hNoCollateIcon
=
1345 LoadImageA(COMDLG32_hInstance
, "PD32_NOCOLLATE", IMAGE_ICON
, 0, 0, 0);
1347 /* These can be done with LoadIcon */
1348 PrintStructures
->hPortraitIcon
=
1349 LoadIconA(COMDLG32_hInstance
, "PD32_PORTRAIT");
1350 PrintStructures
->hLandscapeIcon
=
1351 LoadIconA(COMDLG32_hInstance
, "PD32_LANDSCAPE");
1353 if(PrintStructures
->hCollateIcon
== 0 ||
1354 PrintStructures
->hNoCollateIcon
== 0 ||
1355 PrintStructures
->hPortraitIcon
== 0 ||
1356 PrintStructures
->hLandscapeIcon
== 0) {
1357 ERR("no icon in resourcefile\n");
1358 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1359 EndDialog(hDlg
, FALSE
);
1363 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1364 * must be registered and the Help button must be shown.
1366 if (lppd
->Flags
& PD_SHOWHELP
) {
1367 if((PrintStructures
->HelpMessageID
=
1368 RegisterWindowMessageA(HELPMSGSTRINGA
)) == 0) {
1369 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL
);
1373 PrintStructures
->HelpMessageID
= 0;
1375 if(!(lppd
->Flags
&PD_PRINTSETUP
)) {
1376 PrintStructures
->hwndUpDown
=
1377 CreateUpDownControl(WS_CHILD
| WS_VISIBLE
| WS_BORDER
|
1378 UDS_NOTHOUSANDS
| UDS_ARROWKEYS
|
1379 UDS_ALIGNRIGHT
| UDS_SETBUDDYINT
, 0, 0, 0, 0,
1380 hDlg
, UPDOWN_ID
, COMDLG32_hInstance
,
1381 GetDlgItem(hDlg
, edt3
), MAX_COPIES
, 1, 1);
1384 /* FIXME: I allow more freedom than either Win95 or WinNT,
1385 * which do not agree to what errors should be thrown or not
1386 * in case nToPage or nFromPage is out-of-range.
1388 if (lppd
->nMaxPage
< lppd
->nMinPage
)
1389 lppd
->nMaxPage
= lppd
->nMinPage
;
1390 if (lppd
->nMinPage
== lppd
->nMaxPage
)
1391 lppd
->Flags
|= PD_NOPAGENUMS
;
1392 if (lppd
->nToPage
< lppd
->nMinPage
)
1393 lppd
->nToPage
= lppd
->nMinPage
;
1394 if (lppd
->nToPage
> lppd
->nMaxPage
)
1395 lppd
->nToPage
= lppd
->nMaxPage
;
1396 if (lppd
->nFromPage
< lppd
->nMinPage
)
1397 lppd
->nFromPage
= lppd
->nMinPage
;
1398 if (lppd
->nFromPage
> lppd
->nMaxPage
)
1399 lppd
->nFromPage
= lppd
->nMaxPage
;
1401 /* if we have the combo box, fill it */
1402 if (GetDlgItem(hDlg
,comboID
)) {
1405 pdn
= GlobalLock(lppd
->hDevNames
);
1406 pdm
= GlobalLock(lppd
->hDevMode
);
1408 name
= (WCHAR
*)pdn
+ pdn
->wDeviceOffset
;
1410 name
= pdm
->dmDeviceName
;
1411 PRINTDLG_SetUpPrinterListComboW(hDlg
, comboID
, name
);
1412 if(pdm
) GlobalUnlock(lppd
->hDevMode
);
1413 if(pdn
) GlobalUnlock(lppd
->hDevNames
);
1415 /* Now find selected printer and update rest of dlg */
1416 /* ansi is ok here */
1417 name
= HeapAlloc(GetProcessHeap(),0,256*sizeof(WCHAR
));
1418 if (GetDlgItemTextW(hDlg
, comboID
, name
, 255))
1419 PRINTDLG_ChangePrinterW(hDlg
, name
, PrintStructures
);
1420 HeapFree(GetProcessHeap(),0,name
);
1422 /* else use default printer */
1424 BOOL ret
= PRINTDLG_GetDefaultPrinterNameW(name
, sizeof(name
));
1427 PRINTDLG_ChangePrinterW(hDlg
, name
, PrintStructures
);
1429 FIXME("No default printer found, expect problems!\n");
1434 /***********************************************************************
1435 * PRINTDLG_WMCommand [internal]
1437 LRESULT
PRINTDLG_WMCommandA(HWND hDlg
, WPARAM wParam
,
1438 LPARAM lParam
, PRINT_PTRA
* PrintStructures
)
1440 LPPRINTDLGA lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1441 UINT PrinterComboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1442 LPDEVMODEA lpdm
= PrintStructures
->lpDevMode
;
1444 switch (LOWORD(wParam
)) {
1446 TRACE(" OK button was hit\n");
1447 if (PRINTDLG_UpdatePrintDlgA(hDlg
, PrintStructures
)!=TRUE
) {
1448 FIXME("Update printdlg was not successful!\n");
1451 EndDialog(hDlg
, TRUE
);
1455 TRACE(" CANCEL button was hit\n");
1456 EndDialog(hDlg
, FALSE
);
1460 TRACE(" HELP button was hit\n");
1461 SendMessageA(lppd
->hwndOwner
, PrintStructures
->HelpMessageID
,
1462 (WPARAM
) hDlg
, (LPARAM
) lppd
);
1465 case chx2
: /* collate pages checkbox */
1466 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
1467 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1468 (LPARAM
)PrintStructures
->hCollateIcon
);
1470 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1471 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1473 case edt1
: /* from page nr editbox */
1474 case edt2
: /* to page nr editbox */
1475 if (HIWORD(wParam
)==EN_CHANGE
) {
1478 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
1479 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
1480 if (nFromPage
!= lppd
->nFromPage
|| nToPage
!= lppd
->nToPage
)
1481 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1486 if(HIWORD(wParam
) == EN_CHANGE
) {
1487 INT copies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
1489 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1491 EnableWindow(GetDlgItem(hDlg
, chx2
), TRUE
);
1496 case psh1
: /* Print Setup */
1500 if (!PrintStructures
->dlg
.lpPrintDlg16
) {
1501 FIXME("The 32bit print dialog does not have this button!?\n");
1505 memcpy(&pdlg
,PrintStructures
->dlg
.lpPrintDlg16
,sizeof(pdlg
));
1506 pdlg
.Flags
|= PD_PRINTSETUP
;
1507 pdlg
.hwndOwner
= HWND_16(hDlg
);
1508 if (!PrintDlg16(&pdlg
))
1513 case psh2
: /* Properties button */
1516 char PrinterName
[256];
1518 GetDlgItemTextA(hDlg
, PrinterComboID
, PrinterName
, 255);
1519 if (!OpenPrinterA(PrinterName
, &hPrinter
, NULL
)) {
1520 FIXME(" Call to OpenPrinter did not succeed!\n");
1523 DocumentPropertiesA(hDlg
, hPrinter
, PrinterName
,
1524 PrintStructures
->lpDevMode
,
1525 PrintStructures
->lpDevMode
,
1526 DM_IN_BUFFER
| DM_OUT_BUFFER
| DM_IN_PROMPT
);
1527 ClosePrinter(hPrinter
);
1531 case rad1
: /* Paperorientation */
1532 if (lppd
->Flags
& PD_PRINTSETUP
)
1534 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1535 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1536 (LPARAM
)(PrintStructures
->hPortraitIcon
));
1540 case rad2
: /* Paperorientation */
1541 if (lppd
->Flags
& PD_PRINTSETUP
)
1543 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1544 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1545 (LPARAM
)(PrintStructures
->hLandscapeIcon
));
1549 case cmb1
: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */
1550 if (PrinterComboID
!= wParam
) {
1551 FIXME("No handling for print quality combo box yet.\n");
1555 case cmb4
: /* Printer combobox */
1556 if (HIWORD(wParam
)==CBN_SELCHANGE
) {
1557 char PrinterName
[256];
1558 GetDlgItemTextA(hDlg
, LOWORD(wParam
), PrinterName
, 255);
1559 PRINTDLG_ChangePrinterA(hDlg
, PrinterName
, PrintStructures
);
1563 case cmb2
: /* Papersize */
1565 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
1567 lpdm
->u1
.s1
.dmPaperSize
= SendDlgItemMessageA(hDlg
, cmb2
,
1573 case cmb3
: /* Bin */
1575 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
1577 lpdm
->dmDefaultSource
= SendDlgItemMessageA(hDlg
, cmb3
,
1578 CB_GETITEMDATA
, Sel
,
1583 if(lppd
->Flags
& PD_PRINTSETUP
) {
1584 switch (LOWORD(wParam
)) {
1585 case rad1
: /* orientation */
1587 if (IsDlgButtonChecked(hDlg
, rad1
) == BST_CHECKED
) {
1588 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_PORTRAIT
) {
1589 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1590 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1592 (LPARAM
)PrintStructures
->hPortraitIcon
);
1593 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1595 (LPARAM
)PrintStructures
->hPortraitIcon
);
1598 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_LANDSCAPE
) {
1599 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1600 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1602 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1603 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1605 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1614 static LRESULT
PRINTDLG_WMCommandW(HWND hDlg
, WPARAM wParam
,
1615 LPARAM lParam
, PRINT_PTRW
* PrintStructures
)
1617 LPPRINTDLGW lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1618 UINT PrinterComboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1619 LPDEVMODEW lpdm
= PrintStructures
->lpDevMode
;
1621 switch (LOWORD(wParam
)) {
1623 TRACE(" OK button was hit\n");
1624 if (PRINTDLG_UpdatePrintDlgW(hDlg
, PrintStructures
)!=TRUE
) {
1625 FIXME("Update printdlg was not successful!\n");
1628 EndDialog(hDlg
, TRUE
);
1632 TRACE(" CANCEL button was hit\n");
1633 EndDialog(hDlg
, FALSE
);
1637 TRACE(" HELP button was hit\n");
1638 SendMessageW(lppd
->hwndOwner
, PrintStructures
->HelpMessageID
,
1639 (WPARAM
) hDlg
, (LPARAM
) lppd
);
1642 case chx2
: /* collate pages checkbox */
1643 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
1644 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1645 (LPARAM
)PrintStructures
->hCollateIcon
);
1647 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1648 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1650 case edt1
: /* from page nr editbox */
1651 case edt2
: /* to page nr editbox */
1652 if (HIWORD(wParam
)==EN_CHANGE
) {
1655 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
1656 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
1657 if (nFromPage
!= lppd
->nFromPage
|| nToPage
!= lppd
->nToPage
)
1658 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1663 if(HIWORD(wParam
) == EN_CHANGE
) {
1664 INT copies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
1666 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1668 EnableWindow(GetDlgItem(hDlg
, chx2
), TRUE
);
1672 case psh1
: /* Print Setup */
1674 ERR("psh1 is called from 16bit code only, we should not get here.\n");
1677 case psh2
: /* Properties button */
1680 WCHAR PrinterName
[256];
1682 GetDlgItemTextW(hDlg
, PrinterComboID
, PrinterName
, 255);
1683 if (!OpenPrinterW(PrinterName
, &hPrinter
, NULL
)) {
1684 FIXME(" Call to OpenPrinter did not succeed!\n");
1687 DocumentPropertiesW(hDlg
, hPrinter
, PrinterName
,
1688 PrintStructures
->lpDevMode
,
1689 PrintStructures
->lpDevMode
,
1690 DM_IN_BUFFER
| DM_OUT_BUFFER
| DM_IN_PROMPT
);
1691 ClosePrinter(hPrinter
);
1695 case rad1
: /* Paperorientation */
1696 if (lppd
->Flags
& PD_PRINTSETUP
)
1698 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1699 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1700 (LPARAM
)(PrintStructures
->hPortraitIcon
));
1704 case rad2
: /* Paperorientation */
1705 if (lppd
->Flags
& PD_PRINTSETUP
)
1707 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1708 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1709 (LPARAM
)(PrintStructures
->hLandscapeIcon
));
1713 case cmb1
: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */
1714 if (PrinterComboID
!= wParam
) {
1715 FIXME("No handling for print quality combo box yet.\n");
1719 case cmb4
: /* Printer combobox */
1720 if (HIWORD(wParam
)==CBN_SELCHANGE
) {
1721 WCHAR PrinterName
[256];
1722 GetDlgItemTextW(hDlg
, LOWORD(wParam
), PrinterName
, 255);
1723 PRINTDLG_ChangePrinterW(hDlg
, PrinterName
, PrintStructures
);
1727 case cmb2
: /* Papersize */
1729 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
1731 lpdm
->u1
.s1
.dmPaperSize
= SendDlgItemMessageA(hDlg
, cmb2
,
1737 case cmb3
: /* Bin */
1739 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
1741 lpdm
->dmDefaultSource
= SendDlgItemMessageW(hDlg
, cmb3
,
1742 CB_GETITEMDATA
, Sel
,
1747 if(lppd
->Flags
& PD_PRINTSETUP
) {
1748 switch (LOWORD(wParam
)) {
1749 case rad1
: /* orientation */
1751 if (IsDlgButtonChecked(hDlg
, rad1
) == BST_CHECKED
) {
1752 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_PORTRAIT
) {
1753 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1754 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1756 (LPARAM
)PrintStructures
->hPortraitIcon
);
1757 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1759 (LPARAM
)PrintStructures
->hPortraitIcon
);
1762 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_LANDSCAPE
) {
1763 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1764 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1766 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1767 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1769 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1778 /***********************************************************************
1779 * PrintDlgProcA [internal]
1781 INT_PTR CALLBACK
PrintDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
1784 PRINT_PTRA
* PrintStructures
;
1785 INT_PTR res
= FALSE
;
1787 if (uMsg
!=WM_INITDIALOG
) {
1788 PrintStructures
= (PRINT_PTRA
*)GetPropA(hDlg
,"__WINE_PRINTDLGDATA");
1789 if (!PrintStructures
)
1792 PrintStructures
= (PRINT_PTRA
*) lParam
;
1793 SetPropA(hDlg
,"__WINE_PRINTDLGDATA",PrintStructures
);
1794 res
= PRINTDLG_WMInitDialog(hDlg
, wParam
, PrintStructures
);
1796 if(PrintStructures
->dlg
.lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
)
1797 res
= PrintStructures
->dlg
.lpPrintDlg
->lpfnPrintHook(
1798 hDlg
, uMsg
, wParam
, (LPARAM
)PrintStructures
->dlg
.lpPrintDlg
1803 if(PrintStructures
->dlg
.lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
) {
1804 res
= PrintStructures
->dlg
.lpPrintDlg
->lpfnPrintHook(hDlg
,uMsg
,wParam
,
1811 return PRINTDLG_WMCommandA(hDlg
, wParam
, lParam
, PrintStructures
);
1814 DestroyIcon(PrintStructures
->hCollateIcon
);
1815 DestroyIcon(PrintStructures
->hNoCollateIcon
);
1816 DestroyIcon(PrintStructures
->hPortraitIcon
);
1817 DestroyIcon(PrintStructures
->hLandscapeIcon
);
1818 if(PrintStructures
->hwndUpDown
)
1819 DestroyWindow(PrintStructures
->hwndUpDown
);
1825 INT_PTR CALLBACK
PrintDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
1828 static const WCHAR propW
[] = {'_','_','W','I','N','E','_','P','R','I','N','T','D','L','G','D','A','T','A',0};
1829 PRINT_PTRW
* PrintStructures
;
1830 INT_PTR res
= FALSE
;
1832 if (uMsg
!=WM_INITDIALOG
) {
1833 PrintStructures
= (PRINT_PTRW
*) GetPropW(hDlg
, propW
);
1834 if (!PrintStructures
)
1837 PrintStructures
= (PRINT_PTRW
*) lParam
;
1838 SetPropW(hDlg
, propW
, PrintStructures
);
1839 res
= PRINTDLG_WMInitDialogW(hDlg
, wParam
, PrintStructures
);
1841 if(PrintStructures
->dlg
.lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
)
1842 res
= PrintStructures
->dlg
.lpPrintDlg
->lpfnPrintHook(hDlg
, uMsg
, wParam
, (LPARAM
)PrintStructures
->dlg
.lpPrintDlg
);
1846 if(PrintStructures
->dlg
.lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
) {
1847 res
= PrintStructures
->dlg
.lpPrintDlg
->lpfnPrintHook(hDlg
,uMsg
,wParam
, lParam
);
1853 return PRINTDLG_WMCommandW(hDlg
, wParam
, lParam
, PrintStructures
);
1856 DestroyIcon(PrintStructures
->hCollateIcon
);
1857 DestroyIcon(PrintStructures
->hNoCollateIcon
);
1858 DestroyIcon(PrintStructures
->hPortraitIcon
);
1859 DestroyIcon(PrintStructures
->hLandscapeIcon
);
1860 if(PrintStructures
->hwndUpDown
)
1861 DestroyWindow(PrintStructures
->hwndUpDown
);
1867 /************************************************************
1869 * PRINTDLG_GetDlgTemplate
1872 static HGLOBAL
PRINTDLG_GetDlgTemplateA(PRINTDLGA
*lppd
)
1877 if (lppd
->Flags
& PD_PRINTSETUP
) {
1878 if(lppd
->Flags
& PD_ENABLESETUPTEMPLATEHANDLE
) {
1879 hDlgTmpl
= lppd
->hSetupTemplate
;
1880 } else if(lppd
->Flags
& PD_ENABLESETUPTEMPLATE
) {
1881 hResInfo
= FindResourceA(lppd
->hInstance
,
1882 lppd
->lpSetupTemplateName
, (LPSTR
)RT_DIALOG
);
1883 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
1885 hResInfo
= FindResourceA(COMDLG32_hInstance
, "PRINT32_SETUP",
1887 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
1890 if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATEHANDLE
) {
1891 hDlgTmpl
= lppd
->hPrintTemplate
;
1892 } else if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATE
) {
1893 hResInfo
= FindResourceA(lppd
->hInstance
,
1894 lppd
->lpPrintTemplateName
,
1896 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
1898 hResInfo
= FindResourceA(COMDLG32_hInstance
, "PRINT32",
1900 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
1906 static HGLOBAL
PRINTDLG_GetDlgTemplateW(PRINTDLGW
*lppd
)
1910 const WCHAR xpsetup
[] = { 'P','R','I','N','T','3','2','_','S','E','T','U','P',0};
1911 const WCHAR xprint
[] = { 'P','R','I','N','T','3','2',0};
1913 if (lppd
->Flags
& PD_PRINTSETUP
) {
1914 if(lppd
->Flags
& PD_ENABLESETUPTEMPLATEHANDLE
) {
1915 hDlgTmpl
= lppd
->hSetupTemplate
;
1916 } else if(lppd
->Flags
& PD_ENABLESETUPTEMPLATE
) {
1917 hResInfo
= FindResourceW(lppd
->hInstance
,
1918 lppd
->lpSetupTemplateName
, (LPWSTR
)RT_DIALOG
);
1919 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
1921 hResInfo
= FindResourceW(COMDLG32_hInstance
, xpsetup
, (LPWSTR
)RT_DIALOG
);
1922 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
1925 if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATEHANDLE
) {
1926 hDlgTmpl
= lppd
->hPrintTemplate
;
1927 } else if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATE
) {
1928 hResInfo
= FindResourceW(lppd
->hInstance
,
1929 lppd
->lpPrintTemplateName
,
1931 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
1933 hResInfo
= FindResourceW(COMDLG32_hInstance
, xprint
, (LPWSTR
)RT_DIALOG
);
1934 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
1940 /***********************************************************************
1945 static BOOL
PRINTDLG_CreateDCA(LPPRINTDLGA lppd
)
1947 DEVNAMES
*pdn
= GlobalLock(lppd
->hDevNames
);
1948 DEVMODEA
*pdm
= GlobalLock(lppd
->hDevMode
);
1950 if(lppd
->Flags
& PD_RETURNDC
) {
1951 lppd
->hDC
= CreateDCA((char*)pdn
+ pdn
->wDriverOffset
,
1952 (char*)pdn
+ pdn
->wDeviceOffset
,
1953 (char*)pdn
+ pdn
->wOutputOffset
,
1955 } else if(lppd
->Flags
& PD_RETURNIC
) {
1956 lppd
->hDC
= CreateICA((char*)pdn
+ pdn
->wDriverOffset
,
1957 (char*)pdn
+ pdn
->wDeviceOffset
,
1958 (char*)pdn
+ pdn
->wOutputOffset
,
1961 GlobalUnlock(lppd
->hDevNames
);
1962 GlobalUnlock(lppd
->hDevMode
);
1963 return lppd
->hDC
? TRUE
: FALSE
;
1966 static BOOL
PRINTDLG_CreateDCW(LPPRINTDLGW lppd
)
1968 DEVNAMES
*pdn
= GlobalLock(lppd
->hDevNames
);
1969 DEVMODEW
*pdm
= GlobalLock(lppd
->hDevMode
);
1971 if(lppd
->Flags
& PD_RETURNDC
) {
1972 lppd
->hDC
= CreateDCW((WCHAR
*)pdn
+ pdn
->wDriverOffset
,
1973 (WCHAR
*)pdn
+ pdn
->wDeviceOffset
,
1974 (WCHAR
*)pdn
+ pdn
->wOutputOffset
,
1976 } else if(lppd
->Flags
& PD_RETURNIC
) {
1977 lppd
->hDC
= CreateICW((WCHAR
*)pdn
+ pdn
->wDriverOffset
,
1978 (WCHAR
*)pdn
+ pdn
->wDeviceOffset
,
1979 (WCHAR
*)pdn
+ pdn
->wOutputOffset
,
1982 GlobalUnlock(lppd
->hDevNames
);
1983 GlobalUnlock(lppd
->hDevMode
);
1984 return lppd
->hDC
? TRUE
: FALSE
;
1987 /***********************************************************************
1988 * PrintDlgA (COMDLG32.@)
1990 * Displays the the PRINT dialog box, which enables the user to specify
1991 * specific properties of the print job.
1994 * nonzero if the user pressed the OK button
1995 * zero if the user cancelled the window or an error occurred
1999 * * The Collate Icons do not display, even though they are in the code.
2000 * * The Properties Button(s) should call DocumentPropertiesA().
2002 * * The Paper Orientation Icons are not implemented yet.
2003 * * The Properties Button(s) should call DocumentPropertiesA().
2004 * * Settings are not yet taken from a provided DevMode or
2005 * default printer settings.
2008 BOOL WINAPI
PrintDlgA(
2009 LPPRINTDLGA lppd
/* [in/out] ptr to PRINTDLG32 struct */
2014 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongA( lppd
->hwndOwner
, GWL_HINSTANCE
);
2016 if(TRACE_ON(commdlg
)) {
2017 char flagstr
[1000] = "";
2018 struct pd_flags
*pflag
= pd_flags
;
2019 for( ; pflag
->name
; pflag
++) {
2020 if(lppd
->Flags
& pflag
->flag
)
2021 strcat(flagstr
, pflag
->name
);
2023 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2024 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
2025 "flags %08lx (%s)\n",
2026 lppd
, lppd
->hwndOwner
, lppd
->hDevMode
, lppd
->hDevNames
,
2027 lppd
->nFromPage
, lppd
->nToPage
, lppd
->nMinPage
, lppd
->nMaxPage
,
2028 lppd
->nCopies
, lppd
->hInstance
, lppd
->Flags
, flagstr
);
2031 if(lppd
->lStructSize
!= sizeof(PRINTDLGA
)) {
2032 WARN("structure size failure !!!\n");
2033 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE
);
2037 if(lppd
->Flags
& PD_RETURNDEFAULT
) {
2038 PRINTER_INFO_2A
*pbuf
;
2039 DRIVER_INFO_3A
*dbuf
;
2043 if(lppd
->hDevMode
|| lppd
->hDevNames
) {
2044 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
2045 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2048 if(!PRINTDLG_OpenDefaultPrinter(&hprn
)) {
2049 WARN("Can't find default printer\n");
2050 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN
);
2054 GetPrinterA(hprn
, 2, NULL
, 0, &needed
);
2055 pbuf
= HeapAlloc(GetProcessHeap(), 0, needed
);
2056 GetPrinterA(hprn
, 2, (LPBYTE
)pbuf
, needed
, &needed
);
2058 GetPrinterDriverA(hprn
, NULL
, 3, NULL
, 0, &needed
);
2059 dbuf
= HeapAlloc(GetProcessHeap(),0,needed
);
2060 if (!GetPrinterDriverA(hprn
, NULL
, 3, (LPBYTE
)dbuf
, needed
, &needed
)) {
2061 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf
->pPrinterName
);
2062 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2067 PRINTDLG_CreateDevNames(&(lppd
->hDevNames
),
2071 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
, pbuf
->pDevMode
->dmSize
+
2072 pbuf
->pDevMode
->dmDriverExtra
);
2073 ptr
= GlobalLock(lppd
->hDevMode
);
2074 memcpy(ptr
, pbuf
->pDevMode
, pbuf
->pDevMode
->dmSize
+
2075 pbuf
->pDevMode
->dmDriverExtra
);
2076 GlobalUnlock(lppd
->hDevMode
);
2077 HeapFree(GetProcessHeap(), 0, pbuf
);
2078 HeapFree(GetProcessHeap(), 0, dbuf
);
2082 PRINT_PTRA
*PrintStructures
;
2084 /* load Dialog resources,
2085 * depending on Flags indicates Print32 or Print32_setup dialog
2087 hDlgTmpl
= PRINTDLG_GetDlgTemplateA(lppd
);
2089 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2092 ptr
= LockResource( hDlgTmpl
);
2094 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2098 PrintStructures
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2099 sizeof(PRINT_PTRA
));
2100 PrintStructures
->dlg
.lpPrintDlg
= lppd
;
2102 /* and create & process the dialog .
2103 * -1 is failure, 0 is broken hwnd, everything else is ok.
2105 bRet
= (0<DialogBoxIndirectParamA(hInst
, ptr
, lppd
->hwndOwner
,
2107 (LPARAM
)PrintStructures
));
2110 DEVMODEA
*lpdm
= PrintStructures
->lpDevMode
, *lpdmReturn
;
2111 PRINTER_INFO_2A
*pi
= PrintStructures
->lpPrinterInfo
;
2112 DRIVER_INFO_3A
*di
= PrintStructures
->lpDriverInfo
;
2114 if (lppd
->hDevMode
== 0) {
2115 TRACE(" No hDevMode yet... Need to create my own\n");
2116 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
,
2117 lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2120 if((locks
= (GlobalFlags(lppd
->hDevMode
) & GMEM_LOCKCOUNT
))) {
2121 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks
);
2123 GlobalUnlock(lppd
->hDevMode
);
2124 TRACE("Now got %d locks\n", locks
);
2127 lppd
->hDevMode
= GlobalReAlloc(lppd
->hDevMode
,
2128 lpdm
->dmSize
+ lpdm
->dmDriverExtra
,
2131 lpdmReturn
= GlobalLock(lppd
->hDevMode
);
2132 memcpy(lpdmReturn
, lpdm
, lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2134 if (lppd
->hDevNames
!= 0) {
2136 if((locks
= (GlobalFlags(lppd
->hDevNames
) & GMEM_LOCKCOUNT
))) {
2137 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks
);
2139 GlobalUnlock(lppd
->hDevNames
);
2142 PRINTDLG_CreateDevNames(&(lppd
->hDevNames
),
2147 GlobalUnlock(lppd
->hDevMode
);
2149 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
2150 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpPrinterInfo
);
2151 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDriverInfo
);
2152 HeapFree(GetProcessHeap(), 0, PrintStructures
);
2154 if(bRet
&& (lppd
->Flags
& PD_RETURNDC
|| lppd
->Flags
& PD_RETURNIC
))
2155 bRet
= PRINTDLG_CreateDCA(lppd
);
2157 TRACE("exit! (%d)\n", bRet
);
2161 /***********************************************************************
2162 * PrintDlgW (COMDLG32.@)
2164 BOOL WINAPI
PrintDlgW(
2165 LPPRINTDLGW lppd
/* [in/out] ptr to PRINTDLG32 struct */
2170 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongW( lppd
->hwndOwner
, GWL_HINSTANCE
);
2172 if(TRACE_ON(commdlg
)) {
2173 char flagstr
[1000] = "";
2174 struct pd_flags
*pflag
= pd_flags
;
2175 for( ; pflag
->name
; pflag
++) {
2176 if(lppd
->Flags
& pflag
->flag
)
2177 strcat(flagstr
, pflag
->name
);
2179 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2180 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
2181 "flags %08lx (%s)\n",
2182 lppd
, lppd
->hwndOwner
, lppd
->hDevMode
, lppd
->hDevNames
,
2183 lppd
->nFromPage
, lppd
->nToPage
, lppd
->nMinPage
, lppd
->nMaxPage
,
2184 lppd
->nCopies
, lppd
->hInstance
, lppd
->Flags
, flagstr
);
2187 if(lppd
->lStructSize
!= sizeof(PRINTDLGW
)) {
2188 WARN("structure size failure !!!\n");
2189 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE
);
2193 if(lppd
->Flags
& PD_RETURNDEFAULT
) {
2194 PRINTER_INFO_2W
*pbuf
;
2195 DRIVER_INFO_3W
*dbuf
;
2199 if(lppd
->hDevMode
|| lppd
->hDevNames
) {
2200 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
2201 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2204 if(!PRINTDLG_OpenDefaultPrinter(&hprn
)) {
2205 WARN("Can't find default printer\n");
2206 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN
);
2210 GetPrinterW(hprn
, 2, NULL
, 0, &needed
);
2211 pbuf
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*needed
);
2212 GetPrinterW(hprn
, 2, (LPBYTE
)pbuf
, needed
, &needed
);
2214 GetPrinterDriverW(hprn
, NULL
, 3, NULL
, 0, &needed
);
2215 dbuf
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
2216 if (!GetPrinterDriverW(hprn
, NULL
, 3, (LPBYTE
)dbuf
, needed
, &needed
)) {
2217 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),debugstr_w(pbuf
->pPrinterName
));
2218 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2223 PRINTDLG_CreateDevNamesW(&(lppd
->hDevNames
),
2227 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
, pbuf
->pDevMode
->dmSize
+
2228 pbuf
->pDevMode
->dmDriverExtra
);
2229 ptr
= GlobalLock(lppd
->hDevMode
);
2230 memcpy(ptr
, pbuf
->pDevMode
, pbuf
->pDevMode
->dmSize
+
2231 pbuf
->pDevMode
->dmDriverExtra
);
2232 GlobalUnlock(lppd
->hDevMode
);
2233 HeapFree(GetProcessHeap(), 0, pbuf
);
2234 HeapFree(GetProcessHeap(), 0, dbuf
);
2238 PRINT_PTRW
*PrintStructures
;
2240 /* load Dialog resources,
2241 * depending on Flags indicates Print32 or Print32_setup dialog
2243 hDlgTmpl
= PRINTDLG_GetDlgTemplateW(lppd
);
2245 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2248 ptr
= LockResource( hDlgTmpl
);
2250 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2254 PrintStructures
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2255 sizeof(PRINT_PTRW
));
2256 PrintStructures
->dlg
.lpPrintDlg
= lppd
;
2258 /* and create & process the dialog .
2259 * -1 is failure, 0 is broken hwnd, everything else is ok.
2261 bRet
= (0<DialogBoxIndirectParamW(hInst
, ptr
, lppd
->hwndOwner
,
2263 (LPARAM
)PrintStructures
));
2266 DEVMODEW
*lpdm
= PrintStructures
->lpDevMode
, *lpdmReturn
;
2267 PRINTER_INFO_2W
*pi
= PrintStructures
->lpPrinterInfo
;
2268 DRIVER_INFO_3W
*di
= PrintStructures
->lpDriverInfo
;
2270 if (lppd
->hDevMode
== 0) {
2271 TRACE(" No hDevMode yet... Need to create my own\n");
2272 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
,
2273 lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2276 if((locks
= (GlobalFlags(lppd
->hDevMode
) & GMEM_LOCKCOUNT
))) {
2277 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks
);
2279 GlobalUnlock(lppd
->hDevMode
);
2280 TRACE("Now got %d locks\n", locks
);
2283 lppd
->hDevMode
= GlobalReAlloc(lppd
->hDevMode
,
2284 lpdm
->dmSize
+ lpdm
->dmDriverExtra
,
2287 lpdmReturn
= GlobalLock(lppd
->hDevMode
);
2288 memcpy(lpdmReturn
, lpdm
, lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2290 if (lppd
->hDevNames
!= 0) {
2292 if((locks
= (GlobalFlags(lppd
->hDevNames
) & GMEM_LOCKCOUNT
))) {
2293 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks
);
2295 GlobalUnlock(lppd
->hDevNames
);
2298 PRINTDLG_CreateDevNamesW(&(lppd
->hDevNames
),
2303 GlobalUnlock(lppd
->hDevMode
);
2305 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
2306 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpPrinterInfo
);
2307 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDriverInfo
);
2308 HeapFree(GetProcessHeap(), 0, PrintStructures
);
2310 if(bRet
&& (lppd
->Flags
& PD_RETURNDC
|| lppd
->Flags
& PD_RETURNIC
))
2311 bRet
= PRINTDLG_CreateDCW(lppd
);
2313 TRACE("exit! (%d)\n", bRet
);
2317 /***********************************************************************
2323 * cmb3 - source (tray?)
2324 * edt4 - border left
2326 * edt6 - border right
2327 * edt7 - border bottom
2328 * psh3 - "Printer..."
2332 LPPAGESETUPDLGA dlga
;
2337 LPPAGESETUPDLGW dlga
;
2341 static HGLOBAL
PRINTDLG_GetPGSTemplateA(PAGESETUPDLGA
*lppd
)
2346 if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATEHANDLE
) {
2347 hDlgTmpl
= lppd
->hPageSetupTemplate
;
2348 } else if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATE
) {
2349 hResInfo
= FindResourceA(lppd
->hInstance
,
2350 lppd
->lpPageSetupTemplateName
, (LPSTR
)RT_DIALOG
);
2351 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2353 hResInfo
= FindResourceA(COMDLG32_hInstance
,(LPCSTR
)PAGESETUPDLGORD
,(LPSTR
)RT_DIALOG
);
2354 hDlgTmpl
= LoadResource(COMDLG32_hInstance
,hResInfo
);
2359 static HGLOBAL
PRINTDLG_GetPGSTemplateW(PAGESETUPDLGW
*lppd
)
2364 if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATEHANDLE
) {
2365 hDlgTmpl
= lppd
->hPageSetupTemplate
;
2366 } else if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATE
) {
2367 hResInfo
= FindResourceW(lppd
->hInstance
,
2368 lppd
->lpPageSetupTemplateName
, (LPWSTR
)RT_DIALOG
);
2369 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2371 hResInfo
= FindResourceW(COMDLG32_hInstance
,(LPCWSTR
)PAGESETUPDLGORD
,(LPWSTR
)RT_DIALOG
);
2372 hDlgTmpl
= LoadResource(COMDLG32_hInstance
,hResInfo
);
2378 _c_10mm2size(PAGESETUPDLGA
*dlga
,DWORD size
) {
2379 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2380 return 10*size
*10/25.4;
2381 /* If we don't have a flag, we can choose one. Use millimeters
2382 * to avoid confusing me
2384 dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2390 _c_inch2size(PAGESETUPDLGA
*dlga
,DWORD size
) {
2391 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2393 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
)
2394 return (size
*254)/10;
2395 /* if we don't have a flag, we can choose one. Use millimeters
2396 * to avoid confusing me
2398 dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2399 return (size
*254)/10;
2403 _c_size2strA(PageSetupDataA
*pda
,DWORD size
,LPSTR strout
) {
2404 strcpy(strout
,"<undef>");
2405 if (pda
->dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2406 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2409 if (pda
->dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2410 sprintf(strout
,"%.2fin",(size
*1.0)/1000.0);
2413 pda
->dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2414 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2418 _c_size2strW(PageSetupDataW
*pda
,DWORD size
,LPSTR strout
) {
2419 strcpy(strout
,"<undef>");
2420 if (pda
->dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2421 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2424 if (pda
->dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2425 sprintf(strout
,"%.2fin",(size
*1.0)/1000.0);
2428 pda
->dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2429 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2434 _c_str2size(PAGESETUPDLGA
*dlga
,LPCSTR strin
) {
2439 if (!sscanf(strin
,"%f%s",&val
,rest
))
2442 if (!strcmp(rest
,"in") || !strcmp(rest
,"inch")) {
2443 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2446 return val
*25.4*100;
2448 if (!strcmp(rest
,"cm")) { rest
[0]='m'; val
= val
*10.0; }
2449 if (!strcmp(rest
,"m")) { strcpy(rest
,"mm"); val
= val
*1000.0; }
2451 if (!strcmp(rest
,"mm")) {
2452 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
)
2455 return 1000.0*val
/25.4;
2457 if (rest
[0]=='\0') {
2458 /* use application supplied default */
2459 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2463 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2468 ERR("Did not find a conversion for type '%s'!\n",rest
);
2474 * This is called on finish and will update the output fields of the
2478 PRINTDLG_PS_UpdateDlgStructA(HWND hDlg
, PageSetupDataA
*pda
) {
2481 LPSTR devname
,portname
;
2485 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
2486 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
2487 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
2488 portname
= ((char*)dn
)+dn
->wOutputOffset
;
2489 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb2
,devname
,portname
,dm
);
2490 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb3
,devname
,portname
,dm
);
2492 if (GetDlgItemTextA(hDlg
,cmb2
,papername
,sizeof(papername
))>0) {
2493 PRINTDLG_PaperSizeA(&(pda
->pdlg
),papername
,&(pda
->dlga
->ptPaperSize
));
2494 pda
->dlga
->ptPaperSize
.x
= _c_10mm2size(pda
->dlga
,pda
->dlga
->ptPaperSize
.x
);
2495 pda
->dlga
->ptPaperSize
.y
= _c_10mm2size(pda
->dlga
,pda
->dlga
->ptPaperSize
.y
);
2497 FIXME("could not get dialog text for papersize cmbbox?\n");
2498 #define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size(pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }
2499 GETVAL(edt4
,pda
->dlga
->rtMargin
.left
);
2500 GETVAL(edt5
,pda
->dlga
->rtMargin
.top
);
2501 GETVAL(edt6
,pda
->dlga
->rtMargin
.right
);
2502 GETVAL(edt7
,pda
->dlga
->rtMargin
.bottom
);
2505 /* If we are in landscape, swap x and y of page size */
2506 if (IsDlgButtonChecked(hDlg
, rad2
)) {
2508 tmp
= pda
->dlga
->ptPaperSize
.x
;
2509 pda
->dlga
->ptPaperSize
.x
= pda
->dlga
->ptPaperSize
.y
;
2510 pda
->dlga
->ptPaperSize
.y
= tmp
;
2512 GlobalUnlock(pda
->pdlg
.hDevNames
);
2513 GlobalUnlock(pda
->pdlg
.hDevMode
);
2518 PRINTDLG_PS_UpdateDlgStructW(HWND hDlg
, PageSetupDataW
*pda
) {
2521 LPWSTR devname
,portname
;
2522 WCHAR papername
[64];
2526 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
2527 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
2528 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
2529 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
2530 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb2
,devname
,portname
,dm
);
2531 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb3
,devname
,portname
,dm
);
2533 if (GetDlgItemTextW(hDlg
,cmb2
,papername
,sizeof(papername
))>0) {
2534 PRINTDLG_PaperSizeW(&(pda
->pdlg
),papername
,&(pda
->dlga
->ptPaperSize
));
2535 pda
->dlga
->ptPaperSize
.x
= _c_10mm2size((LPPAGESETUPDLGA
)pda
->dlga
,pda
->dlga
->ptPaperSize
.x
);
2536 pda
->dlga
->ptPaperSize
.y
= _c_10mm2size((LPPAGESETUPDLGA
)pda
->dlga
,pda
->dlga
->ptPaperSize
.y
);
2538 FIXME("could not get dialog text for papersize cmbbox?\n");
2539 #define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size((LPPAGESETUPDLGA)pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }
2540 GETVAL(edt4
,pda
->dlga
->rtMargin
.left
);
2541 GETVAL(edt5
,pda
->dlga
->rtMargin
.top
);
2542 GETVAL(edt6
,pda
->dlga
->rtMargin
.right
);
2543 GETVAL(edt7
,pda
->dlga
->rtMargin
.bottom
);
2546 /* If we are in landscape, swap x and y of page size */
2547 if (IsDlgButtonChecked(hDlg
, rad2
)) {
2549 tmp
= pda
->dlga
->ptPaperSize
.x
;
2550 pda
->dlga
->ptPaperSize
.x
= pda
->dlga
->ptPaperSize
.y
;
2551 pda
->dlga
->ptPaperSize
.y
= tmp
;
2553 GlobalUnlock(pda
->pdlg
.hDevNames
);
2554 GlobalUnlock(pda
->pdlg
.hDevMode
);
2559 * This is called after returning from PrintDlg().
2562 PRINTDLG_PS_ChangePrinterA(HWND hDlg
, PageSetupDataA
*pda
) {
2565 LPSTR devname
,portname
;
2567 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
2568 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
2569 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
2570 portname
= ((char*)dn
)+dn
->wOutputOffset
;
2571 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb2
,devname
,portname
,dm
);
2572 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb3
,devname
,portname
,dm
);
2573 GlobalUnlock(pda
->pdlg
.hDevNames
);
2574 GlobalUnlock(pda
->pdlg
.hDevMode
);
2579 PRINTDLG_PS_ChangePrinterW(HWND hDlg
, PageSetupDataW
*pda
) {
2582 LPWSTR devname
,portname
;
2584 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
2585 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
2586 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
2587 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
2588 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb2
,devname
,portname
,dm
);
2589 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb3
,devname
,portname
,dm
);
2590 GlobalUnlock(pda
->pdlg
.hDevNames
);
2591 GlobalUnlock(pda
->pdlg
.hDevMode
);
2596 PRINTDLG_PS_WMCommandA(
2597 HWND hDlg
, WPARAM wParam
, LPARAM lParam
, PageSetupDataA
*pda
2599 switch (LOWORD(wParam
)) {
2601 if (!PRINTDLG_PS_UpdateDlgStructA(hDlg
, pda
))
2603 EndDialog(hDlg
, TRUE
);
2607 EndDialog(hDlg
, FALSE
);
2611 pda
->pdlg
.Flags
= 0;
2612 pda
->pdlg
.hwndOwner
= hDlg
;
2613 if (PrintDlgA(&(pda
->pdlg
)))
2614 PRINTDLG_PS_ChangePrinterA(hDlg
,pda
);
2618 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
2619 LOWORD(lParam
),wParam
,lParam
2625 PRINTDLG_PS_WMCommandW(
2626 HWND hDlg
, WPARAM wParam
, LPARAM lParam
, PageSetupDataW
*pda
2628 switch (LOWORD(wParam
)) {
2630 if (!PRINTDLG_PS_UpdateDlgStructW(hDlg
, pda
))
2632 EndDialog(hDlg
, TRUE
);
2636 EndDialog(hDlg
, FALSE
);
2640 pda
->pdlg
.Flags
= 0;
2641 pda
->pdlg
.hwndOwner
= hDlg
;
2642 if (PrintDlgW(&(pda
->pdlg
)))
2643 PRINTDLG_PS_ChangePrinterW(hDlg
,pda
);
2647 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
2648 LOWORD(lParam
),wParam
,lParam
2654 static INT_PTR CALLBACK
2655 PageDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2657 PageSetupDataA
*pda
;
2658 INT_PTR res
= FALSE
;
2660 if (uMsg
==WM_INITDIALOG
) {
2662 pda
= (PageSetupDataA
*)lParam
;
2663 SetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA",pda
);
2664 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
2665 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
2667 FIXME("Setup page hook failed?\n");
2671 if (pda
->dlga
->Flags
& PSD_ENABLEPAGEPAINTHOOK
) {
2672 FIXME("PagePaintHook not yet implemented!\n");
2674 if (pda
->dlga
->Flags
& PSD_DISABLEPRINTER
)
2675 EnableWindow(GetDlgItem(hDlg
, psh3
), FALSE
);
2676 if (pda
->dlga
->Flags
& PSD_DISABLEMARGINS
) {
2677 EnableWindow(GetDlgItem(hDlg
, edt4
), FALSE
);
2678 EnableWindow(GetDlgItem(hDlg
, edt5
), FALSE
);
2679 EnableWindow(GetDlgItem(hDlg
, edt6
), FALSE
);
2680 EnableWindow(GetDlgItem(hDlg
, edt7
), FALSE
);
2682 /* width larger as height -> landscape */
2683 if (pda
->dlga
->ptPaperSize
.x
> pda
->dlga
->ptPaperSize
.y
)
2684 CheckRadioButton(hDlg
, rad1
, rad2
, rad2
);
2685 else /* this is default if papersize is not set */
2686 CheckRadioButton(hDlg
, rad1
, rad2
, rad1
);
2687 if (pda
->dlga
->Flags
& PSD_DISABLEORIENTATION
) {
2688 EnableWindow(GetDlgItem(hDlg
,rad1
),FALSE
);
2689 EnableWindow(GetDlgItem(hDlg
,rad2
),FALSE
);
2691 /* We fill them out enabled or not */
2692 if (pda
->dlga
->Flags
& PSD_MARGINS
) {
2694 _c_size2strA(pda
,pda
->dlga
->rtMargin
.left
,str
);
2695 SetDlgItemTextA(hDlg
,edt4
,str
);
2696 _c_size2strA(pda
,pda
->dlga
->rtMargin
.top
,str
);
2697 SetDlgItemTextA(hDlg
,edt5
,str
);
2698 _c_size2strA(pda
,pda
->dlga
->rtMargin
.right
,str
);
2699 SetDlgItemTextA(hDlg
,edt6
,str
);
2700 _c_size2strA(pda
,pda
->dlga
->rtMargin
.bottom
,str
);
2701 SetDlgItemTextA(hDlg
,edt7
,str
);
2703 /* default is 1 inch */
2704 DWORD size
= _c_inch2size(pda
->dlga
,1000);
2706 _c_size2strA(pda
,size
,str
);
2707 SetDlgItemTextA(hDlg
,edt4
,str
);
2708 SetDlgItemTextA(hDlg
,edt5
,str
);
2709 SetDlgItemTextA(hDlg
,edt6
,str
);
2710 SetDlgItemTextA(hDlg
,edt7
,str
);
2712 PRINTDLG_PS_ChangePrinterA(hDlg
,pda
);
2713 if (pda
->dlga
->Flags
& PSD_DISABLEPAPER
) {
2714 EnableWindow(GetDlgItem(hDlg
,cmb2
),FALSE
);
2715 EnableWindow(GetDlgItem(hDlg
,cmb3
),FALSE
);
2719 pda
= (PageSetupDataA
*)GetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA");
2721 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
2724 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
2725 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
2726 if (res
) return res
;
2731 return PRINTDLG_PS_WMCommandA(hDlg
, wParam
, lParam
, pda
);
2736 static INT_PTR CALLBACK
2737 PageDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2739 PageSetupDataW
*pda
;
2742 if (uMsg
==WM_INITDIALOG
) {
2744 pda
= (PageSetupDataW
*)lParam
;
2745 SetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA",pda
);
2746 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
2747 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
2749 FIXME("Setup page hook failed?\n");
2753 if (pda
->dlga
->Flags
& PSD_ENABLEPAGEPAINTHOOK
) {
2754 FIXME("PagePaintHook not yet implemented!\n");
2756 if (pda
->dlga
->Flags
& PSD_DISABLEPRINTER
)
2757 EnableWindow(GetDlgItem(hDlg
, psh3
), FALSE
);
2758 if (pda
->dlga
->Flags
& PSD_DISABLEMARGINS
) {
2759 EnableWindow(GetDlgItem(hDlg
, edt4
), FALSE
);
2760 EnableWindow(GetDlgItem(hDlg
, edt5
), FALSE
);
2761 EnableWindow(GetDlgItem(hDlg
, edt6
), FALSE
);
2762 EnableWindow(GetDlgItem(hDlg
, edt7
), FALSE
);
2764 /* width larger as height -> landscape */
2765 if (pda
->dlga
->ptPaperSize
.x
> pda
->dlga
->ptPaperSize
.y
)
2766 CheckRadioButton(hDlg
, rad1
, rad2
, rad2
);
2767 else /* this is default if papersize is not set */
2768 CheckRadioButton(hDlg
, rad1
, rad2
, rad1
);
2769 if (pda
->dlga
->Flags
& PSD_DISABLEORIENTATION
) {
2770 EnableWindow(GetDlgItem(hDlg
,rad1
),FALSE
);
2771 EnableWindow(GetDlgItem(hDlg
,rad2
),FALSE
);
2773 /* We fill them out enabled or not */
2774 if (pda
->dlga
->Flags
& PSD_MARGINS
) {
2776 _c_size2strW(pda
,pda
->dlga
->rtMargin
.left
,str
);
2777 SetDlgItemTextA(hDlg
,edt4
,str
);
2778 _c_size2strW(pda
,pda
->dlga
->rtMargin
.top
,str
);
2779 SetDlgItemTextA(hDlg
,edt5
,str
);
2780 _c_size2strW(pda
,pda
->dlga
->rtMargin
.right
,str
);
2781 SetDlgItemTextA(hDlg
,edt6
,str
);
2782 _c_size2strW(pda
,pda
->dlga
->rtMargin
.bottom
,str
);
2783 SetDlgItemTextA(hDlg
,edt7
,str
);
2785 /* default is 1 inch */
2786 DWORD size
= _c_inch2size((LPPAGESETUPDLGA
)pda
->dlga
,1000);
2788 _c_size2strW(pda
,size
,str
);
2789 SetDlgItemTextA(hDlg
,edt4
,str
);
2790 SetDlgItemTextA(hDlg
,edt5
,str
);
2791 SetDlgItemTextA(hDlg
,edt6
,str
);
2792 SetDlgItemTextA(hDlg
,edt7
,str
);
2794 PRINTDLG_PS_ChangePrinterW(hDlg
,pda
);
2795 if (pda
->dlga
->Flags
& PSD_DISABLEPAPER
) {
2796 EnableWindow(GetDlgItem(hDlg
,cmb2
),FALSE
);
2797 EnableWindow(GetDlgItem(hDlg
,cmb3
),FALSE
);
2801 pda
= (PageSetupDataW
*)GetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA");
2803 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
2806 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
2807 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
2808 if (res
) return res
;
2813 return PRINTDLG_PS_WMCommandW(hDlg
, wParam
, lParam
, pda
);
2818 /***********************************************************************
2819 * PageSetupDlgA (COMDLG32.@)
2821 BOOL WINAPI
PageSetupDlgA(LPPAGESETUPDLGA setupdlg
) {
2825 PageSetupDataA
*pda
;
2828 if(TRACE_ON(commdlg
)) {
2829 char flagstr
[1000] = "";
2830 struct pd_flags
*pflag
= psd_flags
;
2831 for( ; pflag
->name
; pflag
++) {
2832 if(setupdlg
->Flags
& pflag
->flag
) {
2833 strcat(flagstr
, pflag
->name
);
2834 strcat(flagstr
, "|");
2837 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2838 "hinst %p, flags %08lx (%s)\n",
2839 setupdlg
, setupdlg
->hwndOwner
, setupdlg
->hDevMode
,
2840 setupdlg
->hDevNames
,
2841 setupdlg
->hInstance
, setupdlg
->Flags
, flagstr
);
2844 /* First get default printer data, we need it right after that. */
2845 memset(&pdlg
,0,sizeof(pdlg
));
2846 pdlg
.lStructSize
= sizeof(pdlg
);
2847 pdlg
.Flags
= PD_RETURNDEFAULT
;
2848 bRet
= PrintDlgA(&pdlg
);
2849 if (!bRet
) return FALSE
;
2851 /* short cut exit, just return default values */
2852 if (setupdlg
->Flags
& PSD_RETURNDEFAULT
) {
2853 setupdlg
->hDevMode
= pdlg
.hDevMode
;
2854 setupdlg
->hDevNames
= pdlg
.hDevNames
;
2855 /* FIXME: Just return "A4" for now. */
2856 PRINTDLG_PaperSizeA(&pdlg
,"A4",&setupdlg
->ptPaperSize
);
2857 setupdlg
->ptPaperSize
.x
=_c_10mm2size(setupdlg
,setupdlg
->ptPaperSize
.x
);
2858 setupdlg
->ptPaperSize
.y
=_c_10mm2size(setupdlg
,setupdlg
->ptPaperSize
.y
);
2861 hDlgTmpl
= PRINTDLG_GetPGSTemplateA(setupdlg
);
2863 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2866 ptr
= LockResource( hDlgTmpl
);
2868 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2871 pda
= HeapAlloc(GetProcessHeap(),0,sizeof(*pda
));
2872 pda
->dlga
= setupdlg
;
2873 memcpy(&pda
->pdlg
,&pdlg
,sizeof(pdlg
));
2875 bRet
= (0<DialogBoxIndirectParamA(
2876 setupdlg
->hInstance
,
2878 setupdlg
->hwndOwner
,
2884 /***********************************************************************
2885 * PageSetupDlgW (COMDLG32.@)
2887 BOOL WINAPI
PageSetupDlgW(LPPAGESETUPDLGW setupdlg
) {
2891 PageSetupDataW
*pdw
;
2894 if(TRACE_ON(commdlg
)) {
2895 char flagstr
[1000] = "";
2896 struct pd_flags
*pflag
= psd_flags
;
2897 for( ; pflag
->name
; pflag
++) {
2898 if(setupdlg
->Flags
& pflag
->flag
) {
2899 strcat(flagstr
, pflag
->name
);
2900 strcat(flagstr
, "|");
2903 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2904 "hinst %p, flags %08lx (%s)\n",
2905 setupdlg
, setupdlg
->hwndOwner
, setupdlg
->hDevMode
,
2906 setupdlg
->hDevNames
,
2907 setupdlg
->hInstance
, setupdlg
->Flags
, flagstr
);
2910 /* First get default printer data, we need it right after that. */
2911 memset(&pdlg
,0,sizeof(pdlg
));
2912 pdlg
.lStructSize
= sizeof(pdlg
);
2913 pdlg
.Flags
= PD_RETURNDEFAULT
;
2914 bRet
= PrintDlgW(&pdlg
);
2915 if (!bRet
) return FALSE
;
2917 /* short cut exit, just return default values */
2918 if (setupdlg
->Flags
& PSD_RETURNDEFAULT
) {
2919 const WCHAR a4
[] = {'A','4',0};
2920 setupdlg
->hDevMode
= pdlg
.hDevMode
;
2921 setupdlg
->hDevNames
= pdlg
.hDevNames
;
2922 /* FIXME: Just return "A4" for now. */
2923 PRINTDLG_PaperSizeW(&pdlg
,a4
,&setupdlg
->ptPaperSize
);
2924 setupdlg
->ptPaperSize
.x
=_c_10mm2size((LPPAGESETUPDLGA
)setupdlg
,setupdlg
->ptPaperSize
.x
);
2925 setupdlg
->ptPaperSize
.y
=_c_10mm2size((LPPAGESETUPDLGA
)setupdlg
,setupdlg
->ptPaperSize
.y
);
2928 hDlgTmpl
= PRINTDLG_GetPGSTemplateW(setupdlg
);
2930 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2933 ptr
= LockResource( hDlgTmpl
);
2935 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2938 pdw
= HeapAlloc(GetProcessHeap(),0,sizeof(*pdw
));
2939 pdw
->dlga
= setupdlg
;
2940 memcpy(&pdw
->pdlg
,&pdlg
,sizeof(pdlg
));
2942 bRet
= (0<DialogBoxIndirectParamW(
2943 setupdlg
->hInstance
,
2945 setupdlg
->hwndOwner
,
2952 /***********************************************************************
2953 * PrintDlgExA (COMDLG32.@)
2955 HRESULT WINAPI
PrintDlgExA(LPVOID lpPrintDlgExA
) /* [???] FIXME: LPPRINTDLGEXA */
2960 /***********************************************************************
2961 * PrintDlgExW (COMDLG32.@)
2963 HRESULT WINAPI
PrintDlgExW(LPVOID lpPrintDlgExW
) /* [???] FIXME: LPPRINTDLGEXW */