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
28 #define NONAMELESSUNION
29 #define NONAMELESSSTRUCT
33 #include "wine/wingdi16.h"
35 #include "wine/winuser16.h"
38 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
47 /* This PRINTDLGA internal structure stores
48 * pointers to several throughout useful structures.
55 LPPRINTDLGA lpPrintDlg
;
56 LPPRINTDLG16 lpPrintDlg16
;
58 LPPRINTER_INFO_2A lpPrinterInfo
;
59 LPDRIVER_INFO_3A lpDriverInfo
;
61 HICON hCollateIcon
; /* PrintDlg only */
62 HICON hNoCollateIcon
; /* PrintDlg only */
63 HICON hPortraitIcon
; /* PrintSetupDlg only */
64 HICON hLandscapeIcon
; /* PrintSetupDlg only */
72 LPPRINTDLGW lpPrintDlg
;
74 LPPRINTER_INFO_2W lpPrinterInfo
;
75 LPDRIVER_INFO_3W lpDriverInfo
;
77 HICON hCollateIcon
; /* PrintDlg only */
78 HICON hNoCollateIcon
; /* PrintDlg only */
79 HICON hPortraitIcon
; /* PrintSetupDlg only */
80 HICON hLandscapeIcon
; /* PrintSetupDlg only */
85 static struct pd_flags
{
89 {PD_SELECTION
, "PD_SELECTION "},
90 {PD_PAGENUMS
, "PD_PAGENUMS "},
91 {PD_NOSELECTION
, "PD_NOSELECTION "},
92 {PD_NOPAGENUMS
, "PD_NOPAGENUMS "},
93 {PD_COLLATE
, "PD_COLLATE "},
94 {PD_PRINTTOFILE
, "PD_PRINTTOFILE "},
95 {PD_PRINTSETUP
, "PD_PRINTSETUP "},
96 {PD_NOWARNING
, "PD_NOWARNING "},
97 {PD_RETURNDC
, "PD_RETURNDC "},
98 {PD_RETURNIC
, "PD_RETURNIC "},
99 {PD_RETURNDEFAULT
, "PD_RETURNDEFAULT "},
100 {PD_SHOWHELP
, "PD_SHOWHELP "},
101 {PD_ENABLEPRINTHOOK
, "PD_ENABLEPRINTHOOK "},
102 {PD_ENABLESETUPHOOK
, "PD_ENABLESETUPHOOK "},
103 {PD_ENABLEPRINTTEMPLATE
, "PD_ENABLEPRINTTEMPLATE "},
104 {PD_ENABLESETUPTEMPLATE
, "PD_ENABLESETUPTEMPLATE "},
105 {PD_ENABLEPRINTTEMPLATEHANDLE
, "PD_ENABLEPRINTTEMPLATEHANDLE "},
106 {PD_ENABLESETUPTEMPLATEHANDLE
, "PD_ENABLESETUPTEMPLATEHANDLE "},
107 {PD_USEDEVMODECOPIES
, "PD_USEDEVMODECOPIES[ANDCOLLATE] "},
108 {PD_DISABLEPRINTTOFILE
, "PD_DISABLEPRINTTOFILE "},
109 {PD_HIDEPRINTTOFILE
, "PD_HIDEPRINTTOFILE "},
110 {PD_NONETWORKBUTTON
, "PD_NONETWORKBUTTON "},
115 static struct pd_flags psd_flags
[] = {
116 {PSD_MINMARGINS
,"PSD_MINMARGINS"},
117 {PSD_MARGINS
,"PSD_MARGINS"},
118 {PSD_INTHOUSANDTHSOFINCHES
,"PSD_INTHOUSANDTHSOFINCHES"},
119 {PSD_INHUNDREDTHSOFMILLIMETERS
,"PSD_INHUNDREDTHSOFMILLIMETERS"},
120 {PSD_DISABLEMARGINS
,"PSD_DISABLEMARGINS"},
121 {PSD_DISABLEPRINTER
,"PSD_DISABLEPRINTER"},
122 {PSD_NOWARNING
,"PSD_NOWARNING"},
123 {PSD_DISABLEORIENTATION
,"PSD_DISABLEORIENTATION"},
124 {PSD_RETURNDEFAULT
,"PSD_RETURNDEFAULT"},
125 {PSD_DISABLEPAPER
,"PSD_DISABLEPAPER"},
126 {PSD_SHOWHELP
,"PSD_SHOWHELP"},
127 {PSD_ENABLEPAGESETUPHOOK
,"PSD_ENABLEPAGESETUPHOOK"},
128 {PSD_ENABLEPAGESETUPTEMPLATE
,"PSD_ENABLEPAGESETUPTEMPLATE"},
129 {PSD_ENABLEPAGESETUPTEMPLATEHANDLE
,"PSD_ENABLEPAGESETUPTEMPLATEHANDLE"},
130 {PSD_ENABLEPAGEPAINTHOOK
,"PSD_ENABLEPAGEPAINTHOOK"},
131 {PSD_DISABLEPAGEPAINTING
,"PSD_DISABLEPAGEPAINTING"},
135 /* Yes these constants are the same, but we're just copying win98 */
136 #define UPDOWN_ID 0x270f
137 #define MAX_COPIES 9999
139 /***********************************************************************
140 * PRINTDLG_GetDefaultPrinterName
142 * Returns the default printer name in buf.
143 * Even under WinNT/2000 default printer is retrieved via GetProfileString -
144 * these entries are mapped somewhere in the registry rather than win.ini.
146 * Returns TRUE on success else FALSE
148 static BOOL
PRINTDLG_GetDefaultPrinterNameA(LPSTR buf
, DWORD len
)
152 if(!GetProfileStringA("windows", "device", "", buf
, len
)) {
153 TRACE("No profile entry for default printer found.\n");
156 if((ptr
= strchr(buf
, ',')) == NULL
) {
157 FIXME("bad format for default printer (%s)!\n",buf
);
164 static BOOL
PRINTDLG_GetDefaultPrinterNameW(LPWSTR buf
, DWORD len
)
166 LPSTR ptr
, bufA
= (LPSTR
)HeapAlloc(GetProcessHeap(),0,len
+1);
169 if(!GetProfileStringA("windows", "device", "", bufA
, len
)) {
170 TRACE("No profile entry for default printer found.\n");
171 HeapFree(GetProcessHeap(),0,bufA
);
174 if((ptr
= strchr(bufA
, ',')) == NULL
) {
175 FIXME("bad format for default printer (%s)!\n",bufA
);
176 HeapFree(GetProcessHeap(),0,bufA
);
180 MultiByteToWideChar( CP_ACP
, 0, bufA
, -1, buf
, len
);
181 HeapFree(GetProcessHeap(),0,bufA
);
185 /***********************************************************************
186 * PRINTDLG_OpenDefaultPrinter
188 * Returns a winspool printer handle to the default printer in *hprn
189 * Caller must call ClosePrinter on the handle
191 * Returns TRUE on success else FALSE
193 static BOOL
PRINTDLG_OpenDefaultPrinter(HANDLE
*hprn
)
197 if(!PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
)))
199 res
= OpenPrinterA(buf
, hprn
, NULL
);
201 FIXME("Could not open printer %s?!\n",buf
);
205 /***********************************************************************
206 * PRINTDLG_SetUpPrinterListCombo
208 * Initializes printer list combox.
209 * hDlg: HWND of dialog
210 * id: Control id of combo
211 * name: Name of printer to select
213 * Initializes combo with list of available printers. Selects printer 'name'
214 * If name is NULL or does not exist select the default printer.
216 * Returns number of printers added to list.
218 static INT
PRINTDLG_SetUpPrinterListComboA(HWND hDlg
, UINT id
, LPCSTR name
)
222 LPPRINTER_INFO_2A pi
;
223 EnumPrintersA(PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &needed
, &num
);
224 pi
= HeapAlloc(GetProcessHeap(), 0, needed
);
225 EnumPrintersA(PRINTER_ENUM_LOCAL
, NULL
, 2, (LPBYTE
)pi
, needed
, &needed
,
228 for(i
= 0; i
< num
; i
++) {
229 SendDlgItemMessageA(hDlg
, id
, CB_ADDSTRING
, 0,
230 (LPARAM
)pi
[i
].pPrinterName
);
232 HeapFree(GetProcessHeap(), 0, pi
);
234 (i
= SendDlgItemMessageA(hDlg
, id
, CB_FINDSTRINGEXACT
, -1,
235 (LPARAM
)name
)) == CB_ERR
) {
238 FIXME("Can't find '%s' in printer list so trying to find default\n",
240 if(!PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
)))
242 i
= SendDlgItemMessageA(hDlg
, id
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buf
);
244 FIXME("Can't find default printer in printer list\n");
246 SendDlgItemMessageA(hDlg
, id
, CB_SETCURSEL
, i
, 0);
250 static INT
PRINTDLG_SetUpPrinterListComboW(HWND hDlg
, UINT id
, LPCWSTR name
)
254 LPPRINTER_INFO_2W pi
;
255 EnumPrintersW(PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &needed
, &num
);
256 pi
= HeapAlloc(GetProcessHeap(), 0, needed
);
257 EnumPrintersW(PRINTER_ENUM_LOCAL
, NULL
, 2, (LPBYTE
)pi
, needed
, &needed
,
260 for(i
= 0; i
< num
; i
++) {
261 SendDlgItemMessageW(hDlg
, id
, CB_ADDSTRING
, 0,
262 (LPARAM
)pi
[i
].pPrinterName
);
264 HeapFree(GetProcessHeap(), 0, pi
);
266 (i
= SendDlgItemMessageW(hDlg
, id
, CB_FINDSTRINGEXACT
, -1,
267 (LPARAM
)name
)) == CB_ERR
) {
271 FIXME("Can't find '%s' in printer list so trying to find default\n",
273 if(!PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
)))
275 i
= SendDlgItemMessageA(hDlg
, id
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buf
);
277 FIXME("Can't find default printer in printer list\n");
279 SendDlgItemMessageW(hDlg
, id
, CB_SETCURSEL
, i
, 0);
283 /***********************************************************************
284 * PRINTDLG_CreateDevNames [internal]
287 * creates a DevNames structure.
289 * (NB. when we handle unicode the offsets will be in wchars).
291 static BOOL
PRINTDLG_CreateDevNames(HGLOBAL
*hmem
, char* DeviceDriverName
,
292 char* DeviceName
, char* OutputPort
)
295 char* pDevNamesSpace
;
297 LPDEVNAMES lpDevNames
;
300 size
= strlen(DeviceDriverName
) + 1
301 + strlen(DeviceName
) + 1
302 + strlen(OutputPort
) + 1
306 *hmem
= GlobalReAlloc(*hmem
, size
, GMEM_MOVEABLE
);
308 *hmem
= GlobalAlloc(GMEM_MOVEABLE
, size
);
312 pDevNamesSpace
= GlobalLock(*hmem
);
313 lpDevNames
= (LPDEVNAMES
) pDevNamesSpace
;
315 pTempPtr
= pDevNamesSpace
+ sizeof(DEVNAMES
);
316 strcpy(pTempPtr
, DeviceDriverName
);
317 lpDevNames
->wDriverOffset
= pTempPtr
- pDevNamesSpace
;
319 pTempPtr
+= strlen(DeviceDriverName
) + 1;
320 strcpy(pTempPtr
, DeviceName
);
321 lpDevNames
->wDeviceOffset
= pTempPtr
- pDevNamesSpace
;
323 pTempPtr
+= strlen(DeviceName
) + 1;
324 strcpy(pTempPtr
, OutputPort
);
325 lpDevNames
->wOutputOffset
= pTempPtr
- pDevNamesSpace
;
327 PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
));
328 lpDevNames
->wDefault
= (strcmp(buf
, DeviceName
) == 0) ? 1 : 0;
333 static BOOL
PRINTDLG_CreateDevNamesW(HGLOBAL
*hmem
, LPCWSTR DeviceDriverName
,
334 LPCWSTR DeviceName
, LPCWSTR OutputPort
)
337 LPWSTR pDevNamesSpace
;
339 LPDEVNAMES lpDevNames
;
343 size
= sizeof(WCHAR
)*lstrlenW(DeviceDriverName
) + 2
344 + sizeof(WCHAR
)*lstrlenW(DeviceName
) + 2
345 + sizeof(WCHAR
)*lstrlenW(OutputPort
) + 2
349 *hmem
= GlobalReAlloc(*hmem
, size
, GMEM_MOVEABLE
);
351 *hmem
= GlobalAlloc(GMEM_MOVEABLE
, size
);
355 pDevNamesSpace
= GlobalLock(*hmem
);
356 lpDevNames
= (LPDEVNAMES
) pDevNamesSpace
;
358 pTempPtr
= (LPWSTR
)((LPDEVNAMES
)pDevNamesSpace
+ 1);
359 lstrcpyW(pTempPtr
, DeviceDriverName
);
360 lpDevNames
->wDriverOffset
= pTempPtr
- pDevNamesSpace
;
362 pTempPtr
+= lstrlenW(DeviceDriverName
) + 1;
363 lstrcpyW(pTempPtr
, DeviceName
);
364 lpDevNames
->wDeviceOffset
= pTempPtr
- pDevNamesSpace
;
366 pTempPtr
+= lstrlenW(DeviceName
) + 1;
367 lstrcpyW(pTempPtr
, OutputPort
);
368 lpDevNames
->wOutputOffset
= pTempPtr
- pDevNamesSpace
;
370 PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
));
371 MultiByteToWideChar(CP_ACP
, 0, buf
, -1, bufW
, -1);
372 lpDevNames
->wDefault
= (lstrcmpW(bufW
, DeviceName
) == 0) ? 1 : 0;
378 static BOOL
PRINTDLG_CreateDevNames16(HGLOBAL16
*hmem
, char* DeviceDriverName
,
379 char* DeviceName
, char* OutputPort
)
382 char* pDevNamesSpace
;
384 LPDEVNAMES lpDevNames
;
387 size
= strlen(DeviceDriverName
) + 1
388 + strlen(DeviceName
) + 1
389 + strlen(OutputPort
) + 1
393 *hmem
= GlobalReAlloc16(*hmem
, size
, GMEM_MOVEABLE
);
395 *hmem
= GlobalAlloc16(GMEM_MOVEABLE
, size
);
399 pDevNamesSpace
= GlobalLock16(*hmem
);
400 lpDevNames
= (LPDEVNAMES
) pDevNamesSpace
;
402 pTempPtr
= pDevNamesSpace
+ sizeof(DEVNAMES
);
403 strcpy(pTempPtr
, DeviceDriverName
);
404 lpDevNames
->wDriverOffset
= pTempPtr
- pDevNamesSpace
;
406 pTempPtr
+= strlen(DeviceDriverName
) + 1;
407 strcpy(pTempPtr
, DeviceName
);
408 lpDevNames
->wDeviceOffset
= pTempPtr
- pDevNamesSpace
;
410 pTempPtr
+= strlen(DeviceName
) + 1;
411 strcpy(pTempPtr
, OutputPort
);
412 lpDevNames
->wOutputOffset
= pTempPtr
- pDevNamesSpace
;
414 PRINTDLG_GetDefaultPrinterNameA(buf
, sizeof(buf
));
415 lpDevNames
->wDefault
= (strcmp(buf
, DeviceName
) == 0) ? 1 : 0;
416 GlobalUnlock16(*hmem
);
421 /***********************************************************************
422 * PRINTDLG_UpdatePrintDlg [internal]
425 * updates the PrintDlg structure for returnvalues.
428 * FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
431 static BOOL
PRINTDLG_UpdatePrintDlgA(HWND hDlg
,
432 PRINT_PTRA
* PrintStructures
)
434 LPPRINTDLGA lppd
= PrintStructures
->dlg
.lpPrintDlg
;
435 PDEVMODEA lpdm
= PrintStructures
->lpDevMode
;
436 LPPRINTER_INFO_2A pi
= PrintStructures
->lpPrinterInfo
;
440 FIXME("No lpdm ptr?\n");
445 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
446 /* check whether nFromPage and nToPage are within range defined by
447 * nMinPage and nMaxPage
449 if (IsDlgButtonChecked(hDlg
, rad3
) == BST_CHECKED
) { /* Pages */
452 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
453 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
454 if (nFromPage
< lppd
->nMinPage
|| nFromPage
> lppd
->nMaxPage
||
455 nToPage
< lppd
->nMinPage
|| nToPage
> lppd
->nMaxPage
) {
456 char resourcestr
[256];
458 LoadStringA(COMDLG32_hInstance
, PD32_INVALID_PAGE_RANGE
,
460 sprintf(resultstr
,resourcestr
, lppd
->nMinPage
, lppd
->nMaxPage
);
461 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_TITLE
,
463 MessageBoxA(hDlg
, resultstr
, resourcestr
,
464 MB_OK
| MB_ICONWARNING
);
467 lppd
->nFromPage
= nFromPage
;
468 lppd
->nToPage
= nToPage
;
469 lppd
->Flags
|= PD_PAGENUMS
;
472 lppd
->Flags
&= ~PD_PAGENUMS
;
474 if (IsDlgButtonChecked(hDlg
, chx1
) == BST_CHECKED
) {/* Print to file */
475 lppd
->Flags
|= PD_PRINTTOFILE
;
476 pi
->pPortName
= "FILE:";
479 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
) { /* Collate */
480 FIXME("Collate lppd not yet implemented as output\n");
483 /* set PD_Collate and nCopies */
484 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
485 /* The application doesn't support multiple copies or collate...
487 lppd
->Flags
&= ~PD_COLLATE
;
489 /* if the printer driver supports it... store info there
490 * otherwise no collate & multiple copies !
492 if (lpdm
->dmFields
& DM_COLLATE
)
494 (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
);
495 if (lpdm
->dmFields
& DM_COPIES
)
496 lpdm
->dmCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
498 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
499 lppd
->Flags
|= PD_COLLATE
;
501 lppd
->Flags
&= ~PD_COLLATE
;
502 lppd
->nCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
508 static BOOL
PRINTDLG_UpdatePrintDlgW(HWND hDlg
,
509 PRINT_PTRW
* PrintStructures
)
511 LPPRINTDLGW lppd
= PrintStructures
->dlg
.lpPrintDlg
;
512 PDEVMODEW lpdm
= PrintStructures
->lpDevMode
;
513 LPPRINTER_INFO_2W pi
= PrintStructures
->lpPrinterInfo
;
517 FIXME("No lpdm ptr?\n");
522 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
523 /* check whether nFromPage and nToPage are within range defined by
524 * nMinPage and nMaxPage
526 if (IsDlgButtonChecked(hDlg
, rad3
) == BST_CHECKED
) { /* Pages */
529 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
530 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
531 if (nFromPage
< lppd
->nMinPage
|| nFromPage
> lppd
->nMaxPage
||
532 nToPage
< lppd
->nMinPage
|| nToPage
> lppd
->nMaxPage
) {
533 char resourcestr
[256];
535 LoadStringA(COMDLG32_hInstance
, PD32_INVALID_PAGE_RANGE
,
537 sprintf(resultstr
,resourcestr
, lppd
->nMinPage
, lppd
->nMaxPage
);
538 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_TITLE
,
540 MessageBoxA(hDlg
, resultstr
, resourcestr
,
541 MB_OK
| MB_ICONWARNING
);
544 lppd
->nFromPage
= nFromPage
;
545 lppd
->nToPage
= nToPage
;
548 if (IsDlgButtonChecked(hDlg
, chx1
) == BST_CHECKED
) {/* Print to file */
549 static WCHAR file
[] = {'F','I','L','E',':',0};
550 lppd
->Flags
|= PD_PRINTTOFILE
;
551 pi
->pPortName
= file
;
554 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
) { /* Collate */
555 FIXME("Collate lppd not yet implemented as output\n");
558 /* set PD_Collate and nCopies */
559 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
560 /* The application doesn't support multiple copies or collate...
562 lppd
->Flags
&= ~PD_COLLATE
;
564 /* if the printer driver supports it... store info there
565 * otherwise no collate & multiple copies !
567 if (lpdm
->dmFields
& DM_COLLATE
)
569 (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
);
570 if (lpdm
->dmFields
& DM_COPIES
)
571 lpdm
->dmCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
573 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
574 lppd
->Flags
|= PD_COLLATE
;
576 lppd
->Flags
&= ~PD_COLLATE
;
577 lppd
->nCopies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
583 static BOOL
PRINTDLG_PaperSizeA(
584 PRINTDLGA
*pdlga
,const char *PaperSize
,LPPOINT size
588 LPSTR devname
,portname
;
592 POINT
*points
= NULL
;
595 dn
= GlobalLock(pdlga
->hDevNames
);
596 dm
= GlobalLock(pdlga
->hDevMode
);
597 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
598 portname
= ((char*)dn
)+dn
->wOutputOffset
;
601 NrOfEntries
= DeviceCapabilitiesA(devname
,portname
,DC_PAPERNAMES
,NULL
,dm
);
603 FIXME("No papernames found for %s/%s\n",devname
,portname
);
606 if (NrOfEntries
== -1) {
607 ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n");
611 Names
= (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries
*64);
612 if (NrOfEntries
!= (ret
=DeviceCapabilitiesA(devname
,portname
,DC_PAPERNAMES
,Names
,dm
))) {
613 FIXME("Number of returned vals %d is not %d\n",NrOfEntries
,ret
);
616 for (i
=0;i
<NrOfEntries
;i
++)
617 if (!strcmp(PaperSize
,Names
+(64*i
)))
619 HeapFree(GetProcessHeap(),0,Names
);
620 if (i
==NrOfEntries
) {
621 FIXME("Papersize %s not found in list?\n",PaperSize
);
624 points
= HeapAlloc(GetProcessHeap(),0,sizeof(points
[0])*NrOfEntries
);
625 if (NrOfEntries
!=(ret
=DeviceCapabilitiesA(devname
,portname
,DC_PAPERSIZE
,(LPBYTE
)points
,dm
))) {
626 FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries
,ret
);
629 /* this is _10ths_ of a millimeter */
634 GlobalUnlock(pdlga
->hDevNames
);
635 GlobalUnlock(pdlga
->hDevMode
);
636 if (Names
) HeapFree(GetProcessHeap(),0,Names
);
637 if (points
) HeapFree(GetProcessHeap(),0,points
);
641 static BOOL
PRINTDLG_PaperSizeW(
642 PRINTDLGW
*pdlga
,const WCHAR
*PaperSize
,LPPOINT size
646 LPWSTR devname
,portname
;
650 POINT
*points
= NULL
;
653 dn
= GlobalLock(pdlga
->hDevNames
);
654 dm
= GlobalLock(pdlga
->hDevMode
);
655 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
656 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
659 NrOfEntries
= DeviceCapabilitiesW(devname
,portname
,DC_PAPERNAMES
,NULL
,dm
);
661 FIXME("No papernames found for %s/%s\n",debugstr_w(devname
),debugstr_w(portname
));
664 if (NrOfEntries
== -1) {
665 ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n");
669 Names
= (WCHAR
*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*NrOfEntries
*64);
670 if (NrOfEntries
!= (ret
=DeviceCapabilitiesW(devname
,portname
,DC_PAPERNAMES
,Names
,dm
))) {
671 FIXME("Number of returned vals %d is not %d\n",NrOfEntries
,ret
);
674 for (i
=0;i
<NrOfEntries
;i
++)
675 if (!lstrcmpW(PaperSize
,Names
+(64*i
)))
677 HeapFree(GetProcessHeap(),0,Names
);
678 if (i
==NrOfEntries
) {
679 FIXME("Papersize %s not found in list?\n",debugstr_w(PaperSize
));
682 points
= HeapAlloc(GetProcessHeap(),0,sizeof(points
[0])*NrOfEntries
);
683 if (NrOfEntries
!=(ret
=DeviceCapabilitiesW(devname
,portname
,DC_PAPERSIZE
,(LPWSTR
)points
,dm
))) {
684 FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries
,ret
);
687 /* this is _10ths_ of a millimeter */
692 GlobalUnlock(pdlga
->hDevNames
);
693 GlobalUnlock(pdlga
->hDevMode
);
694 if (Names
) HeapFree(GetProcessHeap(),0,Names
);
695 if (points
) HeapFree(GetProcessHeap(),0,points
);
700 /************************************************************************
701 * PRINTDLG_SetUpPaperComboBox
703 * Initialize either the papersize or inputslot combos of the Printer Setup
704 * dialog. We store the associated word (eg DMPAPER_A4) as the item data.
705 * We also try to re-select the old selection.
707 static BOOL
PRINTDLG_SetUpPaperComboBoxA(HWND hDlg
,
720 int fwCapability_Names
;
721 int fwCapability_Words
;
723 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",PrinterName
,PortName
,nIDComboBox
);
725 /* query the dialog box for the current selected value */
726 Sel
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETCURSEL
, 0, 0);
728 /* we enter here only if a different printer is selected after
729 * the Print Setup dialog is opened. The current settings are
730 * stored into the newly selected printer.
732 oldWord
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
,
735 if (nIDComboBox
== cmb2
)
736 dm
->u1
.s1
.dmPaperSize
= oldWord
;
738 dm
->dmDefaultSource
= oldWord
;
742 /* we enter here only when the Print setup dialog is initially
743 * opened. In this case the settings are restored from when
744 * the dialog was last closed.
747 if (nIDComboBox
== cmb2
)
748 oldWord
= dm
->u1
.s1
.dmPaperSize
;
750 oldWord
= dm
->dmDefaultSource
;
754 if (nIDComboBox
== cmb2
) {
756 fwCapability_Names
= DC_PAPERNAMES
;
757 fwCapability_Words
= DC_PAPERS
;
761 fwCapability_Names
= DC_BINNAMES
;
762 fwCapability_Words
= DC_BINS
;
765 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the
766 * paper settings. As Wine doesn't allow VXDs, this results in a crash.
768 WARN(" if your printer driver uses VXDs, expect a crash now!\n");
769 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
770 fwCapability_Names
, NULL
, dm
);
771 if (NrOfEntries
== 0)
772 WARN("no Name Entries found!\n");
773 else if (NrOfEntries
< 0)
776 if(DeviceCapabilitiesA(PrinterName
, PortName
, fwCapability_Words
, NULL
, dm
)
778 ERR("Number of caps is different\n");
782 Names
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(char)*NamesSize
);
783 Words
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WORD
));
784 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
785 fwCapability_Names
, Names
, dm
);
786 NrOfEntries
= DeviceCapabilitiesA(PrinterName
, PortName
,
787 fwCapability_Words
, (LPSTR
)Words
, dm
);
789 /* reset any current content in the combobox */
790 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_RESETCONTENT
, 0, 0);
792 /* store new content */
793 for (i
= 0; i
< NrOfEntries
; i
++) {
794 DWORD pos
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_ADDSTRING
, 0,
795 (LPARAM
)(&Names
[i
*NamesSize
]) );
796 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_SETITEMDATA
, pos
,
800 /* Look for old selection - can't do this is previous loop since
801 item order will change as more items are added */
803 for (i
= 0; i
< NrOfEntries
; i
++) {
804 if(SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
, i
, 0) ==
810 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_SETCURSEL
, Sel
, 0);
812 HeapFree(GetProcessHeap(),0,Words
);
813 HeapFree(GetProcessHeap(),0,Names
);
817 static BOOL
PRINTDLG_SetUpPaperComboBoxW(HWND hDlg
,
830 int fwCapability_Names
;
831 int fwCapability_Words
;
833 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",debugstr_w(PrinterName
),debugstr_w(PortName
),nIDComboBox
);
835 /* query the dialog box for the current selected value */
836 Sel
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETCURSEL
, 0, 0);
838 /* we enter here only if a different printer is selected after
839 * the Print Setup dialog is opened. The current settings are
840 * stored into the newly selected printer.
842 oldWord
= SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
,
845 if (nIDComboBox
== cmb2
)
846 dm
->u1
.s1
.dmPaperSize
= oldWord
;
848 dm
->dmDefaultSource
= oldWord
;
852 /* we enter here only when the Print setup dialog is initially
853 * opened. In this case the settings are restored from when
854 * the dialog was last closed.
857 if (nIDComboBox
== cmb2
)
858 oldWord
= dm
->u1
.s1
.dmPaperSize
;
860 oldWord
= dm
->dmDefaultSource
;
864 if (nIDComboBox
== cmb2
) {
866 fwCapability_Names
= DC_PAPERNAMES
;
867 fwCapability_Words
= DC_PAPERS
;
871 fwCapability_Names
= DC_BINNAMES
;
872 fwCapability_Words
= DC_BINS
;
875 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the
876 * paper settings. As Wine doesn't allow VXDs, this results in a crash.
878 WARN(" if your printer driver uses VXDs, expect a crash now!\n");
879 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
880 fwCapability_Names
, NULL
, dm
);
881 if (NrOfEntries
== 0)
882 WARN("no Name Entries found!\n");
883 else if (NrOfEntries
< 0)
886 if(DeviceCapabilitiesW(PrinterName
, PortName
, fwCapability_Words
, NULL
, dm
)
888 ERR("Number of caps is different\n");
892 Names
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WCHAR
)*NamesSize
);
893 Words
= HeapAlloc(GetProcessHeap(),0, NrOfEntries
*sizeof(WORD
));
894 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
895 fwCapability_Names
, Names
, dm
);
896 NrOfEntries
= DeviceCapabilitiesW(PrinterName
, PortName
,
897 fwCapability_Words
, (LPWSTR
)Words
, dm
);
899 /* reset any current content in the combobox */
900 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_RESETCONTENT
, 0, 0);
902 /* store new content */
903 for (i
= 0; i
< NrOfEntries
; i
++) {
904 DWORD pos
= SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_ADDSTRING
, 0,
905 (LPARAM
)(&Names
[i
*NamesSize
]) );
906 SendDlgItemMessageW(hDlg
, nIDComboBox
, CB_SETITEMDATA
, pos
,
910 /* Look for old selection - can't do this is previous loop since
911 item order will change as more items are added */
913 for (i
= 0; i
< NrOfEntries
; i
++) {
914 if(SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_GETITEMDATA
, i
, 0) ==
920 SendDlgItemMessageA(hDlg
, nIDComboBox
, CB_SETCURSEL
, Sel
, 0);
922 HeapFree(GetProcessHeap(),0,Words
);
923 HeapFree(GetProcessHeap(),0,Names
);
928 /***********************************************************************
929 * PRINTDLG_UpdatePrinterInfoTexts [internal]
931 static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg
, LPPRINTER_INFO_2A pi
)
934 char ResourceString
[256];
940 /* add all status messages */
941 for (i
= 0; i
< 25; i
++) {
942 if (pi
->Status
& (1<<i
)) {
943 LoadStringA(COMDLG32_hInstance
, PD32_PRINTER_STATUS_PAUSED
+i
,
944 ResourceString
, 255);
945 strcat(StatusMsg
,ResourceString
);
949 /* FIXME: status==ready must only be appended if really so.
950 but how to detect? */
951 LoadStringA(COMDLG32_hInstance
, PD32_PRINTER_STATUS_READY
,
952 ResourceString
, 255);
953 strcat(StatusMsg
,ResourceString
);
954 SetDlgItemTextA(hDlg
, stc12
, StatusMsg
);
956 /* set all other printer info texts */
957 SetDlgItemTextA(hDlg
, stc11
, pi
->pDriverName
);
959 if (pi
->pLocation
!= NULL
&& pi
->pLocation
[0] != '\0')
960 SetDlgItemTextA(hDlg
, stc14
, pi
->pLocation
);
962 SetDlgItemTextA(hDlg
, stc14
, pi
->pPortName
);
963 SetDlgItemTextA(hDlg
, stc13
, pi
->pComment
? pi
->pComment
: "");
967 static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg
, LPPRINTER_INFO_2W pi
)
969 WCHAR StatusMsg
[256];
970 WCHAR ResourceString
[256];
971 static const WCHAR emptyW
[] = {0};
977 /* add all status messages */
978 for (i
= 0; i
< 25; i
++) {
979 if (pi
->Status
& (1<<i
)) {
980 LoadStringW(COMDLG32_hInstance
, PD32_PRINTER_STATUS_PAUSED
+i
,
981 ResourceString
, 255);
982 lstrcatW(StatusMsg
,ResourceString
);
986 /* FIXME: status==ready must only be appended if really so.
987 but how to detect? */
988 LoadStringW(COMDLG32_hInstance
, PD32_PRINTER_STATUS_READY
,
989 ResourceString
, 255);
990 lstrcatW(StatusMsg
,ResourceString
);
991 SetDlgItemTextW(hDlg
, stc12
, StatusMsg
);
993 /* set all other printer info texts */
994 SetDlgItemTextW(hDlg
, stc11
, pi
->pDriverName
);
995 if (pi
->pLocation
!= NULL
&& pi
->pLocation
[0] != '\0')
996 SetDlgItemTextW(hDlg
, stc14
, pi
->pLocation
);
998 SetDlgItemTextW(hDlg
, stc14
, pi
->pPortName
);
999 SetDlgItemTextW(hDlg
, stc13
, pi
->pComment
? pi
->pComment
: emptyW
);
1003 /*******************************************************************
1005 * PRINTDLG_ChangePrinter
1008 static BOOL
PRINTDLG_ChangePrinterA(HWND hDlg
, char *name
,
1009 PRINT_PTRA
*PrintStructures
)
1011 LPPRINTDLGA lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1012 LPDEVMODEA lpdm
= NULL
;
1017 if(PrintStructures
->lpPrinterInfo
)
1018 HeapFree(GetProcessHeap(),0, PrintStructures
->lpPrinterInfo
);
1019 if(PrintStructures
->lpDriverInfo
)
1020 HeapFree(GetProcessHeap(),0, PrintStructures
->lpDriverInfo
);
1021 if(!OpenPrinterA(name
, &hprn
, NULL
)) {
1022 ERR("Can't open printer %s\n", name
);
1025 GetPrinterA(hprn
, 2, NULL
, 0, &needed
);
1026 PrintStructures
->lpPrinterInfo
= HeapAlloc(GetProcessHeap(),0,needed
);
1027 GetPrinterA(hprn
, 2, (LPBYTE
)PrintStructures
->lpPrinterInfo
, needed
,
1029 GetPrinterDriverA(hprn
, NULL
, 3, NULL
, 0, &needed
);
1030 PrintStructures
->lpDriverInfo
= HeapAlloc(GetProcessHeap(),0,needed
);
1031 if (!GetPrinterDriverA(hprn
, NULL
, 3, (LPBYTE
)PrintStructures
->lpDriverInfo
,
1033 ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures
->lpPrinterInfo
->pPrinterName
);
1038 PRINTDLG_UpdatePrinterInfoTextsA(hDlg
, PrintStructures
->lpPrinterInfo
);
1040 if(PrintStructures
->lpDevMode
) {
1041 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
1042 PrintStructures
->lpDevMode
= NULL
;
1045 dmSize
= DocumentPropertiesA(0, 0, name
, NULL
, NULL
, 0);
1047 ERR("DocumentProperties fails on %s\n", debugstr_a(name
));
1050 PrintStructures
->lpDevMode
= HeapAlloc(GetProcessHeap(), 0, dmSize
);
1051 dmSize
= DocumentPropertiesA(0, 0, name
, PrintStructures
->lpDevMode
, NULL
,
1053 if(lppd
->hDevMode
&& (lpdm
= GlobalLock(lppd
->hDevMode
)) &&
1054 !strcmp(lpdm
->dmDeviceName
,
1055 PrintStructures
->lpDevMode
->dmDeviceName
)) {
1056 /* Supplied devicemode matches current printer so try to use it */
1057 DocumentPropertiesA(0, 0, name
, PrintStructures
->lpDevMode
, lpdm
,
1058 DM_OUT_BUFFER
| DM_IN_BUFFER
);
1061 GlobalUnlock(lppd
->hDevMode
);
1063 lpdm
= PrintStructures
->lpDevMode
; /* use this as a shortcut */
1065 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
1066 /* Print range (All/Range/Selection) */
1067 SetDlgItemInt(hDlg
, edt1
, lppd
->nFromPage
, FALSE
);
1068 SetDlgItemInt(hDlg
, edt2
, lppd
->nToPage
, FALSE
);
1069 CheckRadioButton(hDlg
, rad1
, rad3
, rad1
); /* default */
1070 if (lppd
->Flags
& PD_NOSELECTION
)
1071 EnableWindow(GetDlgItem(hDlg
, rad2
), FALSE
);
1073 if (lppd
->Flags
& PD_SELECTION
)
1074 CheckRadioButton(hDlg
, rad1
, rad3
, rad2
);
1075 if (lppd
->Flags
& PD_NOPAGENUMS
) {
1076 EnableWindow(GetDlgItem(hDlg
, rad3
), FALSE
);
1077 EnableWindow(GetDlgItem(hDlg
, stc2
),FALSE
);
1078 EnableWindow(GetDlgItem(hDlg
, edt1
), FALSE
);
1079 EnableWindow(GetDlgItem(hDlg
, stc3
),FALSE
);
1080 EnableWindow(GetDlgItem(hDlg
, edt2
), FALSE
);
1082 if (lppd
->Flags
& PD_PAGENUMS
)
1083 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1085 /* "All xxx pages"... */
1087 char resourcestr
[64];
1089 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_ALL_X_PAGES
,
1091 sprintf(result
,resourcestr
,lppd
->nMaxPage
- lppd
->nMinPage
+ 1);
1092 SendDlgItemMessageA(hDlg
, rad1
, WM_SETTEXT
, 0, (LPARAM
) result
);
1097 * FIXME: The ico3 is not displayed for some reason. I don't know why.
1099 if (lppd
->Flags
& PD_COLLATE
) {
1100 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1101 (LPARAM
)PrintStructures
->hCollateIcon
);
1102 CheckDlgButton(hDlg
, chx2
, 1);
1104 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1105 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1106 CheckDlgButton(hDlg
, chx2
, 0);
1109 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1110 /* if printer doesn't support it: no Collate */
1111 if (!(lpdm
->dmFields
& DM_COLLATE
)) {
1112 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1113 EnableWindow(GetDlgItem(hDlg
, ico3
), FALSE
);
1120 if (lppd
->hDevMode
== 0)
1121 copies
= lppd
->nCopies
;
1123 copies
= lpdm
->dmCopies
;
1124 if(copies
== 0) copies
= 1;
1125 else if(copies
< 0) copies
= MAX_COPIES
;
1126 SetDlgItemInt(hDlg
, edt3
, copies
, FALSE
);
1129 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1130 /* if printer doesn't support it: no nCopies */
1131 if (!(lpdm
->dmFields
& DM_COPIES
)) {
1132 EnableWindow(GetDlgItem(hDlg
, edt3
), FALSE
);
1133 EnableWindow(GetDlgItem(hDlg
, stc5
), FALSE
);
1138 CheckDlgButton(hDlg
, chx1
, (lppd
->Flags
& PD_PRINTTOFILE
) ? 1 : 0);
1139 if (lppd
->Flags
& PD_DISABLEPRINTTOFILE
)
1140 EnableWindow(GetDlgItem(hDlg
, chx1
), FALSE
);
1141 if (lppd
->Flags
& PD_HIDEPRINTTOFILE
)
1142 ShowWindow(GetDlgItem(hDlg
, chx1
), SW_HIDE
);
1144 } else { /* PD_PRINTSETUP */
1145 BOOL bPortrait
= (lpdm
->u1
.s1
.dmOrientation
== DMORIENT_PORTRAIT
);
1147 PRINTDLG_SetUpPaperComboBoxA(hDlg
, cmb2
,
1148 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1149 PrintStructures
->lpPrinterInfo
->pPortName
,
1151 PRINTDLG_SetUpPaperComboBoxA(hDlg
, cmb3
,
1152 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1153 PrintStructures
->lpPrinterInfo
->pPortName
,
1155 CheckRadioButton(hDlg
, rad1
, rad2
, bPortrait
? rad1
: rad2
);
1156 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1157 (LPARAM
)(bPortrait
? PrintStructures
->hPortraitIcon
:
1158 PrintStructures
->hLandscapeIcon
));
1163 if ((lppd
->Flags
& PD_SHOWHELP
)==0) {
1164 /* hide if PD_SHOWHELP not specified */
1165 ShowWindow(GetDlgItem(hDlg
, pshHelp
), SW_HIDE
);
1170 static BOOL
PRINTDLG_ChangePrinterW(HWND hDlg
, WCHAR
*name
,
1171 PRINT_PTRW
*PrintStructures
)
1173 LPPRINTDLGW lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1174 LPDEVMODEW lpdm
= NULL
;
1179 if(PrintStructures
->lpPrinterInfo
)
1180 HeapFree(GetProcessHeap(),0, PrintStructures
->lpPrinterInfo
);
1181 if(PrintStructures
->lpDriverInfo
)
1182 HeapFree(GetProcessHeap(),0, PrintStructures
->lpDriverInfo
);
1183 if(!OpenPrinterW(name
, &hprn
, NULL
)) {
1184 ERR("Can't open printer %s\n", debugstr_w(name
));
1187 GetPrinterW(hprn
, 2, NULL
, 0, &needed
);
1188 PrintStructures
->lpPrinterInfo
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
1189 GetPrinterW(hprn
, 2, (LPBYTE
)PrintStructures
->lpPrinterInfo
, needed
,
1191 GetPrinterDriverW(hprn
, NULL
, 3, NULL
, 0, &needed
);
1192 PrintStructures
->lpDriverInfo
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
1193 if (!GetPrinterDriverW(hprn
, NULL
, 3, (LPBYTE
)PrintStructures
->lpDriverInfo
,
1195 ERR("GetPrinterDriverA failed for %s, fix your config!\n",debugstr_w(PrintStructures
->lpPrinterInfo
->pPrinterName
));
1200 PRINTDLG_UpdatePrinterInfoTextsW(hDlg
, PrintStructures
->lpPrinterInfo
);
1202 if(PrintStructures
->lpDevMode
) {
1203 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
1204 PrintStructures
->lpDevMode
= NULL
;
1207 dmSize
= DocumentPropertiesW(0, 0, name
, NULL
, NULL
, 0);
1209 ERR("DocumentProperties fails on %s\n", debugstr_w(name
));
1212 PrintStructures
->lpDevMode
= HeapAlloc(GetProcessHeap(), 0, dmSize
);
1213 dmSize
= DocumentPropertiesW(0, 0, name
, PrintStructures
->lpDevMode
, NULL
,
1215 if(lppd
->hDevMode
&& (lpdm
= GlobalLock(lppd
->hDevMode
)) &&
1216 !lstrcmpW(lpdm
->dmDeviceName
,
1217 PrintStructures
->lpDevMode
->dmDeviceName
)) {
1218 /* Supplied devicemode matches current printer so try to use it */
1219 DocumentPropertiesW(0, 0, name
, PrintStructures
->lpDevMode
, lpdm
,
1220 DM_OUT_BUFFER
| DM_IN_BUFFER
);
1223 GlobalUnlock(lppd
->hDevMode
);
1225 lpdm
= PrintStructures
->lpDevMode
; /* use this as a shortcut */
1227 if(!(lppd
->Flags
& PD_PRINTSETUP
)) {
1228 /* Print range (All/Range/Selection) */
1229 SetDlgItemInt(hDlg
, edt1
, lppd
->nFromPage
, FALSE
);
1230 SetDlgItemInt(hDlg
, edt2
, lppd
->nToPage
, FALSE
);
1231 CheckRadioButton(hDlg
, rad1
, rad3
, rad1
); /* default */
1232 if (lppd
->Flags
& PD_NOSELECTION
)
1233 EnableWindow(GetDlgItem(hDlg
, rad2
), FALSE
);
1235 if (lppd
->Flags
& PD_SELECTION
)
1236 CheckRadioButton(hDlg
, rad1
, rad3
, rad2
);
1237 if (lppd
->Flags
& PD_NOPAGENUMS
) {
1238 EnableWindow(GetDlgItem(hDlg
, rad3
), FALSE
);
1239 EnableWindow(GetDlgItem(hDlg
, stc2
),FALSE
);
1240 EnableWindow(GetDlgItem(hDlg
, edt1
), FALSE
);
1241 EnableWindow(GetDlgItem(hDlg
, stc3
),FALSE
);
1242 EnableWindow(GetDlgItem(hDlg
, edt2
), FALSE
);
1244 if (lppd
->Flags
& PD_PAGENUMS
)
1245 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1247 /* "All xxx pages"... */
1250 char resourcestr
[64];
1252 LoadStringA(COMDLG32_hInstance
, PD32_PRINT_ALL_X_PAGES
,
1254 sprintf(result
,resourcestr
,lppd
->nMaxPage
- lppd
->nMinPage
+ 1);
1255 SendDlgItemMessageA(hDlg
, rad1
, WM_SETTEXT
, 0, (LPARAM
) result
);
1260 * FIXME: The ico3 is not displayed for some reason. I don't know why.
1262 if (lppd
->Flags
& PD_COLLATE
) {
1263 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1264 (LPARAM
)PrintStructures
->hCollateIcon
);
1265 CheckDlgButton(hDlg
, chx2
, 1);
1267 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1268 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1269 CheckDlgButton(hDlg
, chx2
, 0);
1272 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1273 /* if printer doesn't support it: no Collate */
1274 if (!(lpdm
->dmFields
& DM_COLLATE
)) {
1275 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1276 EnableWindow(GetDlgItem(hDlg
, ico3
), FALSE
);
1283 if (lppd
->hDevMode
== 0)
1284 copies
= lppd
->nCopies
;
1286 copies
= lpdm
->dmCopies
;
1287 if(copies
== 0) copies
= 1;
1288 else if(copies
< 0) copies
= MAX_COPIES
;
1289 SetDlgItemInt(hDlg
, edt3
, copies
, FALSE
);
1292 if (lppd
->Flags
& PD_USEDEVMODECOPIESANDCOLLATE
) {
1293 /* if printer doesn't support it: no nCopies */
1294 if (!(lpdm
->dmFields
& DM_COPIES
)) {
1295 EnableWindow(GetDlgItem(hDlg
, edt3
), FALSE
);
1296 EnableWindow(GetDlgItem(hDlg
, stc5
), FALSE
);
1301 CheckDlgButton(hDlg
, chx1
, (lppd
->Flags
& PD_PRINTTOFILE
) ? 1 : 0);
1302 if (lppd
->Flags
& PD_DISABLEPRINTTOFILE
)
1303 EnableWindow(GetDlgItem(hDlg
, chx1
), FALSE
);
1304 if (lppd
->Flags
& PD_HIDEPRINTTOFILE
)
1305 ShowWindow(GetDlgItem(hDlg
, chx1
), SW_HIDE
);
1307 } else { /* PD_PRINTSETUP */
1308 BOOL bPortrait
= (lpdm
->u1
.s1
.dmOrientation
== DMORIENT_PORTRAIT
);
1310 PRINTDLG_SetUpPaperComboBoxW(hDlg
, cmb2
,
1311 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1312 PrintStructures
->lpPrinterInfo
->pPortName
,
1314 PRINTDLG_SetUpPaperComboBoxW(hDlg
, cmb3
,
1315 PrintStructures
->lpPrinterInfo
->pPrinterName
,
1316 PrintStructures
->lpPrinterInfo
->pPortName
,
1318 CheckRadioButton(hDlg
, rad1
, rad2
, bPortrait
? rad1
: rad2
);
1319 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1320 (LPARAM
)(bPortrait
? PrintStructures
->hPortraitIcon
:
1321 PrintStructures
->hLandscapeIcon
));
1326 if ((lppd
->Flags
& PD_SHOWHELP
)==0) {
1327 /* hide if PD_SHOWHELP not specified */
1328 ShowWindow(GetDlgItem(hDlg
, pshHelp
), SW_HIDE
);
1333 /***********************************************************************
1334 * PRINTDLG_WMInitDialog [internal]
1336 static LRESULT
PRINTDLG_WMInitDialog(HWND hDlg
, WPARAM wParam
,
1337 PRINT_PTRA
* PrintStructures
)
1339 LPPRINTDLGA lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1343 UINT comboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1345 /* load Collate ICONs */
1346 /* We load these with LoadImage because they are not a standard
1347 size and we don't want them rescaled */
1348 PrintStructures
->hCollateIcon
=
1349 LoadImageA(COMDLG32_hInstance
, "PD32_COLLATE", IMAGE_ICON
, 0, 0, 0);
1350 PrintStructures
->hNoCollateIcon
=
1351 LoadImageA(COMDLG32_hInstance
, "PD32_NOCOLLATE", IMAGE_ICON
, 0, 0, 0);
1353 /* These can be done with LoadIcon */
1354 PrintStructures
->hPortraitIcon
=
1355 LoadIconA(COMDLG32_hInstance
, "PD32_PORTRAIT");
1356 PrintStructures
->hLandscapeIcon
=
1357 LoadIconA(COMDLG32_hInstance
, "PD32_LANDSCAPE");
1359 if(PrintStructures
->hCollateIcon
== 0 ||
1360 PrintStructures
->hNoCollateIcon
== 0 ||
1361 PrintStructures
->hPortraitIcon
== 0 ||
1362 PrintStructures
->hLandscapeIcon
== 0) {
1363 ERR("no icon in resourcefile\n");
1364 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1365 EndDialog(hDlg
, FALSE
);
1369 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1370 * must be registered and the Help button must be shown.
1372 if (lppd
->Flags
& PD_SHOWHELP
) {
1373 if((PrintStructures
->HelpMessageID
=
1374 RegisterWindowMessageA(HELPMSGSTRINGA
)) == 0) {
1375 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL
);
1379 PrintStructures
->HelpMessageID
= 0;
1381 if(!(lppd
->Flags
&PD_PRINTSETUP
)) {
1382 PrintStructures
->hwndUpDown
=
1383 CreateUpDownControl(WS_CHILD
| WS_VISIBLE
| WS_BORDER
|
1384 UDS_NOTHOUSANDS
| UDS_ARROWKEYS
|
1385 UDS_ALIGNRIGHT
| UDS_SETBUDDYINT
, 0, 0, 0, 0,
1386 hDlg
, UPDOWN_ID
, COMDLG32_hInstance
,
1387 GetDlgItem(hDlg
, edt3
), MAX_COPIES
, 1, 1);
1390 /* FIXME: I allow more freedom than either Win95 or WinNT,
1391 * which do not agree to what errors should be thrown or not
1392 * in case nToPage or nFromPage is out-of-range.
1394 if (lppd
->nMaxPage
< lppd
->nMinPage
)
1395 lppd
->nMaxPage
= lppd
->nMinPage
;
1396 if (lppd
->nMinPage
== lppd
->nMaxPage
)
1397 lppd
->Flags
|= PD_NOPAGENUMS
;
1398 if (lppd
->nToPage
< lppd
->nMinPage
)
1399 lppd
->nToPage
= lppd
->nMinPage
;
1400 if (lppd
->nToPage
> lppd
->nMaxPage
)
1401 lppd
->nToPage
= lppd
->nMaxPage
;
1402 if (lppd
->nFromPage
< lppd
->nMinPage
)
1403 lppd
->nFromPage
= lppd
->nMinPage
;
1404 if (lppd
->nFromPage
> lppd
->nMaxPage
)
1405 lppd
->nFromPage
= lppd
->nMaxPage
;
1407 /* if we have the combo box, fill it */
1408 if (GetDlgItem(hDlg
,comboID
)) {
1411 pdn
= GlobalLock(lppd
->hDevNames
);
1412 pdm
= GlobalLock(lppd
->hDevMode
);
1414 name
= (char*)pdn
+ pdn
->wDeviceOffset
;
1416 name
= pdm
->dmDeviceName
;
1417 PRINTDLG_SetUpPrinterListComboA(hDlg
, comboID
, name
);
1418 if(pdm
) GlobalUnlock(lppd
->hDevMode
);
1419 if(pdn
) GlobalUnlock(lppd
->hDevNames
);
1421 /* Now find selected printer and update rest of dlg */
1422 name
= HeapAlloc(GetProcessHeap(),0,256);
1423 if (GetDlgItemTextA(hDlg
, comboID
, name
, 255))
1424 PRINTDLG_ChangePrinterA(hDlg
, name
, PrintStructures
);
1425 HeapFree(GetProcessHeap(),0,name
);
1427 /* else use default printer */
1429 BOOL ret
= PRINTDLG_GetDefaultPrinterNameA(name
, sizeof(name
));
1432 PRINTDLG_ChangePrinterA(hDlg
, name
, PrintStructures
);
1434 FIXME("No default printer found, expect problems!\n");
1439 static LRESULT
PRINTDLG_WMInitDialogW(HWND hDlg
, WPARAM wParam
,
1440 PRINT_PTRW
* PrintStructures
)
1442 LPPRINTDLGW lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1446 UINT comboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1448 /* load Collate ICONs */
1449 /* We load these with LoadImage because they are not a standard
1450 size and we don't want them rescaled */
1451 PrintStructures
->hCollateIcon
=
1452 LoadImageA(COMDLG32_hInstance
, "PD32_COLLATE", IMAGE_ICON
, 0, 0, 0);
1453 PrintStructures
->hNoCollateIcon
=
1454 LoadImageA(COMDLG32_hInstance
, "PD32_NOCOLLATE", IMAGE_ICON
, 0, 0, 0);
1456 /* These can be done with LoadIcon */
1457 PrintStructures
->hPortraitIcon
=
1458 LoadIconA(COMDLG32_hInstance
, "PD32_PORTRAIT");
1459 PrintStructures
->hLandscapeIcon
=
1460 LoadIconA(COMDLG32_hInstance
, "PD32_LANDSCAPE");
1462 if(PrintStructures
->hCollateIcon
== 0 ||
1463 PrintStructures
->hNoCollateIcon
== 0 ||
1464 PrintStructures
->hPortraitIcon
== 0 ||
1465 PrintStructures
->hLandscapeIcon
== 0) {
1466 ERR("no icon in resourcefile\n");
1467 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1468 EndDialog(hDlg
, FALSE
);
1472 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1473 * must be registered and the Help button must be shown.
1475 if (lppd
->Flags
& PD_SHOWHELP
) {
1476 if((PrintStructures
->HelpMessageID
=
1477 RegisterWindowMessageA(HELPMSGSTRINGA
)) == 0) {
1478 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL
);
1482 PrintStructures
->HelpMessageID
= 0;
1484 if(!(lppd
->Flags
&PD_PRINTSETUP
)) {
1485 PrintStructures
->hwndUpDown
=
1486 CreateUpDownControl(WS_CHILD
| WS_VISIBLE
| WS_BORDER
|
1487 UDS_NOTHOUSANDS
| UDS_ARROWKEYS
|
1488 UDS_ALIGNRIGHT
| UDS_SETBUDDYINT
, 0, 0, 0, 0,
1489 hDlg
, UPDOWN_ID
, COMDLG32_hInstance
,
1490 GetDlgItem(hDlg
, edt3
), MAX_COPIES
, 1, 1);
1493 /* FIXME: I allow more freedom than either Win95 or WinNT,
1494 * which do not agree to what errors should be thrown or not
1495 * in case nToPage or nFromPage is out-of-range.
1497 if (lppd
->nMaxPage
< lppd
->nMinPage
)
1498 lppd
->nMaxPage
= lppd
->nMinPage
;
1499 if (lppd
->nMinPage
== lppd
->nMaxPage
)
1500 lppd
->Flags
|= PD_NOPAGENUMS
;
1501 if (lppd
->nToPage
< lppd
->nMinPage
)
1502 lppd
->nToPage
= lppd
->nMinPage
;
1503 if (lppd
->nToPage
> lppd
->nMaxPage
)
1504 lppd
->nToPage
= lppd
->nMaxPage
;
1505 if (lppd
->nFromPage
< lppd
->nMinPage
)
1506 lppd
->nFromPage
= lppd
->nMinPage
;
1507 if (lppd
->nFromPage
> lppd
->nMaxPage
)
1508 lppd
->nFromPage
= lppd
->nMaxPage
;
1510 /* if we have the combo box, fill it */
1511 if (GetDlgItem(hDlg
,comboID
)) {
1514 pdn
= GlobalLock(lppd
->hDevNames
);
1515 pdm
= GlobalLock(lppd
->hDevMode
);
1517 name
= (WCHAR
*)pdn
+ pdn
->wDeviceOffset
;
1519 name
= pdm
->dmDeviceName
;
1520 PRINTDLG_SetUpPrinterListComboW(hDlg
, comboID
, name
);
1521 if(pdm
) GlobalUnlock(lppd
->hDevMode
);
1522 if(pdn
) GlobalUnlock(lppd
->hDevNames
);
1524 /* Now find selected printer and update rest of dlg */
1525 /* ansi is ok here */
1526 name
= HeapAlloc(GetProcessHeap(),0,256*sizeof(WCHAR
));
1527 if (GetDlgItemTextW(hDlg
, comboID
, name
, 255))
1528 PRINTDLG_ChangePrinterW(hDlg
, name
, PrintStructures
);
1529 HeapFree(GetProcessHeap(),0,name
);
1531 /* else use default printer */
1533 BOOL ret
= PRINTDLG_GetDefaultPrinterNameW(name
, sizeof(name
));
1536 PRINTDLG_ChangePrinterW(hDlg
, name
, PrintStructures
);
1538 FIXME("No default printer found, expect problems!\n");
1544 /***********************************************************************
1545 * PRINTDLG_WMInitDialog [internal]
1547 static LRESULT
PRINTDLG_WMInitDialog16(HWND hDlg
, WPARAM wParam
,
1548 PRINT_PTRA
* PrintStructures
)
1550 LPPRINTDLG16 lppd
= PrintStructures
->dlg
.lpPrintDlg16
;
1554 UINT comboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1556 /* load Collate ICONs */
1557 PrintStructures
->hCollateIcon
=
1558 LoadIconA(COMDLG32_hInstance
, "PD32_COLLATE");
1559 PrintStructures
->hNoCollateIcon
=
1560 LoadIconA(COMDLG32_hInstance
, "PD32_NOCOLLATE");
1561 if(PrintStructures
->hCollateIcon
== 0 ||
1562 PrintStructures
->hNoCollateIcon
== 0) {
1563 ERR("no icon in resourcefile\n");
1564 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1565 EndDialog(hDlg
, FALSE
);
1568 /* load Paper Orientation ICON */
1569 /* FIXME: not implemented yet */
1572 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1573 * must be registered and the Help button must be shown.
1575 if (lppd
->Flags
& PD_SHOWHELP
) {
1576 if((PrintStructures
->HelpMessageID
=
1577 RegisterWindowMessageA(HELPMSGSTRINGA
)) == 0) {
1578 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL
);
1582 PrintStructures
->HelpMessageID
= 0;
1584 if (!(lppd
->Flags
& PD_PRINTSETUP
)) {
1585 /* We have a print quality combo box. What shall we do? */
1586 if (GetDlgItem(hDlg
,cmb1
)) {
1589 FIXME("Print quality only displaying currently.\n");
1591 pdm
= GlobalLock16(lppd
->hDevMode
);
1593 switch (pdm
->dmPrintQuality
) {
1594 case DMRES_HIGH
: strcpy(buf
,"High");break;
1595 case DMRES_MEDIUM
: strcpy(buf
,"Medium");break;
1596 case DMRES_LOW
: strcpy(buf
,"Low");break;
1597 case DMRES_DRAFT
: strcpy(buf
,"Draft");break;
1598 case 0 : strcpy(buf
,"Default");break;
1599 default : sprintf(buf
,"%ddpi",pdm
->dmPrintQuality
);break;
1601 GlobalUnlock16(lppd
->hDevMode
);
1603 strcpy(buf
,"Default");
1604 SendDlgItemMessageA(hDlg
,cmb1
,CB_ADDSTRING
,0,(LPARAM
)buf
);
1605 SendDlgItemMessageA(hDlg
,cmb1
,CB_SETCURSEL
,0,0);
1606 EnableWindow(GetDlgItem(hDlg
,cmb1
),FALSE
);
1610 /* FIXME: I allow more freedom than either Win95 or WinNT,
1611 * which do not agree to what errors should be thrown or not
1612 * in case nToPage or nFromPage is out-of-range.
1614 if (lppd
->nMaxPage
< lppd
->nMinPage
)
1615 lppd
->nMaxPage
= lppd
->nMinPage
;
1616 if (lppd
->nMinPage
== lppd
->nMaxPage
)
1617 lppd
->Flags
|= PD_NOPAGENUMS
;
1618 if (lppd
->nToPage
< lppd
->nMinPage
)
1619 lppd
->nToPage
= lppd
->nMinPage
;
1620 if (lppd
->nToPage
> lppd
->nMaxPage
)
1621 lppd
->nToPage
= lppd
->nMaxPage
;
1622 if (lppd
->nFromPage
< lppd
->nMinPage
)
1623 lppd
->nFromPage
= lppd
->nMinPage
;
1624 if (lppd
->nFromPage
> lppd
->nMaxPage
)
1625 lppd
->nFromPage
= lppd
->nMaxPage
;
1627 /* If the printer combo box is in the dialog, fill it */
1628 if (GetDlgItem(hDlg
,comboID
)) {
1631 pdn
= GlobalLock16(lppd
->hDevNames
);
1632 pdm
= GlobalLock16(lppd
->hDevMode
);
1634 name
= (char*)pdn
+ pdn
->wDeviceOffset
;
1636 name
= pdm
->dmDeviceName
;
1637 PRINTDLG_SetUpPrinterListComboA(hDlg
, comboID
, name
);
1638 if(pdm
) GlobalUnlock16(lppd
->hDevMode
);
1639 if(pdn
) GlobalUnlock16(lppd
->hDevNames
);
1641 /* Now find selected printer and update rest of dlg */
1642 name
= HeapAlloc(GetProcessHeap(),0,256);
1643 if (GetDlgItemTextA(hDlg
, comboID
, name
, 255))
1644 PRINTDLG_ChangePrinterA(hDlg
, name
, PrintStructures
);
1646 /* else just use default printer */
1648 BOOL ret
= PRINTDLG_GetDefaultPrinterNameA(name
, sizeof(name
));
1651 PRINTDLG_ChangePrinterA(hDlg
, name
, PrintStructures
);
1653 FIXME("No default printer found, expect problems!\n");
1655 HeapFree(GetProcessHeap(),0,name
);
1660 /***********************************************************************
1661 * PRINTDLG_WMCommand [internal]
1663 static LRESULT
PRINTDLG_WMCommandA(HWND hDlg
, WPARAM wParam
,
1664 LPARAM lParam
, PRINT_PTRA
* PrintStructures
)
1666 LPPRINTDLGA lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1667 UINT PrinterComboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1668 LPDEVMODEA lpdm
= PrintStructures
->lpDevMode
;
1670 switch (LOWORD(wParam
)) {
1672 TRACE(" OK button was hit\n");
1673 if (PRINTDLG_UpdatePrintDlgA(hDlg
, PrintStructures
)!=TRUE
) {
1674 FIXME("Update printdlg was not successful!\n");
1677 EndDialog(hDlg
, TRUE
);
1681 TRACE(" CANCEL button was hit\n");
1682 EndDialog(hDlg
, FALSE
);
1686 TRACE(" HELP button was hit\n");
1687 SendMessageA(lppd
->hwndOwner
, PrintStructures
->HelpMessageID
,
1688 (WPARAM
) hDlg
, (LPARAM
) lppd
);
1691 case chx2
: /* collate pages checkbox */
1692 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
1693 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1694 (LPARAM
)PrintStructures
->hCollateIcon
);
1696 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1697 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1699 case edt1
: /* from page nr editbox */
1700 case edt2
: /* to page nr editbox */
1701 if (HIWORD(wParam
)==EN_CHANGE
) {
1704 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
1705 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
1706 if (nFromPage
!= lppd
->nFromPage
|| nToPage
!= lppd
->nToPage
)
1707 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1712 if(HIWORD(wParam
) == EN_CHANGE
) {
1713 INT copies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
1715 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1717 EnableWindow(GetDlgItem(hDlg
, chx2
), TRUE
);
1721 case psh1
: /* Print Setup */
1725 if (!PrintStructures
->dlg
.lpPrintDlg16
) {
1726 FIXME("The 32bit print dialog does not have this button!?\n");
1730 memcpy(&pdlg
,PrintStructures
->dlg
.lpPrintDlg16
,sizeof(pdlg
));
1731 pdlg
.Flags
|= PD_PRINTSETUP
;
1732 pdlg
.hwndOwner
= HWND_16(hDlg
);
1733 if (!PrintDlg16(&pdlg
))
1737 case psh2
: /* Properties button */
1740 char PrinterName
[256];
1742 GetDlgItemTextA(hDlg
, PrinterComboID
, PrinterName
, 255);
1743 if (!OpenPrinterA(PrinterName
, &hPrinter
, NULL
)) {
1744 FIXME(" Call to OpenPrinter did not succeed!\n");
1747 DocumentPropertiesA(hDlg
, hPrinter
, PrinterName
,
1748 PrintStructures
->lpDevMode
,
1749 PrintStructures
->lpDevMode
,
1750 DM_IN_BUFFER
| DM_OUT_BUFFER
| DM_IN_PROMPT
);
1751 ClosePrinter(hPrinter
);
1755 case rad1
: /* Paperorientation */
1756 if (lppd
->Flags
& PD_PRINTSETUP
)
1758 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1759 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1760 (LPARAM
)(PrintStructures
->hPortraitIcon
));
1764 case rad2
: /* Paperorientation */
1765 if (lppd
->Flags
& PD_PRINTSETUP
)
1767 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1768 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1769 (LPARAM
)(PrintStructures
->hLandscapeIcon
));
1773 case cmb1
: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */
1774 if (PrinterComboID
!= wParam
) {
1775 FIXME("No handling for print quality combo box yet.\n");
1779 case cmb4
: /* Printer combobox */
1780 if (HIWORD(wParam
)==CBN_SELCHANGE
) {
1781 char PrinterName
[256];
1782 GetDlgItemTextA(hDlg
, LOWORD(wParam
), PrinterName
, 255);
1783 PRINTDLG_ChangePrinterA(hDlg
, PrinterName
, PrintStructures
);
1787 case cmb2
: /* Papersize */
1789 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
1791 lpdm
->u1
.s1
.dmPaperSize
= SendDlgItemMessageA(hDlg
, cmb2
,
1797 case cmb3
: /* Bin */
1799 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
1801 lpdm
->dmDefaultSource
= SendDlgItemMessageA(hDlg
, cmb3
,
1802 CB_GETITEMDATA
, Sel
,
1807 if(lppd
->Flags
& PD_PRINTSETUP
) {
1808 switch (LOWORD(wParam
)) {
1809 case rad1
: /* orientation */
1811 if (IsDlgButtonChecked(hDlg
, rad1
) == BST_CHECKED
) {
1812 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_PORTRAIT
) {
1813 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1814 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1816 (LPARAM
)PrintStructures
->hPortraitIcon
);
1817 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1819 (LPARAM
)PrintStructures
->hPortraitIcon
);
1822 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_LANDSCAPE
) {
1823 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1824 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1826 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1827 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1829 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1838 static LRESULT
PRINTDLG_WMCommandW(HWND hDlg
, WPARAM wParam
,
1839 LPARAM lParam
, PRINT_PTRW
* PrintStructures
)
1841 LPPRINTDLGW lppd
= PrintStructures
->dlg
.lpPrintDlg
;
1842 UINT PrinterComboID
= (lppd
->Flags
& PD_PRINTSETUP
) ? cmb1
: cmb4
;
1843 LPDEVMODEW lpdm
= PrintStructures
->lpDevMode
;
1845 switch (LOWORD(wParam
)) {
1847 TRACE(" OK button was hit\n");
1848 if (PRINTDLG_UpdatePrintDlgW(hDlg
, PrintStructures
)!=TRUE
) {
1849 FIXME("Update printdlg was not successful!\n");
1852 EndDialog(hDlg
, TRUE
);
1856 TRACE(" CANCEL button was hit\n");
1857 EndDialog(hDlg
, FALSE
);
1861 TRACE(" HELP button was hit\n");
1862 SendMessageW(lppd
->hwndOwner
, PrintStructures
->HelpMessageID
,
1863 (WPARAM
) hDlg
, (LPARAM
) lppd
);
1866 case chx2
: /* collate pages checkbox */
1867 if (IsDlgButtonChecked(hDlg
, chx2
) == BST_CHECKED
)
1868 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1869 (LPARAM
)PrintStructures
->hCollateIcon
);
1871 SendDlgItemMessageA(hDlg
, ico3
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1872 (LPARAM
)PrintStructures
->hNoCollateIcon
);
1874 case edt1
: /* from page nr editbox */
1875 case edt2
: /* to page nr editbox */
1876 if (HIWORD(wParam
)==EN_CHANGE
) {
1879 nFromPage
= GetDlgItemInt(hDlg
, edt1
, NULL
, FALSE
);
1880 nToPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
1881 if (nFromPage
!= lppd
->nFromPage
|| nToPage
!= lppd
->nToPage
)
1882 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
1887 if(HIWORD(wParam
) == EN_CHANGE
) {
1888 INT copies
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
1890 EnableWindow(GetDlgItem(hDlg
, chx2
), FALSE
);
1892 EnableWindow(GetDlgItem(hDlg
, chx2
), TRUE
);
1896 case psh1
: /* Print Setup */
1898 ERR("psh1 is called from 16bit code only, we should not get here.\n");
1901 case psh2
: /* Properties button */
1904 WCHAR PrinterName
[256];
1906 GetDlgItemTextW(hDlg
, PrinterComboID
, PrinterName
, 255);
1907 if (!OpenPrinterW(PrinterName
, &hPrinter
, NULL
)) {
1908 FIXME(" Call to OpenPrinter did not succeed!\n");
1911 DocumentPropertiesW(hDlg
, hPrinter
, PrinterName
,
1912 PrintStructures
->lpDevMode
,
1913 PrintStructures
->lpDevMode
,
1914 DM_IN_BUFFER
| DM_OUT_BUFFER
| DM_IN_PROMPT
);
1915 ClosePrinter(hPrinter
);
1919 case rad1
: /* Paperorientation */
1920 if (lppd
->Flags
& PD_PRINTSETUP
)
1922 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1923 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1924 (LPARAM
)(PrintStructures
->hPortraitIcon
));
1928 case rad2
: /* Paperorientation */
1929 if (lppd
->Flags
& PD_PRINTSETUP
)
1931 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1932 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
, (WPARAM
) IMAGE_ICON
,
1933 (LPARAM
)(PrintStructures
->hLandscapeIcon
));
1937 case cmb1
: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */
1938 if (PrinterComboID
!= wParam
) {
1939 FIXME("No handling for print quality combo box yet.\n");
1943 case cmb4
: /* Printer combobox */
1944 if (HIWORD(wParam
)==CBN_SELCHANGE
) {
1945 WCHAR PrinterName
[256];
1946 GetDlgItemTextW(hDlg
, LOWORD(wParam
), PrinterName
, 255);
1947 PRINTDLG_ChangePrinterW(hDlg
, PrinterName
, PrintStructures
);
1951 case cmb2
: /* Papersize */
1953 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
1955 lpdm
->u1
.s1
.dmPaperSize
= SendDlgItemMessageA(hDlg
, cmb2
,
1961 case cmb3
: /* Bin */
1963 DWORD Sel
= SendDlgItemMessageA(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
1965 lpdm
->dmDefaultSource
= SendDlgItemMessageW(hDlg
, cmb3
,
1966 CB_GETITEMDATA
, Sel
,
1971 if(lppd
->Flags
& PD_PRINTSETUP
) {
1972 switch (LOWORD(wParam
)) {
1973 case rad1
: /* orientation */
1975 if (IsDlgButtonChecked(hDlg
, rad1
) == BST_CHECKED
) {
1976 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_PORTRAIT
) {
1977 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_PORTRAIT
;
1978 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1980 (LPARAM
)PrintStructures
->hPortraitIcon
);
1981 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1983 (LPARAM
)PrintStructures
->hPortraitIcon
);
1986 if(lpdm
->u1
.s1
.dmOrientation
!= DMORIENT_LANDSCAPE
) {
1987 lpdm
->u1
.s1
.dmOrientation
= DMORIENT_LANDSCAPE
;
1988 SendDlgItemMessageA(hDlg
, stc10
, STM_SETIMAGE
,
1990 (LPARAM
)PrintStructures
->hLandscapeIcon
);
1991 SendDlgItemMessageA(hDlg
, ico1
, STM_SETIMAGE
,
1993 (LPARAM
)PrintStructures
->hLandscapeIcon
);
2002 /***********************************************************************
2003 * PrintDlgProcA [internal]
2005 INT_PTR CALLBACK
PrintDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
2008 PRINT_PTRA
* PrintStructures
;
2009 INT_PTR res
= FALSE
;
2011 if (uMsg
!=WM_INITDIALOG
) {
2012 PrintStructures
= (PRINT_PTRA
*)GetPropA(hDlg
,"__WINE_PRINTDLGDATA");
2013 if (!PrintStructures
)
2016 PrintStructures
= (PRINT_PTRA
*) lParam
;
2017 SetPropA(hDlg
,"__WINE_PRINTDLGDATA",PrintStructures
);
2018 res
= PRINTDLG_WMInitDialog(hDlg
, wParam
, PrintStructures
);
2020 if(PrintStructures
->dlg
.lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
)
2021 res
= PrintStructures
->dlg
.lpPrintDlg
->lpfnPrintHook(
2022 hDlg
, uMsg
, wParam
, (LPARAM
)PrintStructures
->dlg
.lpPrintDlg
2027 if(PrintStructures
->dlg
.lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
) {
2028 res
= PrintStructures
->dlg
.lpPrintDlg
->lpfnPrintHook(hDlg
,uMsg
,wParam
,
2035 return PRINTDLG_WMCommandA(hDlg
, wParam
, lParam
, PrintStructures
);
2038 DestroyIcon(PrintStructures
->hCollateIcon
);
2039 DestroyIcon(PrintStructures
->hNoCollateIcon
);
2040 DestroyIcon(PrintStructures
->hPortraitIcon
);
2041 DestroyIcon(PrintStructures
->hLandscapeIcon
);
2042 if(PrintStructures
->hwndUpDown
)
2043 DestroyWindow(PrintStructures
->hwndUpDown
);
2049 INT_PTR CALLBACK
PrintDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
2052 PRINT_PTRW
* PrintStructures
;
2053 INT_PTR res
= FALSE
;
2055 if (uMsg
!=WM_INITDIALOG
) {
2056 PrintStructures
= (PRINT_PTRW
*) GetWindowLongW(hDlg
, DWL_USER
);
2057 if (!PrintStructures
)
2060 PrintStructures
= (PRINT_PTRW
*) lParam
;
2061 SetWindowLongA(hDlg
, DWL_USER
, lParam
);
2062 res
= PRINTDLG_WMInitDialogW(hDlg
, wParam
, PrintStructures
);
2064 if(PrintStructures
->dlg
.lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
)
2065 res
= PrintStructures
->dlg
.lpPrintDlg
->lpfnPrintHook(
2066 hDlg
, uMsg
, wParam
, (LPARAM
)PrintStructures
->dlg
.lpPrintDlg
2071 if(PrintStructures
->dlg
.lpPrintDlg
->Flags
& PD_ENABLEPRINTHOOK
) {
2072 res
= PrintStructures
->dlg
.lpPrintDlg
->lpfnPrintHook(hDlg
,uMsg
,wParam
,
2079 return PRINTDLG_WMCommandW(hDlg
, wParam
, lParam
, PrintStructures
);
2082 DestroyIcon(PrintStructures
->hCollateIcon
);
2083 DestroyIcon(PrintStructures
->hNoCollateIcon
);
2084 DestroyIcon(PrintStructures
->hPortraitIcon
);
2085 DestroyIcon(PrintStructures
->hLandscapeIcon
);
2086 if(PrintStructures
->hwndUpDown
)
2087 DestroyWindow(PrintStructures
->hwndUpDown
);
2094 /************************************************************
2096 * PRINTDLG_Get16TemplateFrom32 [Internal]
2097 * Generates a 16 bits template from the Wine 32 bits resource
2100 static HGLOBAL16
PRINTDLG_Get16TemplateFrom32(char *PrintResourceName
)
2106 HGLOBAL16 hGlobal16
;
2109 if (!(hResInfo
= FindResourceA(COMDLG32_hInstance
,
2110 PrintResourceName
, RT_DIALOGA
)))
2112 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
2115 if (!(hDlgTmpl32
= LoadResource(COMDLG32_hInstance
, hResInfo
)) ||
2116 !(template32
= LockResource( hDlgTmpl32
)))
2118 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2121 size
= SizeofResource(COMDLG32_hInstance
, hResInfo
);
2122 hGlobal16
= GlobalAlloc16(0, size
);
2125 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE
);
2126 ERR("alloc failure for %ld bytes\n", size
);
2129 template = GlobalLock16(hGlobal16
);
2132 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE
);
2133 ERR("global lock failure for %x handle\n", hGlobal16
);
2134 GlobalFree16(hGlobal16
);
2137 ConvertDialog32To16((LPVOID
)template32
, size
, (LPVOID
)template);
2138 GlobalUnlock16(hGlobal16
);
2142 /************************************************************
2144 * PRINTDLG_GetDlgTemplate
2147 static HGLOBAL
PRINTDLG_GetDlgTemplateA(PRINTDLGA
*lppd
)
2152 if (lppd
->Flags
& PD_PRINTSETUP
) {
2153 if(lppd
->Flags
& PD_ENABLESETUPTEMPLATEHANDLE
) {
2154 hDlgTmpl
= lppd
->hSetupTemplate
;
2155 } else if(lppd
->Flags
& PD_ENABLESETUPTEMPLATE
) {
2156 hResInfo
= FindResourceA(lppd
->hInstance
,
2157 lppd
->lpSetupTemplateName
, RT_DIALOGA
);
2158 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2160 hResInfo
= FindResourceA(COMDLG32_hInstance
, "PRINT32_SETUP",
2162 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
2165 if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATEHANDLE
) {
2166 hDlgTmpl
= lppd
->hPrintTemplate
;
2167 } else if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATE
) {
2168 hResInfo
= FindResourceA(lppd
->hInstance
,
2169 lppd
->lpPrintTemplateName
,
2171 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2173 hResInfo
= FindResourceA(COMDLG32_hInstance
, "PRINT32",
2175 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
2181 static HGLOBAL
PRINTDLG_GetDlgTemplateW(PRINTDLGW
*lppd
)
2185 const WCHAR xpsetup
[] = { 'P','R','I','N','T','3','2','_','S','E','T','U','P',0};
2186 const WCHAR xprint
[] = { 'P','R','I','N','T','3','2',0};
2188 if (lppd
->Flags
& PD_PRINTSETUP
) {
2189 if(lppd
->Flags
& PD_ENABLESETUPTEMPLATEHANDLE
) {
2190 hDlgTmpl
= lppd
->hSetupTemplate
;
2191 } else if(lppd
->Flags
& PD_ENABLESETUPTEMPLATE
) {
2192 hResInfo
= FindResourceW(lppd
->hInstance
,
2193 lppd
->lpSetupTemplateName
, RT_DIALOGW
);
2194 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2196 hResInfo
= FindResourceW(COMDLG32_hInstance
, xpsetup
, RT_DIALOGW
);
2197 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
2200 if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATEHANDLE
) {
2201 hDlgTmpl
= lppd
->hPrintTemplate
;
2202 } else if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATE
) {
2203 hResInfo
= FindResourceW(lppd
->hInstance
,
2204 lppd
->lpPrintTemplateName
,
2206 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2208 hResInfo
= FindResourceW(COMDLG32_hInstance
, xprint
, RT_DIALOGW
);
2209 hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
);
2217 /************************************************************
2219 * PRINTDLG_GetDlgTemplate
2222 static HGLOBAL16
PRINTDLG_GetDlgTemplate16(PRINTDLG16
*lppd
)
2224 HGLOBAL16 hDlgTmpl
, hResInfo
;
2226 if (lppd
->Flags
& PD_PRINTSETUP
) {
2227 if(lppd
->Flags
& PD_ENABLESETUPTEMPLATEHANDLE
) {
2228 hDlgTmpl
= lppd
->hSetupTemplate
;
2229 } else if(lppd
->Flags
& PD_ENABLESETUPTEMPLATE
) {
2230 hResInfo
= FindResource16(lppd
->hInstance
,
2231 MapSL(lppd
->lpSetupTemplateName
), RT_DIALOGA
);
2232 hDlgTmpl
= LoadResource16(lppd
->hInstance
, hResInfo
);
2234 hDlgTmpl
= PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP");
2237 if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATEHANDLE
) {
2238 hDlgTmpl
= lppd
->hPrintTemplate
;
2239 } else if(lppd
->Flags
& PD_ENABLEPRINTTEMPLATE
) {
2240 hResInfo
= FindResource16(lppd
->hInstance
,
2241 MapSL(lppd
->lpPrintTemplateName
),
2243 hDlgTmpl
= LoadResource16(lppd
->hInstance
, hResInfo
);
2245 hDlgTmpl
= PRINTDLG_Get16TemplateFrom32("PRINT32");
2251 /***********************************************************************
2256 static BOOL
PRINTDLG_CreateDCA(LPPRINTDLGA lppd
)
2258 DEVNAMES
*pdn
= GlobalLock(lppd
->hDevNames
);
2259 DEVMODEA
*pdm
= GlobalLock(lppd
->hDevMode
);
2261 if(lppd
->Flags
& PD_RETURNDC
) {
2262 lppd
->hDC
= CreateDCA((char*)pdn
+ pdn
->wDriverOffset
,
2263 (char*)pdn
+ pdn
->wDeviceOffset
,
2264 (char*)pdn
+ pdn
->wOutputOffset
,
2266 } else if(lppd
->Flags
& PD_RETURNIC
) {
2267 lppd
->hDC
= CreateICA((char*)pdn
+ pdn
->wDriverOffset
,
2268 (char*)pdn
+ pdn
->wDeviceOffset
,
2269 (char*)pdn
+ pdn
->wOutputOffset
,
2272 GlobalUnlock(lppd
->hDevNames
);
2273 GlobalUnlock(lppd
->hDevMode
);
2274 return lppd
->hDC
? TRUE
: FALSE
;
2277 static BOOL
PRINTDLG_CreateDCW(LPPRINTDLGW lppd
)
2279 DEVNAMES
*pdn
= GlobalLock(lppd
->hDevNames
);
2280 DEVMODEW
*pdm
= GlobalLock(lppd
->hDevMode
);
2282 if(lppd
->Flags
& PD_RETURNDC
) {
2283 lppd
->hDC
= CreateDCW((WCHAR
*)pdn
+ pdn
->wDriverOffset
,
2284 (WCHAR
*)pdn
+ pdn
->wDeviceOffset
,
2285 (WCHAR
*)pdn
+ pdn
->wOutputOffset
,
2287 } else if(lppd
->Flags
& PD_RETURNIC
) {
2288 lppd
->hDC
= CreateICW((WCHAR
*)pdn
+ pdn
->wDriverOffset
,
2289 (WCHAR
*)pdn
+ pdn
->wDeviceOffset
,
2290 (WCHAR
*)pdn
+ pdn
->wOutputOffset
,
2293 GlobalUnlock(lppd
->hDevNames
);
2294 GlobalUnlock(lppd
->hDevMode
);
2295 return lppd
->hDC
? TRUE
: FALSE
;
2298 static BOOL
PRINTDLG_CreateDC16(LPPRINTDLG16 lppd
)
2300 DEVNAMES
*pdn
= GlobalLock16(lppd
->hDevNames
);
2301 DEVMODEA
*pdm
= GlobalLock16(lppd
->hDevMode
);
2303 if(lppd
->Flags
& PD_RETURNDC
) {
2304 lppd
->hDC
= HDC_16(CreateDCA((char*)pdn
+ pdn
->wDriverOffset
,
2305 (char*)pdn
+ pdn
->wDeviceOffset
,
2306 (char*)pdn
+ pdn
->wOutputOffset
,
2308 } else if(lppd
->Flags
& PD_RETURNIC
) {
2309 lppd
->hDC
= HDC_16(CreateICA((char*)pdn
+ pdn
->wDriverOffset
,
2310 (char*)pdn
+ pdn
->wDeviceOffset
,
2311 (char*)pdn
+ pdn
->wOutputOffset
,
2314 GlobalUnlock16(lppd
->hDevNames
);
2315 GlobalUnlock16(lppd
->hDevMode
);
2316 return lppd
->hDC
? TRUE
: FALSE
;
2319 /***********************************************************************
2320 * PrintDlgA (COMDLG32.@)
2322 * Displays the the PRINT dialog box, which enables the user to specify
2323 * specific properties of the print job.
2326 * nonzero if the user pressed the OK button
2327 * zero if the user cancelled the window or an error occurred
2331 * * The Collate Icons do not display, even though they are in the code.
2332 * * The Properties Button(s) should call DocumentPropertiesA().
2334 * * The Paper Orientation Icons are not implemented yet.
2335 * * The Properties Button(s) should call DocumentPropertiesA().
2336 * * Settings are not yet taken from a provided DevMode or
2337 * default printer settings.
2340 BOOL WINAPI
PrintDlgA(
2341 LPPRINTDLGA lppd
/* [in/out] ptr to PRINTDLG32 struct */
2346 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongA( lppd
->hwndOwner
, GWL_HINSTANCE
);
2348 if(TRACE_ON(commdlg
)) {
2349 char flagstr
[1000] = "";
2350 struct pd_flags
*pflag
= pd_flags
;
2351 for( ; pflag
->name
; pflag
++) {
2352 if(lppd
->Flags
& pflag
->flag
)
2353 strcat(flagstr
, pflag
->name
);
2355 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2356 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
2357 "flags %08lx (%s)\n",
2358 lppd
, lppd
->hwndOwner
, lppd
->hDevMode
, lppd
->hDevNames
,
2359 lppd
->nFromPage
, lppd
->nToPage
, lppd
->nMinPage
, lppd
->nMaxPage
,
2360 lppd
->nCopies
, lppd
->hInstance
, lppd
->Flags
, flagstr
);
2363 if(lppd
->lStructSize
!= sizeof(PRINTDLGA
)) {
2364 WARN("structure size failure !!!\n");
2365 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE
);
2369 if(lppd
->Flags
& PD_RETURNDEFAULT
) {
2370 PRINTER_INFO_2A
*pbuf
;
2371 DRIVER_INFO_3A
*dbuf
;
2375 if(lppd
->hDevMode
|| lppd
->hDevNames
) {
2376 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
2377 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2380 if(!PRINTDLG_OpenDefaultPrinter(&hprn
)) {
2381 WARN("Can't find default printer\n");
2382 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN
);
2386 GetPrinterA(hprn
, 2, NULL
, 0, &needed
);
2387 pbuf
= HeapAlloc(GetProcessHeap(), 0, needed
);
2388 GetPrinterA(hprn
, 2, (LPBYTE
)pbuf
, needed
, &needed
);
2390 GetPrinterDriverA(hprn
, NULL
, 3, NULL
, 0, &needed
);
2391 dbuf
= HeapAlloc(GetProcessHeap(),0,needed
);
2392 if (!GetPrinterDriverA(hprn
, NULL
, 3, (LPBYTE
)dbuf
, needed
, &needed
)) {
2393 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf
->pPrinterName
);
2394 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2399 PRINTDLG_CreateDevNames(&(lppd
->hDevNames
),
2403 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
, pbuf
->pDevMode
->dmSize
+
2404 pbuf
->pDevMode
->dmDriverExtra
);
2405 ptr
= GlobalLock(lppd
->hDevMode
);
2406 memcpy(ptr
, pbuf
->pDevMode
, pbuf
->pDevMode
->dmSize
+
2407 pbuf
->pDevMode
->dmDriverExtra
);
2408 GlobalUnlock(lppd
->hDevMode
);
2409 HeapFree(GetProcessHeap(), 0, pbuf
);
2410 HeapFree(GetProcessHeap(), 0, dbuf
);
2414 PRINT_PTRA
*PrintStructures
;
2416 /* load Dialog resources,
2417 * depending on Flags indicates Print32 or Print32_setup dialog
2419 hDlgTmpl
= PRINTDLG_GetDlgTemplateA(lppd
);
2421 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2424 ptr
= LockResource( hDlgTmpl
);
2426 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2430 PrintStructures
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2431 sizeof(PRINT_PTRA
));
2432 PrintStructures
->dlg
.lpPrintDlg
= lppd
;
2434 /* and create & process the dialog .
2435 * -1 is failure, 0 is broken hwnd, everything else is ok.
2437 bRet
= (0<DialogBoxIndirectParamA(hInst
, ptr
, lppd
->hwndOwner
,
2439 (LPARAM
)PrintStructures
));
2442 DEVMODEA
*lpdm
= PrintStructures
->lpDevMode
, *lpdmReturn
;
2443 PRINTER_INFO_2A
*pi
= PrintStructures
->lpPrinterInfo
;
2444 DRIVER_INFO_3A
*di
= PrintStructures
->lpDriverInfo
;
2446 if (lppd
->hDevMode
== 0) {
2447 TRACE(" No hDevMode yet... Need to create my own\n");
2448 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
,
2449 lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2452 if((locks
= (GlobalFlags(lppd
->hDevMode
) & GMEM_LOCKCOUNT
))) {
2453 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks
);
2455 GlobalUnlock(lppd
->hDevMode
);
2456 TRACE("Now got %d locks\n", locks
);
2459 lppd
->hDevMode
= GlobalReAlloc(lppd
->hDevMode
,
2460 lpdm
->dmSize
+ lpdm
->dmDriverExtra
,
2463 lpdmReturn
= GlobalLock(lppd
->hDevMode
);
2464 memcpy(lpdmReturn
, lpdm
, lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2466 if (lppd
->hDevNames
!= 0) {
2468 if((locks
= (GlobalFlags(lppd
->hDevNames
) & GMEM_LOCKCOUNT
))) {
2469 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks
);
2471 GlobalUnlock(lppd
->hDevNames
);
2474 PRINTDLG_CreateDevNames(&(lppd
->hDevNames
),
2479 GlobalUnlock(lppd
->hDevMode
);
2481 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
2482 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpPrinterInfo
);
2483 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDriverInfo
);
2484 HeapFree(GetProcessHeap(), 0, PrintStructures
);
2486 if(bRet
&& (lppd
->Flags
& PD_RETURNDC
|| lppd
->Flags
& PD_RETURNIC
))
2487 bRet
= PRINTDLG_CreateDCA(lppd
);
2489 TRACE("exit! (%d)\n", bRet
);
2493 /***********************************************************************
2494 * PrintDlgW (COMDLG32.@)
2496 BOOL WINAPI
PrintDlgW(
2497 LPPRINTDLGW lppd
/* [in/out] ptr to PRINTDLG32 struct */
2502 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongW( lppd
->hwndOwner
, GWL_HINSTANCE
);
2504 if(TRACE_ON(commdlg
)) {
2505 char flagstr
[1000] = "";
2506 struct pd_flags
*pflag
= pd_flags
;
2507 for( ; pflag
->name
; pflag
++) {
2508 if(lppd
->Flags
& pflag
->flag
)
2509 strcat(flagstr
, pflag
->name
);
2511 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2512 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
2513 "flags %08lx (%s)\n",
2514 lppd
, lppd
->hwndOwner
, lppd
->hDevMode
, lppd
->hDevNames
,
2515 lppd
->nFromPage
, lppd
->nToPage
, lppd
->nMinPage
, lppd
->nMaxPage
,
2516 lppd
->nCopies
, lppd
->hInstance
, lppd
->Flags
, flagstr
);
2519 if(lppd
->lStructSize
!= sizeof(PRINTDLGW
)) {
2520 WARN("structure size failure !!!\n");
2521 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE
);
2525 if(lppd
->Flags
& PD_RETURNDEFAULT
) {
2526 PRINTER_INFO_2W
*pbuf
;
2527 DRIVER_INFO_3W
*dbuf
;
2531 if(lppd
->hDevMode
|| lppd
->hDevNames
) {
2532 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
2533 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2536 if(!PRINTDLG_OpenDefaultPrinter(&hprn
)) {
2537 WARN("Can't find default printer\n");
2538 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN
);
2542 GetPrinterW(hprn
, 2, NULL
, 0, &needed
);
2543 pbuf
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*needed
);
2544 GetPrinterW(hprn
, 2, (LPBYTE
)pbuf
, needed
, &needed
);
2546 GetPrinterDriverW(hprn
, NULL
, 3, NULL
, 0, &needed
);
2547 dbuf
= HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR
)*needed
);
2548 if (!GetPrinterDriverW(hprn
, NULL
, 3, (LPBYTE
)dbuf
, needed
, &needed
)) {
2549 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),debugstr_w(pbuf
->pPrinterName
));
2550 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2555 PRINTDLG_CreateDevNamesW(&(lppd
->hDevNames
),
2559 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
, pbuf
->pDevMode
->dmSize
+
2560 pbuf
->pDevMode
->dmDriverExtra
);
2561 ptr
= GlobalLock(lppd
->hDevMode
);
2562 memcpy(ptr
, pbuf
->pDevMode
, pbuf
->pDevMode
->dmSize
+
2563 pbuf
->pDevMode
->dmDriverExtra
);
2564 GlobalUnlock(lppd
->hDevMode
);
2565 HeapFree(GetProcessHeap(), 0, pbuf
);
2566 HeapFree(GetProcessHeap(), 0, dbuf
);
2570 PRINT_PTRW
*PrintStructures
;
2572 /* load Dialog resources,
2573 * depending on Flags indicates Print32 or Print32_setup dialog
2575 hDlgTmpl
= PRINTDLG_GetDlgTemplateW(lppd
);
2577 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2580 ptr
= LockResource( hDlgTmpl
);
2582 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2586 PrintStructures
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2587 sizeof(PRINT_PTRW
));
2588 PrintStructures
->dlg
.lpPrintDlg
= lppd
;
2590 /* and create & process the dialog .
2591 * -1 is failure, 0 is broken hwnd, everything else is ok.
2593 bRet
= (0<DialogBoxIndirectParamW(hInst
, ptr
, lppd
->hwndOwner
,
2595 (LPARAM
)PrintStructures
));
2598 DEVMODEW
*lpdm
= PrintStructures
->lpDevMode
, *lpdmReturn
;
2599 PRINTER_INFO_2W
*pi
= PrintStructures
->lpPrinterInfo
;
2600 DRIVER_INFO_3W
*di
= PrintStructures
->lpDriverInfo
;
2602 if (lppd
->hDevMode
== 0) {
2603 TRACE(" No hDevMode yet... Need to create my own\n");
2604 lppd
->hDevMode
= GlobalAlloc(GMEM_MOVEABLE
,
2605 lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2608 if((locks
= (GlobalFlags(lppd
->hDevMode
) & GMEM_LOCKCOUNT
))) {
2609 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks
);
2611 GlobalUnlock(lppd
->hDevMode
);
2612 TRACE("Now got %d locks\n", locks
);
2615 lppd
->hDevMode
= GlobalReAlloc(lppd
->hDevMode
,
2616 lpdm
->dmSize
+ lpdm
->dmDriverExtra
,
2619 lpdmReturn
= GlobalLock(lppd
->hDevMode
);
2620 memcpy(lpdmReturn
, lpdm
, lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2622 if (lppd
->hDevNames
!= 0) {
2624 if((locks
= (GlobalFlags(lppd
->hDevNames
) & GMEM_LOCKCOUNT
))) {
2625 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks
);
2627 GlobalUnlock(lppd
->hDevNames
);
2630 PRINTDLG_CreateDevNamesW(&(lppd
->hDevNames
),
2635 GlobalUnlock(lppd
->hDevMode
);
2637 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
2638 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpPrinterInfo
);
2639 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDriverInfo
);
2640 HeapFree(GetProcessHeap(), 0, PrintStructures
);
2642 if(bRet
&& (lppd
->Flags
& PD_RETURNDC
|| lppd
->Flags
& PD_RETURNIC
))
2643 bRet
= PRINTDLG_CreateDCW(lppd
);
2645 TRACE("exit! (%d)\n", bRet
);
2649 /***********************************************************************
2650 * PrintDlg (COMMDLG.20)
2652 * Displays the the PRINT dialog box, which enables the user to specify
2653 * specific properties of the print job.
2656 * nonzero if the user pressed the OK button
2657 * zero if the user cancelled the window or an error occurred
2660 * * calls up to the 32-bit versions of the Dialogs, which look different
2661 * * Customizing is *not* implemented.
2664 BOOL16 WINAPI
PrintDlg16(
2665 LPPRINTDLG16 lppd
/* [in/out] ptr to PRINTDLG struct */
2669 HINSTANCE16 hInst
= GetWindowWord( HWND_32(lppd
->hwndOwner
), GWL_HINSTANCE
);
2671 if(TRACE_ON(commdlg
)) {
2672 char flagstr
[1000] = "";
2673 struct pd_flags
*pflag
= pd_flags
;
2674 for( ; pflag
->name
; pflag
++) {
2675 if(lppd
->Flags
& pflag
->flag
)
2676 strcat(flagstr
, pflag
->name
);
2678 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"
2679 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"
2680 "flags %08lx (%s)\n",
2681 lppd
, lppd
->hwndOwner
, lppd
->hDevMode
, lppd
->hDevNames
,
2682 lppd
->nFromPage
, lppd
->nToPage
, lppd
->nMinPage
, lppd
->nMaxPage
,
2683 lppd
->nCopies
, lppd
->hInstance
, lppd
->Flags
, flagstr
);
2686 if(lppd
->lStructSize
!= sizeof(PRINTDLG16
)) {
2687 ERR("structure size (%ld/%d)\n",lppd
->lStructSize
,sizeof(PRINTDLG16
));
2688 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE
);
2692 if(lppd
->Flags
& PD_RETURNDEFAULT
) {
2693 PRINTER_INFO_2A
*pbuf
;
2694 DRIVER_INFO_3A
*dbuf
;
2698 if(lppd
->hDevMode
|| lppd
->hDevNames
) {
2699 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
2700 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2703 if(!PRINTDLG_OpenDefaultPrinter(&hprn
)) {
2704 WARN("Can't find default printer\n");
2705 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN
);
2709 GetPrinterA(hprn
, 2, NULL
, 0, &needed
);
2710 pbuf
= HeapAlloc(GetProcessHeap(), 0, needed
);
2711 GetPrinterA(hprn
, 2, (LPBYTE
)pbuf
, needed
, &needed
);
2712 GetPrinterDriverA(hprn
, NULL
, 3, NULL
, 0, &needed
);
2713 dbuf
= HeapAlloc(GetProcessHeap(),0,needed
);
2714 if (!GetPrinterDriverA(hprn
, NULL
, 3, (LPBYTE
)dbuf
, needed
, &needed
)) {
2715 ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n",
2716 pbuf
->pPrinterName
,GetLastError());
2717 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE
);
2721 PRINTDLG_CreateDevNames16(&(lppd
->hDevNames
),
2725 lppd
->hDevMode
= GlobalAlloc16(GMEM_MOVEABLE
,pbuf
->pDevMode
->dmSize
+
2726 pbuf
->pDevMode
->dmDriverExtra
);
2727 ptr
= GlobalLock16(lppd
->hDevMode
);
2728 memcpy(ptr
, pbuf
->pDevMode
, pbuf
->pDevMode
->dmSize
+
2729 pbuf
->pDevMode
->dmDriverExtra
);
2730 GlobalUnlock16(lppd
->hDevMode
);
2731 HeapFree(GetProcessHeap(), 0, pbuf
);
2732 HeapFree(GetProcessHeap(), 0, dbuf
);
2736 PRINT_PTRA
*PrintStructures
;
2738 /* load Dialog resources,
2739 * depending on Flags indicates Print32 or Print32_setup dialog
2741 hDlgTmpl
= PRINTDLG_GetDlgTemplate16(lppd
);
2743 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
2746 PrintStructures
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
2747 sizeof(PRINT_PTRA
));
2748 PrintStructures
->dlg
.lpPrintDlg16
= lppd
;
2749 PrintStructures
->dlg
.lpPrintDlg
= (LPPRINTDLGA
)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(PRINTDLGA
));
2750 #define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x;
2751 #define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x);
2753 PrintStructures
->dlg
.lpPrintDlg
->hwndOwner
= HWND_32(lppd
->hwndOwner
);
2754 PrintStructures
->dlg
.lpPrintDlg
->hDC
= HDC_32(lppd
->hDC
);
2755 CVAL(nFromPage
);CVAL(nToPage
);CVAL(nMinPage
);CVAL(nMaxPage
);
2757 PrintStructures
->dlg
.lpPrintDlg
->hInstance
= HINSTANCE_32(lppd
->hInstance
);
2759 MVAL(lpPrintTemplateName
);MVAL(lpSetupTemplateName
);
2760 /* Don't copy rest, it is 16 bit specific */
2764 PrintStructures
->lpDevMode
= HeapAlloc(GetProcessHeap(),0,sizeof(DEVMODEA
));
2766 /* and create & process the dialog .
2767 * -1 is failure, 0 is broken hwnd, everything else is ok.
2769 bRet
= (0<DialogBoxIndirectParam16(
2770 hInst
, hDlgTmpl
, lppd
->hwndOwner
,
2771 (DLGPROC16
)GetProcAddress16(GetModuleHandle16("COMMDLG"),(LPCSTR
)21),
2772 (LPARAM
)PrintStructures
2775 if (!PrintStructures
->lpPrinterInfo
) bRet
= FALSE
;
2777 DEVMODEA
*lpdm
= PrintStructures
->lpDevMode
, *lpdmReturn
;
2778 PRINTER_INFO_2A
*pi
= PrintStructures
->lpPrinterInfo
;
2779 DRIVER_INFO_3A
*di
= PrintStructures
->lpDriverInfo
;
2781 if (lppd
->hDevMode
== 0) {
2782 TRACE(" No hDevMode yet... Need to create my own\n");
2783 lppd
->hDevMode
= GlobalAlloc16(GMEM_MOVEABLE
,
2784 lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2787 if((locks
= (GlobalFlags16(lppd
->hDevMode
)&GMEM_LOCKCOUNT
))) {
2788 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks
);
2790 GlobalUnlock16(lppd
->hDevMode
);
2791 TRACE("Now got %d locks\n", locks
);
2794 lppd
->hDevMode
= GlobalReAlloc16(lppd
->hDevMode
,
2795 lpdm
->dmSize
+ lpdm
->dmDriverExtra
,
2798 lpdmReturn
= GlobalLock16(lppd
->hDevMode
);
2799 memcpy(lpdmReturn
, lpdm
, lpdm
->dmSize
+ lpdm
->dmDriverExtra
);
2801 if (lppd
->hDevNames
!= 0) {
2803 if((locks
= (GlobalFlags16(lppd
->hDevNames
)&GMEM_LOCKCOUNT
))) {
2804 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks
);
2806 GlobalUnlock16(lppd
->hDevNames
);
2809 PRINTDLG_CreateDevNames16(&(lppd
->hDevNames
),
2814 GlobalUnlock16(lppd
->hDevMode
);
2816 if (!(lppd
->Flags
& (PD_ENABLESETUPTEMPLATEHANDLE
| PD_ENABLESETUPTEMPLATE
)))
2817 GlobalFree16(hDlgTmpl
); /* created from the 32 bits resource */
2818 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDevMode
);
2819 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpPrinterInfo
);
2820 HeapFree(GetProcessHeap(), 0, PrintStructures
->lpDriverInfo
);
2821 HeapFree(GetProcessHeap(), 0, PrintStructures
);
2823 if(bRet
&& (lppd
->Flags
& PD_RETURNDC
|| lppd
->Flags
& PD_RETURNIC
))
2824 bRet
= PRINTDLG_CreateDC16(lppd
);
2826 TRACE("exit! (%d)\n", bRet
);
2831 /***********************************************************************
2837 * cmb3 - source (tray?)
2838 * edt4 - border left
2840 * edt6 - border right
2841 * edt7 - border bottom
2842 * psh3 - "Printer..."
2846 LPPAGESETUPDLGA dlga
;
2851 LPPAGESETUPDLGW dlga
;
2855 static HGLOBAL
PRINTDLG_GetPGSTemplateA(PAGESETUPDLGA
*lppd
)
2860 if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATEHANDLE
) {
2861 hDlgTmpl
= lppd
->hPageSetupTemplate
;
2862 } else if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATE
) {
2863 hResInfo
= FindResourceA(lppd
->hInstance
,
2864 lppd
->lpPageSetupTemplateName
, RT_DIALOGA
);
2865 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2867 hResInfo
= FindResourceA(COMDLG32_hInstance
,(LPCSTR
)PAGESETUPDLGORD
,RT_DIALOGA
);
2868 hDlgTmpl
= LoadResource(COMDLG32_hInstance
,hResInfo
);
2873 static HGLOBAL
PRINTDLG_GetPGSTemplateW(PAGESETUPDLGW
*lppd
)
2878 if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATEHANDLE
) {
2879 hDlgTmpl
= lppd
->hPageSetupTemplate
;
2880 } else if(lppd
->Flags
& PSD_ENABLEPAGESETUPTEMPLATE
) {
2881 hResInfo
= FindResourceW(lppd
->hInstance
,
2882 lppd
->lpPageSetupTemplateName
, RT_DIALOGW
);
2883 hDlgTmpl
= LoadResource(lppd
->hInstance
, hResInfo
);
2885 hResInfo
= FindResourceW(COMDLG32_hInstance
,(LPCWSTR
)PAGESETUPDLGORD
,RT_DIALOGW
);
2886 hDlgTmpl
= LoadResource(COMDLG32_hInstance
,hResInfo
);
2892 _c_10mm2size(PAGESETUPDLGA
*dlga
,DWORD size
) {
2893 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2894 return 10*size
*10/25.4;
2895 /* If we don't have a flag, we can choose one. Use millimeters
2896 * to avoid confusing me
2898 dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2904 _c_inch2size(PAGESETUPDLGA
*dlga
,DWORD size
) {
2905 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2907 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
)
2908 return (size
*254)/10;
2909 /* if we don't have a flag, we can choose one. Use millimeters
2910 * to avoid confusing me
2912 dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2913 return (size
*254)/10;
2917 _c_size2strA(PageSetupDataA
*pda
,DWORD size
,LPSTR strout
) {
2918 strcpy(strout
,"<undef>");
2919 if (pda
->dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2920 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2923 if (pda
->dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2924 sprintf(strout
,"%.2fin",(size
*1.0)/1000.0);
2927 pda
->dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2928 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2932 _c_size2strW(PageSetupDataW
*pda
,DWORD size
,LPSTR strout
) {
2933 strcpy(strout
,"<undef>");
2934 if (pda
->dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2935 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2938 if (pda
->dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2939 sprintf(strout
,"%.2fin",(size
*1.0)/1000.0);
2942 pda
->dlga
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
2943 sprintf(strout
,"%.2fmm",(size
*1.0)/100.0);
2948 _c_str2size(PAGESETUPDLGA
*dlga
,LPCSTR strin
) {
2953 if (!sscanf(strin
,"%f%s",&val
,rest
))
2956 if (!strcmp(rest
,"in") || !strcmp(rest
,"inch")) {
2957 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
)
2960 return val
*25.4*100;
2962 if (!strcmp(rest
,"cm")) { rest
[0]='m'; val
= val
*10.0; }
2963 if (!strcmp(rest
,"m")) { strcpy(rest
,"mm"); val
= val
*1000.0; }
2965 if (!strcmp(rest
,"mm")) {
2966 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
)
2969 return 1000.0*val
/25.4;
2971 if (rest
[0]=='\0') {
2972 /* use application supplied default */
2973 if (dlga
->Flags
& PSD_INHUNDREDTHSOFMILLIMETERS
) {
2977 if (dlga
->Flags
& PSD_INTHOUSANDTHSOFINCHES
) {
2982 ERR("Did not find a conversion for type '%s'!\n",rest
);
2988 * This is called on finish and will update the output fields of the
2992 PRINTDLG_PS_UpdateDlgStructA(HWND hDlg
, PageSetupDataA
*pda
) {
2995 LPSTR devname
,portname
;
2999 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
3000 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
3001 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
3002 portname
= ((char*)dn
)+dn
->wOutputOffset
;
3003 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb2
,devname
,portname
,dm
);
3004 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb3
,devname
,portname
,dm
);
3006 if (GetDlgItemTextA(hDlg
,cmb2
,papername
,sizeof(papername
))>0) {
3007 PRINTDLG_PaperSizeA(&(pda
->pdlg
),papername
,&(pda
->dlga
->ptPaperSize
));
3008 pda
->dlga
->ptPaperSize
.x
= _c_10mm2size(pda
->dlga
,pda
->dlga
->ptPaperSize
.x
);
3009 pda
->dlga
->ptPaperSize
.y
= _c_10mm2size(pda
->dlga
,pda
->dlga
->ptPaperSize
.y
);
3011 FIXME("could not get dialog text for papersize cmbbox?\n");
3012 #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); }
3013 GETVAL(edt4
,pda
->dlga
->rtMargin
.left
);
3014 GETVAL(edt5
,pda
->dlga
->rtMargin
.top
);
3015 GETVAL(edt6
,pda
->dlga
->rtMargin
.right
);
3016 GETVAL(edt7
,pda
->dlga
->rtMargin
.bottom
);
3019 /* If we are in landscape, swap x and y of page size */
3020 if (IsDlgButtonChecked(hDlg
, rad2
)) {
3022 tmp
= pda
->dlga
->ptPaperSize
.x
;
3023 pda
->dlga
->ptPaperSize
.x
= pda
->dlga
->ptPaperSize
.y
;
3024 pda
->dlga
->ptPaperSize
.y
= tmp
;
3026 GlobalUnlock(pda
->pdlg
.hDevNames
);
3027 GlobalUnlock(pda
->pdlg
.hDevMode
);
3032 PRINTDLG_PS_UpdateDlgStructW(HWND hDlg
, PageSetupDataW
*pda
) {
3035 LPWSTR devname
,portname
;
3036 WCHAR papername
[64];
3040 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
3041 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
3042 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
3043 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
3044 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb2
,devname
,portname
,dm
);
3045 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb3
,devname
,portname
,dm
);
3047 if (GetDlgItemTextW(hDlg
,cmb2
,papername
,sizeof(papername
))>0) {
3048 PRINTDLG_PaperSizeW(&(pda
->pdlg
),papername
,&(pda
->dlga
->ptPaperSize
));
3049 pda
->dlga
->ptPaperSize
.x
= _c_10mm2size((LPPAGESETUPDLGA
)pda
->dlga
,pda
->dlga
->ptPaperSize
.x
);
3050 pda
->dlga
->ptPaperSize
.y
= _c_10mm2size((LPPAGESETUPDLGA
)pda
->dlga
,pda
->dlga
->ptPaperSize
.y
);
3052 FIXME("could not get dialog text for papersize cmbbox?\n");
3053 #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); }
3054 GETVAL(edt4
,pda
->dlga
->rtMargin
.left
);
3055 GETVAL(edt5
,pda
->dlga
->rtMargin
.top
);
3056 GETVAL(edt6
,pda
->dlga
->rtMargin
.right
);
3057 GETVAL(edt7
,pda
->dlga
->rtMargin
.bottom
);
3060 /* If we are in landscape, swap x and y of page size */
3061 if (IsDlgButtonChecked(hDlg
, rad2
)) {
3063 tmp
= pda
->dlga
->ptPaperSize
.x
;
3064 pda
->dlga
->ptPaperSize
.x
= pda
->dlga
->ptPaperSize
.y
;
3065 pda
->dlga
->ptPaperSize
.y
= tmp
;
3067 GlobalUnlock(pda
->pdlg
.hDevNames
);
3068 GlobalUnlock(pda
->pdlg
.hDevMode
);
3073 * This is called after returning from PrintDlg().
3076 PRINTDLG_PS_ChangePrinterA(HWND hDlg
, PageSetupDataA
*pda
) {
3079 LPSTR devname
,portname
;
3081 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
3082 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
3083 devname
= ((char*)dn
)+dn
->wDeviceOffset
;
3084 portname
= ((char*)dn
)+dn
->wOutputOffset
;
3085 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb2
,devname
,portname
,dm
);
3086 PRINTDLG_SetUpPaperComboBoxA(hDlg
,cmb3
,devname
,portname
,dm
);
3087 GlobalUnlock(pda
->pdlg
.hDevNames
);
3088 GlobalUnlock(pda
->pdlg
.hDevMode
);
3093 PRINTDLG_PS_ChangePrinterW(HWND hDlg
, PageSetupDataW
*pda
) {
3096 LPWSTR devname
,portname
;
3098 dn
= GlobalLock(pda
->pdlg
.hDevNames
);
3099 dm
= GlobalLock(pda
->pdlg
.hDevMode
);
3100 devname
= ((WCHAR
*)dn
)+dn
->wDeviceOffset
;
3101 portname
= ((WCHAR
*)dn
)+dn
->wOutputOffset
;
3102 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb2
,devname
,portname
,dm
);
3103 PRINTDLG_SetUpPaperComboBoxW(hDlg
,cmb3
,devname
,portname
,dm
);
3104 GlobalUnlock(pda
->pdlg
.hDevNames
);
3105 GlobalUnlock(pda
->pdlg
.hDevMode
);
3110 PRINTDLG_PS_WMCommandA(
3111 HWND hDlg
, WPARAM wParam
, LPARAM lParam
, PageSetupDataA
*pda
3113 switch (LOWORD(wParam
)) {
3115 if (!PRINTDLG_PS_UpdateDlgStructA(hDlg
, pda
))
3117 EndDialog(hDlg
, TRUE
);
3121 EndDialog(hDlg
, FALSE
);
3125 pda
->pdlg
.Flags
= 0;
3126 pda
->pdlg
.hwndOwner
= hDlg
;
3127 if (PrintDlgA(&(pda
->pdlg
)))
3128 PRINTDLG_PS_ChangePrinterA(hDlg
,pda
);
3132 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
3133 LOWORD(lParam
),wParam
,lParam
3139 PRINTDLG_PS_WMCommandW(
3140 HWND hDlg
, WPARAM wParam
, LPARAM lParam
, PageSetupDataW
*pda
3142 switch (LOWORD(wParam
)) {
3144 if (!PRINTDLG_PS_UpdateDlgStructW(hDlg
, pda
))
3146 EndDialog(hDlg
, TRUE
);
3150 EndDialog(hDlg
, FALSE
);
3154 pda
->pdlg
.Flags
= 0;
3155 pda
->pdlg
.hwndOwner
= hDlg
;
3156 if (PrintDlgW(&(pda
->pdlg
)))
3157 PRINTDLG_PS_ChangePrinterW(hDlg
,pda
);
3161 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
3162 LOWORD(lParam
),wParam
,lParam
3168 static INT_PTR CALLBACK
3169 PageDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3171 PageSetupDataA
*pda
;
3172 INT_PTR res
= FALSE
;
3174 if (uMsg
==WM_INITDIALOG
) {
3176 pda
= (PageSetupDataA
*)lParam
;
3177 SetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA",pda
);
3178 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
3179 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
3181 FIXME("Setup page hook failed?\n");
3185 if (pda
->dlga
->Flags
& PSD_ENABLEPAGEPAINTHOOK
) {
3186 FIXME("PagePaintHook not yet implemented!\n");
3188 if (pda
->dlga
->Flags
& PSD_DISABLEPRINTER
)
3189 EnableWindow(GetDlgItem(hDlg
, psh3
), FALSE
);
3190 if (pda
->dlga
->Flags
& PSD_DISABLEMARGINS
) {
3191 EnableWindow(GetDlgItem(hDlg
, edt4
), FALSE
);
3192 EnableWindow(GetDlgItem(hDlg
, edt5
), FALSE
);
3193 EnableWindow(GetDlgItem(hDlg
, edt6
), FALSE
);
3194 EnableWindow(GetDlgItem(hDlg
, edt7
), FALSE
);
3196 /* width larger as height -> landscape */
3197 if (pda
->dlga
->ptPaperSize
.x
> pda
->dlga
->ptPaperSize
.y
)
3198 CheckRadioButton(hDlg
, rad1
, rad2
, rad2
);
3199 else /* this is default if papersize is not set */
3200 CheckRadioButton(hDlg
, rad1
, rad2
, rad1
);
3201 if (pda
->dlga
->Flags
& PSD_DISABLEORIENTATION
) {
3202 EnableWindow(GetDlgItem(hDlg
,rad1
),FALSE
);
3203 EnableWindow(GetDlgItem(hDlg
,rad2
),FALSE
);
3205 /* We fill them out enabled or not */
3206 if (pda
->dlga
->Flags
& PSD_MARGINS
) {
3208 _c_size2strA(pda
,pda
->dlga
->rtMargin
.left
,str
);
3209 SetDlgItemTextA(hDlg
,edt4
,str
);
3210 _c_size2strA(pda
,pda
->dlga
->rtMargin
.top
,str
);
3211 SetDlgItemTextA(hDlg
,edt5
,str
);
3212 _c_size2strA(pda
,pda
->dlga
->rtMargin
.right
,str
);
3213 SetDlgItemTextA(hDlg
,edt6
,str
);
3214 _c_size2strA(pda
,pda
->dlga
->rtMargin
.bottom
,str
);
3215 SetDlgItemTextA(hDlg
,edt7
,str
);
3217 /* default is 1 inch */
3218 DWORD size
= _c_inch2size(pda
->dlga
,1000);
3220 _c_size2strA(pda
,size
,str
);
3221 SetDlgItemTextA(hDlg
,edt4
,str
);
3222 SetDlgItemTextA(hDlg
,edt5
,str
);
3223 SetDlgItemTextA(hDlg
,edt6
,str
);
3224 SetDlgItemTextA(hDlg
,edt7
,str
);
3226 PRINTDLG_PS_ChangePrinterA(hDlg
,pda
);
3227 if (pda
->dlga
->Flags
& PSD_DISABLEPAPER
) {
3228 EnableWindow(GetDlgItem(hDlg
,cmb2
),FALSE
);
3229 EnableWindow(GetDlgItem(hDlg
,cmb3
),FALSE
);
3233 pda
= (PageSetupDataA
*)GetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA");
3235 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
3238 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
3239 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
3240 if (res
) return res
;
3245 return PRINTDLG_PS_WMCommandA(hDlg
, wParam
, lParam
, pda
);
3250 static INT_PTR CALLBACK
3251 PageDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3253 PageSetupDataW
*pda
;
3256 if (uMsg
==WM_INITDIALOG
) {
3258 pda
= (PageSetupDataW
*)lParam
;
3259 SetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA",pda
);
3260 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
3261 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
3263 FIXME("Setup page hook failed?\n");
3267 if (pda
->dlga
->Flags
& PSD_ENABLEPAGEPAINTHOOK
) {
3268 FIXME("PagePaintHook not yet implemented!\n");
3270 if (pda
->dlga
->Flags
& PSD_DISABLEPRINTER
)
3271 EnableWindow(GetDlgItem(hDlg
, psh3
), FALSE
);
3272 if (pda
->dlga
->Flags
& PSD_DISABLEMARGINS
) {
3273 EnableWindow(GetDlgItem(hDlg
, edt4
), FALSE
);
3274 EnableWindow(GetDlgItem(hDlg
, edt5
), FALSE
);
3275 EnableWindow(GetDlgItem(hDlg
, edt6
), FALSE
);
3276 EnableWindow(GetDlgItem(hDlg
, edt7
), FALSE
);
3278 /* width larger as height -> landscape */
3279 if (pda
->dlga
->ptPaperSize
.x
> pda
->dlga
->ptPaperSize
.y
)
3280 CheckRadioButton(hDlg
, rad1
, rad2
, rad2
);
3281 else /* this is default if papersize is not set */
3282 CheckRadioButton(hDlg
, rad1
, rad2
, rad1
);
3283 if (pda
->dlga
->Flags
& PSD_DISABLEORIENTATION
) {
3284 EnableWindow(GetDlgItem(hDlg
,rad1
),FALSE
);
3285 EnableWindow(GetDlgItem(hDlg
,rad2
),FALSE
);
3287 /* We fill them out enabled or not */
3288 if (pda
->dlga
->Flags
& PSD_MARGINS
) {
3290 _c_size2strW(pda
,pda
->dlga
->rtMargin
.left
,str
);
3291 SetDlgItemTextA(hDlg
,edt4
,str
);
3292 _c_size2strW(pda
,pda
->dlga
->rtMargin
.top
,str
);
3293 SetDlgItemTextA(hDlg
,edt5
,str
);
3294 _c_size2strW(pda
,pda
->dlga
->rtMargin
.right
,str
);
3295 SetDlgItemTextA(hDlg
,edt6
,str
);
3296 _c_size2strW(pda
,pda
->dlga
->rtMargin
.bottom
,str
);
3297 SetDlgItemTextA(hDlg
,edt7
,str
);
3299 /* default is 1 inch */
3300 DWORD size
= _c_inch2size((LPPAGESETUPDLGA
)pda
->dlga
,1000);
3302 _c_size2strW(pda
,size
,str
);
3303 SetDlgItemTextA(hDlg
,edt4
,str
);
3304 SetDlgItemTextA(hDlg
,edt5
,str
);
3305 SetDlgItemTextA(hDlg
,edt6
,str
);
3306 SetDlgItemTextA(hDlg
,edt7
,str
);
3308 PRINTDLG_PS_ChangePrinterW(hDlg
,pda
);
3309 if (pda
->dlga
->Flags
& PSD_DISABLEPAPER
) {
3310 EnableWindow(GetDlgItem(hDlg
,cmb2
),FALSE
);
3311 EnableWindow(GetDlgItem(hDlg
,cmb3
),FALSE
);
3315 pda
= (PageSetupDataW
*)GetPropA(hDlg
,"__WINE_PAGESETUPDLGDATA");
3317 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
3320 if (pda
->dlga
->Flags
& PSD_ENABLEPAGESETUPHOOK
) {
3321 res
= pda
->dlga
->lpfnPageSetupHook(hDlg
,uMsg
,wParam
,lParam
);
3322 if (res
) return res
;
3327 return PRINTDLG_PS_WMCommandW(hDlg
, wParam
, lParam
, pda
);
3332 /***********************************************************************
3333 * PageSetupDlgA (COMDLG32.@)
3335 BOOL WINAPI
PageSetupDlgA(LPPAGESETUPDLGA setupdlg
) {
3339 PageSetupDataA
*pda
;
3342 if(TRACE_ON(commdlg
)) {
3343 char flagstr
[1000] = "";
3344 struct pd_flags
*pflag
= psd_flags
;
3345 for( ; pflag
->name
; pflag
++) {
3346 if(setupdlg
->Flags
& pflag
->flag
) {
3347 strcat(flagstr
, pflag
->name
);
3348 strcat(flagstr
, "|");
3351 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
3352 "hinst %p, flags %08lx (%s)\n",
3353 setupdlg
, setupdlg
->hwndOwner
, setupdlg
->hDevMode
,
3354 setupdlg
->hDevNames
,
3355 setupdlg
->hInstance
, setupdlg
->Flags
, flagstr
);
3358 /* First get default printer data, we need it right after that. */
3359 memset(&pdlg
,0,sizeof(pdlg
));
3360 pdlg
.lStructSize
= sizeof(pdlg
);
3361 pdlg
.Flags
= PD_RETURNDEFAULT
;
3362 bRet
= PrintDlgA(&pdlg
);
3363 if (!bRet
) return FALSE
;
3365 /* short cut exit, just return default values */
3366 if (setupdlg
->Flags
& PSD_RETURNDEFAULT
) {
3367 setupdlg
->hDevMode
= pdlg
.hDevMode
;
3368 setupdlg
->hDevNames
= pdlg
.hDevNames
;
3369 /* FIXME: Just return "A4" for now. */
3370 PRINTDLG_PaperSizeA(&pdlg
,"A4",&setupdlg
->ptPaperSize
);
3371 setupdlg
->ptPaperSize
.x
=_c_10mm2size(setupdlg
,setupdlg
->ptPaperSize
.x
);
3372 setupdlg
->ptPaperSize
.y
=_c_10mm2size(setupdlg
,setupdlg
->ptPaperSize
.y
);
3375 hDlgTmpl
= PRINTDLG_GetPGSTemplateA(setupdlg
);
3377 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
3380 ptr
= LockResource( hDlgTmpl
);
3382 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
3385 pda
= HeapAlloc(GetProcessHeap(),0,sizeof(*pda
));
3386 pda
->dlga
= setupdlg
;
3387 memcpy(&pda
->pdlg
,&pdlg
,sizeof(pdlg
));
3389 bRet
= (0<DialogBoxIndirectParamA(
3390 setupdlg
->hInstance
,
3392 setupdlg
->hwndOwner
,
3398 /***********************************************************************
3399 * PageSetupDlgW (COMDLG32.@)
3401 BOOL WINAPI
PageSetupDlgW(LPPAGESETUPDLGW setupdlg
) {
3405 PageSetupDataW
*pdw
;
3408 if(TRACE_ON(commdlg
)) {
3409 char flagstr
[1000] = "";
3410 struct pd_flags
*pflag
= psd_flags
;
3411 for( ; pflag
->name
; pflag
++) {
3412 if(setupdlg
->Flags
& pflag
->flag
) {
3413 strcat(flagstr
, pflag
->name
);
3414 strcat(flagstr
, "|");
3417 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
3418 "hinst %p, flags %08lx (%s)\n",
3419 setupdlg
, setupdlg
->hwndOwner
, setupdlg
->hDevMode
,
3420 setupdlg
->hDevNames
,
3421 setupdlg
->hInstance
, setupdlg
->Flags
, flagstr
);
3424 /* First get default printer data, we need it right after that. */
3425 memset(&pdlg
,0,sizeof(pdlg
));
3426 pdlg
.lStructSize
= sizeof(pdlg
);
3427 pdlg
.Flags
= PD_RETURNDEFAULT
;
3428 bRet
= PrintDlgW(&pdlg
);
3429 if (!bRet
) return FALSE
;
3431 /* short cut exit, just return default values */
3432 if (setupdlg
->Flags
& PSD_RETURNDEFAULT
) {
3433 const WCHAR a4
[] = {'A','4',0};
3434 setupdlg
->hDevMode
= pdlg
.hDevMode
;
3435 setupdlg
->hDevNames
= pdlg
.hDevNames
;
3436 /* FIXME: Just return "A4" for now. */
3437 PRINTDLG_PaperSizeW(&pdlg
,a4
,&setupdlg
->ptPaperSize
);
3438 setupdlg
->ptPaperSize
.x
=_c_10mm2size((LPPAGESETUPDLGA
)setupdlg
,setupdlg
->ptPaperSize
.x
);
3439 setupdlg
->ptPaperSize
.y
=_c_10mm2size((LPPAGESETUPDLGA
)setupdlg
,setupdlg
->ptPaperSize
.y
);
3442 hDlgTmpl
= PRINTDLG_GetPGSTemplateW(setupdlg
);
3444 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
3447 ptr
= LockResource( hDlgTmpl
);
3449 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
3452 pdw
= HeapAlloc(GetProcessHeap(),0,sizeof(*pdw
));
3453 pdw
->dlga
= setupdlg
;
3454 memcpy(&pdw
->pdlg
,&pdlg
,sizeof(pdlg
));
3456 bRet
= (0<DialogBoxIndirectParamW(
3457 setupdlg
->hInstance
,
3459 setupdlg
->hwndOwner
,
3466 /**********************************************************************
3471 /***********************************************************************
3472 * PrintDlgProc (COMMDLG.21)
3474 BOOL16 CALLBACK
PrintDlgProc16(HWND16 hDlg16
, UINT16 uMsg
, WPARAM16 wParam
,
3477 HWND hDlg
= HWND_32(hDlg16
);
3478 PRINT_PTRA
* PrintStructures
;
3481 if (uMsg
!=WM_INITDIALOG
) {
3482 PrintStructures
= (PRINT_PTRA
*)GetPropA(hDlg
,"__WINE_PRINTDLGDATA");
3483 if (!PrintStructures
)
3486 PrintStructures
= (PRINT_PTRA
*) lParam
;
3487 SetPropA(hDlg
,"__WINE_PRINTDLGDATA",PrintStructures
);
3488 res
= PRINTDLG_WMInitDialog16(hDlg
, wParam
, PrintStructures
);
3490 if(PrintStructures
->dlg
.lpPrintDlg16
->Flags
& PD_ENABLEPRINTHOOK
) {
3491 res
= CallWindowProc16(
3492 (WNDPROC16
)PrintStructures
->dlg
.lpPrintDlg16
->lpfnPrintHook
,
3493 hDlg16
, uMsg
, wParam
, (LPARAM
)PrintStructures
->dlg
.lpPrintDlg16
3499 if(PrintStructures
->dlg
.lpPrintDlg16
->Flags
& PD_ENABLEPRINTHOOK
) {
3500 res
= CallWindowProc16(
3501 (WNDPROC16
)PrintStructures
->dlg
.lpPrintDlg16
->lpfnPrintHook
,
3502 hDlg16
,uMsg
, wParam
, lParam
3504 if(LOWORD(res
)) return res
;
3509 /* We need to map those for the 32bit window procedure, compare
3510 * with 32Ato16 mapper in winproc.c
3512 return PRINTDLG_WMCommandA(
3514 MAKEWPARAM(wParam
,HIWORD(lParam
)),
3520 DestroyIcon(PrintStructures
->hCollateIcon
);
3521 DestroyIcon(PrintStructures
->hNoCollateIcon
);
3522 /* FIXME: don't forget to delete the paper orientation icons here! */
3530 /***********************************************************************
3531 * PrintSetupDlgProc (COMMDLG.22)
3533 BOOL16 CALLBACK
PrintSetupDlgProc16(HWND16 hWnd16
, UINT16 wMsg
, WPARAM16 wParam
,
3536 HWND hWnd
= HWND_32(hWnd16
);
3540 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam
);
3541 ShowWindow(hWnd
, SW_SHOWNORMAL
);
3546 EndDialog(hWnd
, TRUE
);
3549 EndDialog(hWnd
, FALSE
);
3558 /***********************************************************************
3559 * PrintDlgExA (COMDLG32.@)
3561 HRESULT WINAPI
PrintDlgExA(LPVOID lpPrintDlgExA
) /* [???] FIXME: LPPRINTDLGEXA */
3566 /***********************************************************************
3567 * PrintDlgExW (COMDLG32.@)
3569 HRESULT WINAPI
PrintDlgExW(LPVOID lpPrintDlgExW
) /* [???] FIXME: LPPRINTDLGEXW */