ReactOS 0.4.17-dev-966-gf06eace
printdlg.c
Go to the documentation of this file.
1/*
2 * COMMDLG - Print Dialog
3 *
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
6 * Copyright 1999 Klaas van Gend
7 * Copyright 2000 Huw D M Davies
8 * Copyright 2010 Vitaly Perov
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24#include <ctype.h>
25#include <stdlib.h>
26#include <stdarg.h>
27#include <stdio.h>
28#include <string.h>
29#include <assert.h>
30
31#define COBJMACROS
32#include "windef.h"
33#include "winbase.h"
34#include "wingdi.h"
35#include "winuser.h"
36#include "winspool.h"
37#include "winerror.h"
38#include "objbase.h"
39#include "commdlg.h"
40
41#include "wine/debug.h"
42
43#include "dlgs.h"
44#include "cderr.h"
45#include "cdlg.h"
46
48
49/* Yes these constants are the same, but we're just copying win98 */
50#define UPDOWN_ID 0x270f
51#define MAX_COPIES 9999
52
53/* This PRINTDLGA internal structure stores
54 * pointers to several throughout useful structures.
55 */
56
57typedef struct
58{
64 HICON hCollateIcon; /* PrintDlg only */
65 HICON hNoCollateIcon; /* PrintDlg only */
66 HICON hPortraitIcon; /* PrintSetupDlg only */
67 HICON hLandscapeIcon; /* PrintSetupDlg only */
70
71typedef struct
72{
78 HICON hCollateIcon; /* PrintDlg only */
79 HICON hNoCollateIcon; /* PrintDlg only */
80 HICON hPortraitIcon; /* PrintSetupDlg only */
81 HICON hLandscapeIcon; /* PrintSetupDlg only */
84
85/* Debugging info */
87{
90};
91
92static const struct pd_flags psd_flags[] = {
93 {PSD_MINMARGINS,"PSD_MINMARGINS"},
94 {PSD_MARGINS,"PSD_MARGINS"},
95 {PSD_INTHOUSANDTHSOFINCHES,"PSD_INTHOUSANDTHSOFINCHES"},
96 {PSD_INHUNDREDTHSOFMILLIMETERS,"PSD_INHUNDREDTHSOFMILLIMETERS"},
97 {PSD_DISABLEMARGINS,"PSD_DISABLEMARGINS"},
98 {PSD_DISABLEPRINTER,"PSD_DISABLEPRINTER"},
99 {PSD_NOWARNING,"PSD_NOWARNING"},
100 {PSD_DISABLEORIENTATION,"PSD_DISABLEORIENTATION"},
101 {PSD_RETURNDEFAULT,"PSD_RETURNDEFAULT"},
102 {PSD_DISABLEPAPER,"PSD_DISABLEPAPER"},
103 {PSD_SHOWHELP,"PSD_SHOWHELP"},
104 {PSD_ENABLEPAGESETUPHOOK,"PSD_ENABLEPAGESETUPHOOK"},
105 {PSD_ENABLEPAGESETUPTEMPLATE,"PSD_ENABLEPAGESETUPTEMPLATE"},
106 {PSD_ENABLEPAGESETUPTEMPLATEHANDLE,"PSD_ENABLEPAGESETUPTEMPLATEHANDLE"},
107 {PSD_ENABLEPAGEPAINTHOOK,"PSD_ENABLEPAGEPAINTHOOK"},
108 {PSD_DISABLEPAGEPAINTING,"PSD_DISABLEPAGEPAINTING"},
109 {-1, NULL}
110};
111
112static const struct pd_flags pd_flags[] = {
113 {PD_SELECTION, "PD_SELECTION "},
114 {PD_PAGENUMS, "PD_PAGENUMS "},
115 {PD_NOSELECTION, "PD_NOSELECTION "},
116 {PD_NOPAGENUMS, "PD_NOPAGENUMS "},
117 {PD_COLLATE, "PD_COLLATE "},
118 {PD_PRINTTOFILE, "PD_PRINTTOFILE "},
119 {PD_PRINTSETUP, "PD_PRINTSETUP "},
120 {PD_NOWARNING, "PD_NOWARNING "},
121 {PD_RETURNDC, "PD_RETURNDC "},
122 {PD_RETURNIC, "PD_RETURNIC "},
123 {PD_RETURNDEFAULT, "PD_RETURNDEFAULT "},
124 {PD_SHOWHELP, "PD_SHOWHELP "},
125 {PD_ENABLEPRINTHOOK, "PD_ENABLEPRINTHOOK "},
126 {PD_ENABLESETUPHOOK, "PD_ENABLESETUPHOOK "},
127 {PD_ENABLEPRINTTEMPLATE, "PD_ENABLEPRINTTEMPLATE "},
128 {PD_ENABLESETUPTEMPLATE, "PD_ENABLESETUPTEMPLATE "},
129 {PD_ENABLEPRINTTEMPLATEHANDLE, "PD_ENABLEPRINTTEMPLATEHANDLE "},
130 {PD_ENABLESETUPTEMPLATEHANDLE, "PD_ENABLESETUPTEMPLATEHANDLE "},
131 {PD_USEDEVMODECOPIES, "PD_USEDEVMODECOPIES[ANDCOLLATE] "},
132 {PD_DISABLEPRINTTOFILE, "PD_DISABLEPRINTTOFILE "},
133 {PD_HIDEPRINTTOFILE, "PD_HIDEPRINTTOFILE "},
134 {PD_NONETWORKBUTTON, "PD_NONETWORKBUTTON "},
135 {-1, NULL}
136};
137/* address of wndproc for subclassed Static control */
140/* the text of the fake document to render for the Page Setup dialog */
142static const WCHAR printdlg_prop[] = L"__WINE_PRINTDLGDATA";
143static const WCHAR pagesetupdlg_prop[] = L"__WINE_PAGESETUPDLGDATA";
144
145
146/***********************************************************************
147 * get_driver_info [internal]
148 *
149 * get DRIVER_INFO_3W for the current printer handle,
150 * alloc the buffer, when needed
151 */
153{
154 DRIVER_INFO_3W *di3 = NULL;
155 DWORD needed = 0;
156 BOOL res;
157
158 res = GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
160 di3 = malloc(needed);
161 res = GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)di3, needed, &needed);
162 }
163
164 if (res)
165 return di3;
166
167 TRACE("GetPrinterDriverW failed with %lu\n", GetLastError());
168 free(di3);
169 return NULL;
170}
171
173{
174 DRIVER_INFO_3A *di3 = NULL;
175 DWORD needed = 0;
176 BOOL res;
177
178 res = GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
180 di3 = malloc(needed);
181 res = GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)di3, needed, &needed);
182 }
183
184 if (res)
185 return di3;
186
187 TRACE("GetPrinterDriverA failed with %lu\n", GetLastError());
188 free(di3);
189 return NULL;
190}
191
192
193/***********************************************************************
194 * get_printer_info [internal]
195 *
196 * get PRINTER_INFO_2W for the current printer handle,
197 * alloc the buffer, when needed
198 */
200{
201 PRINTER_INFO_2W *pi2 = NULL;
202 DWORD needed = 0;
203 BOOL res;
204
205 res = GetPrinterW(hprn, 2, NULL, 0, &needed);
207 pi2 = malloc(needed);
208 res = GetPrinterW(hprn, 2, (LPBYTE)pi2, needed, &needed);
209 }
210
211 if (res)
212 return pi2;
213
214 TRACE("GetPrinterW failed with %lu\n", GetLastError());
215 free(pi2);
216 return NULL;
217}
218
220{
221 PRINTER_INFO_2A *pi2 = NULL;
222 DWORD needed = 0;
223 BOOL res;
224
225 res = GetPrinterA(hprn, 2, NULL, 0, &needed);
227 pi2 = malloc(needed);
228 res = GetPrinterA(hprn, 2, (LPBYTE)pi2, needed, &needed);
229 }
230
231 if (res)
232 return pi2;
233
234 TRACE("GetPrinterA failed with %lu\n", GetLastError());
235 free(pi2);
236 return NULL;
237}
238
239
240/***********************************************************************
241 * update_devmode_handle [internal]
242 *
243 * update a devmode handle for the given DEVMODE, alloc the buffer, when needed
244 */
246{
247 SIZE_T size = GlobalSize(hdm);
248 LPVOID ptr;
249
250 /* Increase / alloc the global memory block, when needed */
251 if ((dm->dmSize + dm->dmDriverExtra) > size) {
252 if (hdm)
253 hdm = GlobalReAlloc(hdm, dm->dmSize + dm->dmDriverExtra, GMEM_MOVEABLE);
254 else
256 }
257
258 if (hdm) {
259 ptr = GlobalLock(hdm);
260 if (ptr) {
261 memcpy(ptr, dm, dm->dmSize + dm->dmDriverExtra);
262 GlobalUnlock(hdm);
263 }
264 else
265 {
266 GlobalFree(hdm);
267 hdm = NULL;
268 }
269 }
270 return hdm;
271}
272
274{
275 SIZE_T size = GlobalSize(hdm);
276 LPVOID ptr;
277
278 /* Increase / alloc the global memory block, when needed */
279 if ((dm->dmSize + dm->dmDriverExtra) > size) {
280 if (hdm)
281 hdm = GlobalReAlloc(hdm, dm->dmSize + dm->dmDriverExtra, GMEM_MOVEABLE);
282 else
284 }
285
286 if (hdm) {
287 ptr = GlobalLock(hdm);
288 if (ptr) {
289 memcpy(ptr, dm, dm->dmSize + dm->dmDriverExtra);
290 GlobalUnlock(hdm);
291 }
292 else
293 {
294 GlobalFree(hdm);
295 hdm = NULL;
296 }
297 }
298 return hdm;
299}
300
301/***********************************************************
302 * convert_to_devmodeA
303 *
304 * Creates an ansi copy of supplied devmode
305 */
307{
308 DEVMODEA *dmA;
309 DWORD size;
310
311 if (!dmW) return NULL;
312 size = dmW->dmSize - CCHDEVICENAME -
313 ((dmW->dmSize > FIELD_OFFSET(DEVMODEW, dmFormName)) ? CCHFORMNAME : 0);
314
315 dmA = malloc(size + dmW->dmDriverExtra);
316 if (!dmA) return NULL;
317
320
321 if (FIELD_OFFSET(DEVMODEW, dmFormName) >= dmW->dmSize)
322 {
324 dmW->dmSize - FIELD_OFFSET(DEVMODEW, dmSpecVersion));
325 }
326 else
327 {
329 FIELD_OFFSET(DEVMODEW, dmFormName) - FIELD_OFFSET(DEVMODEW, dmSpecVersion));
332
333 memcpy(&dmA->dmLogPixels, &dmW->dmLogPixels, dmW->dmSize - FIELD_OFFSET(DEVMODEW, dmLogPixels));
334 }
335
336 dmA->dmSize = size;
337 memcpy((char *)dmA + dmA->dmSize, (const char *)dmW + dmW->dmSize, dmW->dmDriverExtra);
338 return dmA;
339}
340
341/***********************************************************************
342 * PRINTDLG_OpenDefaultPrinter
343 *
344 * Returns a winspool printer handle to the default printer in *hprn
345 * Caller must call ClosePrinter on the handle
346 *
347 * Returns TRUE on success else FALSE
348 */
350{
351 WCHAR buf[260];
352 DWORD dwBufLen = ARRAY_SIZE(buf);
353 BOOL res;
354 if(!GetDefaultPrinterW(buf, &dwBufLen))
355 return FALSE;
356 res = OpenPrinterW(buf, hprn, NULL);
357 if (!res)
358 WARN("Could not open printer %s\n", debugstr_w(buf));
359 return res;
360}
361
362/***********************************************************************
363 * PRINTDLG_SetUpPrinterListCombo
364 *
365 * Initializes printer list combox.
366 * hDlg: HWND of dialog
367 * id: Control id of combo
368 * name: Name of printer to select
369 *
370 * Initializes combo with list of available printers. Selects printer 'name'
371 * If name is NULL or does not exist select the default printer.
372 *
373 * Returns number of printers added to list.
374 */
376{
377 DWORD needed, num;
378 INT i;
380 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
381 pi = malloc(needed);
382 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed,
383 &num);
384
385 SendDlgItemMessageA(hDlg, id, CB_RESETCONTENT, 0, 0);
386
387 for(i = 0; i < num; i++) {
389 (LPARAM)pi[i].pPrinterName );
390 }
391 free(pi);
392 if(!name ||
394 (LPARAM)name)) == CB_ERR) {
395
396 char buf[260];
397 DWORD dwBufLen = ARRAY_SIZE(buf);
398 if (name != NULL)
399 WARN("Can't find %s in printer list so trying to find default\n",
401 if(!GetDefaultPrinterA(buf, &dwBufLen))
402 return num;
404 if(i == CB_ERR)
405 FIXME("Can't find default printer in printer list\n");
406 }
407 SendDlgItemMessageA(hDlg, id, CB_SETCURSEL, i, 0);
408 return num;
409}
410
412{
413 DWORD needed, num;
414 INT i;
416 EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
417 pi = malloc(needed);
418 EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed,
419 &num);
420
421 for(i = 0; i < num; i++) {
423 (LPARAM)pi[i].pPrinterName );
424 }
425 free(pi);
426 if(!name ||
428 (LPARAM)name)) == CB_ERR) {
429 WCHAR buf[260];
430 DWORD dwBufLen = ARRAY_SIZE(buf);
431 if (name != NULL)
432 WARN("Can't find %s in printer list so trying to find default\n",
434 if(!GetDefaultPrinterW(buf, &dwBufLen))
435 return num;
437 if(i == CB_ERR)
438 TRACE("Can't find default printer in printer list\n");
439 }
440 SendDlgItemMessageW(hDlg, id, CB_SETCURSEL, i, 0);
441 return num;
442}
443
444#ifdef __REACTOS__
445static const CHAR cDriverName[] = "winspool";
446static const WCHAR wDriverName[] = L"winspool";
447#endif
448
449/***********************************************************************
450 * PRINTDLG_CreateDevNames [internal]
451 *
452 *
453 * creates a DevNames structure.
454 *
455 * (NB. when we handle unicode the offsets will be in wchars).
456 */
457static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, const char* DeviceDriverName,
458 const char* DeviceName, const char* OutputPort)
459{
460 long size;
461 char* pDevNamesSpace;
462 char* pTempPtr;
463 LPDEVNAMES lpDevNames;
464 char buf[260];
465 DWORD dwBufLen = ARRAY_SIZE(buf);
466 const char *p;
467
468 p = strrchr( DeviceDriverName, '\\' );
469 if (p) DeviceDriverName = p + 1;
470#ifndef __REACTOS__
471 size = strlen(DeviceDriverName) + 1
472#else
473 size = strlen(cDriverName) + 1
474#endif
475 + strlen(DeviceName) + 1
476 + strlen(OutputPort) + 1
477 + sizeof(DEVNAMES);
478
479 if(*hmem)
480 *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
481 else
483 if (*hmem == 0)
484 return FALSE;
485
486 pDevNamesSpace = GlobalLock(*hmem);
487 lpDevNames = (LPDEVNAMES) pDevNamesSpace;
488
489 pTempPtr = pDevNamesSpace + sizeof(DEVNAMES);
490#ifndef __REACTOS__
491 strcpy(pTempPtr, DeviceDriverName);
492#else
493 strcpy(pTempPtr, cDriverName);
494#endif
495 lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace;
496
497 pTempPtr += strlen(DeviceDriverName) + 1;
498 strcpy(pTempPtr, DeviceName);
499 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
500
501 pTempPtr += strlen(DeviceName) + 1;
502 strcpy(pTempPtr, OutputPort);
503 lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
504
505 GetDefaultPrinterA(buf, &dwBufLen);
506 lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0;
507 GlobalUnlock(*hmem);
508 return TRUE;
509}
510
511static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName,
512 LPCWSTR DeviceName, LPCWSTR OutputPort)
513{
514 long size;
515 LPWSTR pDevNamesSpace;
516 LPWSTR pTempPtr;
517 LPDEVNAMES lpDevNames;
518 WCHAR bufW[260];
519 DWORD dwBufLen = ARRAY_SIZE(bufW);
520 const WCHAR *p;
521
522 p = wcsrchr( DeviceDriverName, '\\' );
523 if (p) DeviceDriverName = p + 1;
524#ifndef __REACTOS__
525 size = sizeof(WCHAR)*lstrlenW(DeviceDriverName) + 2
526#else
527 size = sizeof(WCHAR)*lstrlenW(wDriverName) + 2
528#endif
529 + sizeof(WCHAR)*lstrlenW(DeviceName) + 2
530 + sizeof(WCHAR)*lstrlenW(OutputPort) + 2
531 + sizeof(DEVNAMES);
532
533 if(*hmem)
534 *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
535 else
537 if (*hmem == 0)
538 return FALSE;
539
540 pDevNamesSpace = GlobalLock(*hmem);
541 lpDevNames = (LPDEVNAMES) pDevNamesSpace;
542
543 pTempPtr = (LPWSTR)((LPDEVNAMES)pDevNamesSpace + 1);
544#ifndef __REACTOS__
545 lstrcpyW(pTempPtr, DeviceDriverName);
546#else
547 lstrcpyW(pTempPtr, wDriverName);
548#endif
549 lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace;
550
551 pTempPtr += lstrlenW(DeviceDriverName) + 1;
552 lstrcpyW(pTempPtr, DeviceName);
553 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
554
555 pTempPtr += lstrlenW(DeviceName) + 1;
556 lstrcpyW(pTempPtr, OutputPort);
557 lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
558
559 GetDefaultPrinterW(bufW, &dwBufLen);
560 lpDevNames->wDefault = (lstrcmpW(bufW, DeviceName) == 0) ? 1 : 0;
561 GlobalUnlock(*hmem);
562 return TRUE;
563}
564
565/***********************************************************************
566 * PRINTDLG_UpdatePrintDlg [internal]
567 *
568 *
569 * updates the PrintDlg structure for return values.
570 *
571 * RETURNS
572 * FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
573 * TRUE if successful.
574 */
576 PRINT_PTRA* PrintStructures)
577{
578 LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
579 PDEVMODEA lpdm = PrintStructures->lpDevMode;
580 LPPRINTER_INFO_2A pi = PrintStructures->lpPrinterInfo;
581
582
583 if(!lpdm) {
584 FIXME("No lpdm ptr?\n");
585 return FALSE;
586 }
587
588
589 if(!(lppd->Flags & PD_PRINTSETUP)) {
590 /* check whether nFromPage and nToPage are within range defined by
591 * nMinPage and nMaxPage
592 */
593 if (IsDlgButtonChecked(hDlg, rad3) == BST_CHECKED) { /* Pages */
594 WORD nToPage;
595 WORD nFromPage;
596 BOOL translated;
597 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
598 nToPage = GetDlgItemInt(hDlg, edt2, &translated, FALSE);
599
600 /* if no ToPage value is entered, use the FromPage value */
601 if(!translated) nToPage = nFromPage;
602
603 if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
604 nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
605 WCHAR resourcestr[256];
606 WCHAR resultstr[256];
608 wsprintfW(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);
610 MessageBoxW(hDlg, resultstr, resourcestr, MB_OK | MB_ICONWARNING);
611 return FALSE;
612 }
613 lppd->nFromPage = nFromPage;
614 lppd->nToPage = nToPage;
615 lppd->Flags |= PD_PAGENUMS;
616 }
617 else
618 lppd->Flags &= ~PD_PAGENUMS;
619
620 if (IsDlgButtonChecked(hDlg, rad2) == BST_CHECKED) /* Selection */
621 lppd->Flags |= PD_SELECTION;
622 else
623 lppd->Flags &= ~PD_SELECTION;
624
625 if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
626 static char file[] = "FILE:";
627 lppd->Flags |= PD_PRINTTOFILE;
628 pi->pPortName = file;
629 }
630
631 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */
632 FIXME("Collate lppd not yet implemented as output\n");
633 }
634
635 /* set PD_Collate and nCopies */
637 /* The application doesn't support multiple copies or collate...
638 */
639 lppd->Flags &= ~PD_COLLATE;
640 lppd->nCopies = 1;
641 /* if the printer driver supports it... store info there
642 * otherwise no collate & multiple copies !
643 */
644 if (lpdm->dmFields & DM_COLLATE)
645 lpdm->dmCollate =
647 if (lpdm->dmFields & DM_COPIES)
648 lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
649 } else {
650 /* Application is responsible for multiple copies */
651 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
652 lppd->Flags |= PD_COLLATE;
653 else
654 lppd->Flags &= ~PD_COLLATE;
655 lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
656 /* multiple copies already included in the document. Driver must print only one copy */
657 lpdm->dmCopies = 1;
658 }
659
660 /* Print quality, PrintDlg16 */
661 if(GetDlgItem(hDlg, cmb1))
662 {
663 HWND hQuality = GetDlgItem(hDlg, cmb1);
664 int Sel = SendMessageA(hQuality, CB_GETCURSEL, 0, 0);
665
666 if(Sel != CB_ERR)
667 {
668 LONG dpi = SendMessageA(hQuality, CB_GETITEMDATA, Sel, 0);
670 lpdm->dmPrintQuality = LOWORD(dpi);
671 lpdm->dmYResolution = HIWORD(dpi);
672 }
673 }
674 }
675 return TRUE;
676}
677
679 PRINT_PTRW* PrintStructures)
680{
681 LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
682 PDEVMODEW lpdm = PrintStructures->lpDevMode;
683 LPPRINTER_INFO_2W pi = PrintStructures->lpPrinterInfo;
684
685
686 if(!lpdm) {
687 FIXME("No lpdm ptr?\n");
688 return FALSE;
689 }
690
691
692 if(!(lppd->Flags & PD_PRINTSETUP)) {
693 /* check whether nFromPage and nToPage are within range defined by
694 * nMinPage and nMaxPage
695 */
696 if (IsDlgButtonChecked(hDlg, rad3) == BST_CHECKED) { /* Pages */
697 WORD nToPage;
698 WORD nFromPage;
699 BOOL translated;
700 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
701 nToPage = GetDlgItemInt(hDlg, edt2, &translated, FALSE);
702
703 /* if no ToPage value is entered, use the FromPage value */
704 if(!translated) nToPage = nFromPage;
705
706 if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||
707 nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {
708 WCHAR resourcestr[256];
709 WCHAR resultstr[256];
710 DWORD_PTR args[2];
712 resourcestr, 255);
713 args[0] = lppd->nMinPage;
714 args[1] = lppd->nMaxPage;
716 resourcestr, 0, 0, resultstr, ARRAY_SIZE(resultstr), (va_list *)args);
718 resourcestr, 255);
719 MessageBoxW(hDlg, resultstr, resourcestr,
721 return FALSE;
722 }
723 lppd->nFromPage = nFromPage;
724 lppd->nToPage = nToPage;
725 lppd->Flags |= PD_PAGENUMS;
726 }
727 else
728 lppd->Flags &= ~PD_PAGENUMS;
729
730 if (IsDlgButtonChecked(hDlg, rad2) == BST_CHECKED) /* Selection */
731 lppd->Flags |= PD_SELECTION;
732 else
733 lppd->Flags &= ~PD_SELECTION;
734
735 if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */
736 static WCHAR file[] = L"FILE:";
737 lppd->Flags |= PD_PRINTTOFILE;
738 pi->pPortName = file;
739 }
740
741 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */
742 FIXME("Collate lppd not yet implemented as output\n");
743 }
744
745 /* set PD_Collate and nCopies */
747 /* The application doesn't support multiple copies or collate...
748 */
749 lppd->Flags &= ~PD_COLLATE;
750 lppd->nCopies = 1;
751 /* if the printer driver supports it... store info there
752 * otherwise no collate & multiple copies !
753 */
754 if (lpdm->dmFields & DM_COLLATE)
755 lpdm->dmCollate =
757 if (lpdm->dmFields & DM_COPIES)
758 lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
759 } else {
760 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
761 lppd->Flags |= PD_COLLATE;
762 else
763 lppd->Flags &= ~PD_COLLATE;
764 lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
765 }
766 }
767 return TRUE;
768}
769
770/************************************************************************
771 * PRINTDLG_SetUpPaperComboBox
772 *
773 * Initialize either the papersize or inputslot combos of the Printer Setup
774 * dialog. We store the associated word (eg DMPAPER_A4) as the item data.
775 * We also try to re-select the old selection.
776 */
778 int nIDComboBox,
779 char* PrinterName,
780 char* PortName,
781 LPDEVMODEA dm)
782{
783 int i;
784 int NrOfEntries;
785 char* Names;
786 WORD* Words;
787 DWORD Sel, old_Sel;
788 WORD oldWord = 0, newWord = 0; /* DMPAPER_ and DMBIN_ start at 1 */
789 int NamesSize;
790 int fwCapability_Names;
791 int fwCapability_Words;
792
793 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",PrinterName,PortName,nIDComboBox);
794
795 /* query the dialog box for the current selected value */
796 Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
797 if(Sel != CB_ERR) {
798 /* we enter here only if a different printer is selected after
799 * the Print Setup dialog is opened. The current settings are
800 * stored into the newly selected printer.
801 */
802 oldWord = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA,
803 Sel, 0);
804 if(oldWord >= DMPAPER_USER) /* DMPAPER_USER == DMBIN_USER */
805 oldWord = 0; /* There's no point in trying to keep custom
806 paper / bin sizes across printers */
807 }
808
809 if (dm)
810 newWord = (nIDComboBox == cmb2) ? dm->dmPaperSize : dm->dmDefaultSource;
811
812 if (nIDComboBox == cmb2) {
813 NamesSize = 64;
814 fwCapability_Names = DC_PAPERNAMES;
815 fwCapability_Words = DC_PAPERS;
816 } else {
817 nIDComboBox = cmb3;
818 NamesSize = 24;
819 fwCapability_Names = DC_BINNAMES;
820 fwCapability_Words = DC_BINS;
821 }
822
823 NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
824 fwCapability_Names, NULL, dm);
825 if (NrOfEntries == 0)
826 WARN("no Name Entries found!\n");
827 else if (NrOfEntries < 0)
828 return FALSE;
829
830 if(DeviceCapabilitiesA(PrinterName, PortName, fwCapability_Words, NULL, dm)
831 != NrOfEntries) {
832 ERR("Number of caps is different\n");
833 NrOfEntries = 0;
834 }
835
836 Names = malloc(NrOfEntries * sizeof(char) * NamesSize);
837 Words = malloc(NrOfEntries * sizeof(WORD));
838 DeviceCapabilitiesA(PrinterName, PortName, fwCapability_Names, Names, dm);
839 NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
840 fwCapability_Words, (LPSTR)Words, dm);
841
842 /* reset any current content in the combobox */
843 SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
844
845 /* store new content */
846 for (i = 0; i < NrOfEntries; i++) {
847 DWORD pos = SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0,
848 (LPARAM)(&Names[i*NamesSize]) );
849 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos,
850 Words[i]);
851 }
852
853 /* Look for old selection or the new default.
854 Can't do this is previous loop since item order will change as more items are added */
855 Sel = 0;
856 old_Sel = NrOfEntries;
857 for (i = 0; i < NrOfEntries; i++) {
858 if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
859 oldWord) {
860 old_Sel = i;
861 break;
862 }
863 if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == newWord)
864 Sel = i;
865 }
866
867 if(old_Sel < NrOfEntries)
868 {
869 if (dm)
870 {
871 if(nIDComboBox == cmb2)
872 dm->dmPaperSize = oldWord;
873 else
874 dm->dmDefaultSource = oldWord;
875 }
876 Sel = old_Sel;
877 }
878
879 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
880
881 free(Words);
882 free(Names);
883 return TRUE;
884}
885
887 int nIDComboBox,
888 const WCHAR* PrinterName,
889 const WCHAR* PortName,
890 LPDEVMODEW dm)
891{
892 int i;
893 int NrOfEntries;
894 WCHAR* Names;
895 WORD* Words;
896 DWORD Sel, old_Sel;
897 WORD oldWord = 0, newWord = 0; /* DMPAPER_ and DMBIN_ start at 1 */
898 int NamesSize;
899 int fwCapability_Names;
900 int fwCapability_Words;
901
902 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",debugstr_w(PrinterName),debugstr_w(PortName),nIDComboBox);
903
904 /* query the dialog box for the current selected value */
905 Sel = SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
906 if(Sel != CB_ERR) {
907 /* we enter here only if a different printer is selected after
908 * the Print Setup dialog is opened. The current settings are
909 * stored into the newly selected printer.
910 */
911 oldWord = SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA,
912 Sel, 0);
913
914 if(oldWord >= DMPAPER_USER) /* DMPAPER_USER == DMBIN_USER */
915 oldWord = 0; /* There's no point in trying to keep custom
916 paper / bin sizes across printers */
917 }
918
919 if (dm)
920 newWord = (nIDComboBox == cmb2) ? dm->dmPaperSize : dm->dmDefaultSource;
921
922 if (nIDComboBox == cmb2) {
923 NamesSize = 64;
924 fwCapability_Names = DC_PAPERNAMES;
925 fwCapability_Words = DC_PAPERS;
926 } else {
927 nIDComboBox = cmb3;
928 NamesSize = 24;
929 fwCapability_Names = DC_BINNAMES;
930 fwCapability_Words = DC_BINS;
931 }
932
933 NrOfEntries = DeviceCapabilitiesW(PrinterName, PortName,
934 fwCapability_Names, NULL, dm);
935 if (NrOfEntries == 0)
936 WARN("no Name Entries found!\n");
937 else if (NrOfEntries < 0)
938 return FALSE;
939
940 if(DeviceCapabilitiesW(PrinterName, PortName, fwCapability_Words, NULL, dm)
941 != NrOfEntries) {
942 ERR("Number of caps is different\n");
943 NrOfEntries = 0;
944 }
945
946 Names = malloc(NrOfEntries * sizeof(WCHAR) * NamesSize);
947 Words = malloc(NrOfEntries * sizeof(WORD));
948 DeviceCapabilitiesW(PrinterName, PortName, fwCapability_Names, Names, dm);
949 NrOfEntries = DeviceCapabilitiesW(PrinterName, PortName,
950 fwCapability_Words, Words, dm);
951
952 /* reset any current content in the combobox */
953 SendDlgItemMessageW(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
954
955 /* store new content */
956 for (i = 0; i < NrOfEntries; i++) {
957 DWORD pos = SendDlgItemMessageW(hDlg, nIDComboBox, CB_ADDSTRING, 0,
958 (LPARAM)(&Names[i*NamesSize]) );
959 SendDlgItemMessageW(hDlg, nIDComboBox, CB_SETITEMDATA, pos,
960 Words[i]);
961 }
962
963 /* Look for old selection or the new default.
964 Can't do this is previous loop since item order will change as more items are added */
965 Sel = 0;
966 old_Sel = NrOfEntries;
967 for (i = 0; i < NrOfEntries; i++) {
968 if(SendDlgItemMessageW(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
969 oldWord) {
970 old_Sel = i;
971 break;
972 }
973 if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == newWord)
974 Sel = i;
975 }
976
977 if(old_Sel < NrOfEntries)
978 {
979 if (dm)
980 {
981 if(nIDComboBox == cmb2)
982 dm->dmPaperSize = oldWord;
983 else
984 dm->dmDefaultSource = oldWord;
985 }
986 Sel = old_Sel;
987 }
988
989 SendDlgItemMessageW(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
990
991 free(Words);
992 free(Names);
993 return TRUE;
994}
995
996
997/***********************************************************************
998 * PRINTDLG_UpdatePrinterInfoTexts [internal]
999 */
1001{
1002 char StatusMsg[256];
1003 char ResourceString[256];
1004 char printer_name[256];
1005 int i;
1006
1007 /* Status Message */
1008 StatusMsg[0]='\0';
1009
1010 /* add all status messages */
1011 for (i = 0; i < 25; i++) {
1012 if (pi->Status & (1<<i)) {
1014 ResourceString, 255);
1015 strcat(StatusMsg,ResourceString);
1016 }
1017 }
1018 /* append "ready" */
1019 /* FIXME: status==ready must only be appended if really so.
1020 but how to detect? */
1022 ResourceString, 255);
1023 strcat(StatusMsg,ResourceString);
1024 SetDlgItemTextA(hDlg, stc12, StatusMsg);
1025
1026 /* set all other printer info texts */
1027 if (flags & PD_PRINTSETUP)
1028 {
1029 DWORD dwBufLen = ARRAY_SIZE(printer_name);
1030 GetDefaultPrinterA(printer_name, &dwBufLen);
1031 }
1032 else
1033 {
1034 /* FIXME: Windows decorates the printer name with text like 'System Printer' or 'on <port>'. */
1035 lstrcpynA(printer_name, pi->pPrinterName, ARRAY_SIZE(printer_name));
1036 }
1037 SetDlgItemTextA(hDlg, stc1, printer_name);
1038 SetDlgItemTextA(hDlg, stc11, pi->pDriverName);
1039
1040 if (pi->pLocation != NULL && pi->pLocation[0] != '\0')
1041 SetDlgItemTextA(hDlg, stc14, pi->pLocation);
1042 else
1043 SetDlgItemTextA(hDlg, stc14, pi->pPortName);
1044 SetDlgItemTextA(hDlg, stc13, pi->pComment ? pi->pComment : "");
1045 return;
1046}
1047
1049{
1050 WCHAR StatusMsg[256];
1051 WCHAR ResourceString[256];
1052 WCHAR printer_name[256];
1053 int i;
1054
1055 /* Status Message */
1056 StatusMsg[0]='\0';
1057
1058 /* add all status messages */
1059 for (i = 0; i < 25; i++) {
1060 if (pi->Status & (1<<i)) {
1062 ResourceString, 255);
1063 lstrcatW(StatusMsg,ResourceString);
1064 }
1065 }
1066 /* append "ready" */
1067 /* FIXME: status==ready must only be appended if really so.
1068 but how to detect? */
1070 ResourceString, 255);
1071 lstrcatW(StatusMsg,ResourceString);
1072 SetDlgItemTextW(hDlg, stc12, StatusMsg);
1073
1074 /* set all other printer info texts */
1075 if (flags & PD_PRINTSETUP)
1076 {
1077 DWORD dwBufLen = ARRAY_SIZE(printer_name);
1078 GetDefaultPrinterW(printer_name, &dwBufLen);
1079 }
1080 else
1081 {
1082 /* FIXME: Windows decorates the printer name with text like 'System Printer' or 'on <port>'. */
1083 lstrcpynW(printer_name, pi->pPrinterName, ARRAY_SIZE(printer_name));
1084 }
1085 SetDlgItemTextW(hDlg, stc1, printer_name);
1086 SetDlgItemTextW(hDlg, stc11, pi->pDriverName);
1087 if (pi->pLocation != NULL && pi->pLocation[0] != '\0')
1088 SetDlgItemTextW(hDlg, stc14, pi->pLocation);
1089 else
1090 SetDlgItemTextW(hDlg, stc14, pi->pPortName);
1091 SetDlgItemTextW(hDlg, stc13, pi->pComment ? pi->pComment : L"");
1092}
1093
1094
1095/*******************************************************************
1096 *
1097 * PRINTDLG_ChangePrinter
1098 *
1099 */
1100static BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, PRINT_PTRA *PrintStructures)
1101{
1102 LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
1103 LPDEVMODEA lpdm = NULL;
1104 LONG dmSize;
1105 DWORD needed;
1106 HANDLE hprn;
1107
1108 free(PrintStructures->lpPrinterInfo);
1109 free(PrintStructures->lpDriverInfo);
1110 if(!OpenPrinterA(name, &hprn, NULL)) {
1111 ERR("Can't open printer %s\n", name);
1112 return FALSE;
1113 }
1114 GetPrinterA(hprn, 2, NULL, 0, &needed);
1115 PrintStructures->lpPrinterInfo = malloc(needed);
1116 GetPrinterA(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
1117 &needed);
1118 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
1119 PrintStructures->lpDriverInfo = malloc(needed);
1120 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo,
1121 needed, &needed)) {
1122 ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName);
1123 return FALSE;
1124 }
1125 ClosePrinter(hprn);
1126
1127 PRINTDLG_UpdatePrinterInfoTextsA(hDlg, lppd->Flags, PrintStructures->lpPrinterInfo);
1128
1129 free(PrintStructures->lpDevMode);
1130 PrintStructures->lpDevMode = NULL;
1131
1132 dmSize = DocumentPropertiesA(0, 0, name, NULL, NULL, 0);
1133 if(dmSize == -1) {
1134 ERR("DocumentProperties fails on %s\n", debugstr_a(name));
1135 return FALSE;
1136 }
1137 PrintStructures->lpDevMode = malloc(dmSize);
1138 dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL,
1140 if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
1141 !lstrcmpA( (LPSTR) lpdm->dmDeviceName,
1142 (LPSTR) PrintStructures->lpDevMode->dmDeviceName)) {
1143 /* Supplied devicemode matches current printer so try to use it */
1144 DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm,
1146 }
1147 if(lpdm)
1148 GlobalUnlock(lppd->hDevMode);
1149
1150 lpdm = PrintStructures->lpDevMode; /* use this as a shortcut */
1151
1152 if(!(lppd->Flags & PD_PRINTSETUP)) {
1153 /* Print range (All/Range/Selection) */
1154 if(lppd->nFromPage != 0xffff)
1155 SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
1156 if(lppd->nToPage != 0xffff)
1157 SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
1158
1159 CheckRadioButton(hDlg, rad1, rad3, rad1); /* default */
1160 if (lppd->Flags & PD_NOSELECTION)
1162 else
1163 if (lppd->Flags & PD_SELECTION)
1164 CheckRadioButton(hDlg, rad1, rad3, rad2);
1165 if (lppd->Flags & PD_NOPAGENUMS) {
1171 } else {
1172 if (lppd->Flags & PD_PAGENUMS)
1173 CheckRadioButton(hDlg, rad1, rad3, rad3);
1174 }
1175
1176 /* Collate pages
1177 *
1178 * FIXME: The ico3 is not displayed for some reason. I don't know why.
1179 */
1180 if (lppd->Flags & PD_COLLATE) {
1182 (LPARAM)PrintStructures->hCollateIcon);
1183 CheckDlgButton(hDlg, chx2, 1);
1184 } else {
1186 (LPARAM)PrintStructures->hNoCollateIcon);
1187 CheckDlgButton(hDlg, chx2, 0);
1188 }
1189
1191 /* if printer doesn't support it: no Collate */
1192 if (!(lpdm->dmFields & DM_COLLATE)) {
1195 }
1196 }
1197
1198 /* nCopies */
1199 {
1200 INT copies;
1201 if (lppd->hDevMode == 0)
1202 copies = lppd->nCopies;
1203 else
1204 copies = lpdm->dmCopies;
1205 if(copies == 0) copies = 1;
1206 else if(copies < 0) copies = MAX_COPIES;
1207 SetDlgItemInt(hDlg, edt3, copies, FALSE);
1208 }
1209
1211 /* if printer doesn't support it: no nCopies */
1212 if (!(lpdm->dmFields & DM_COPIES)) {
1215 }
1216 }
1217
1218 /* print to file */
1219 CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
1220 if (lppd->Flags & PD_DISABLEPRINTTOFILE)
1222 if (lppd->Flags & PD_HIDEPRINTTOFILE)
1224
1225 /* Fill print quality combo, PrintDlg16 */
1226 if(GetDlgItem(hDlg, cmb1))
1227 {
1228 DWORD numResolutions = DeviceCapabilitiesA(PrintStructures->lpPrinterInfo->pPrinterName,
1229 PrintStructures->lpPrinterInfo->pPortName,
1230 DC_ENUMRESOLUTIONS, NULL, lpdm);
1231
1232 if(numResolutions != -1)
1233 {
1234 HWND hQuality = GetDlgItem(hDlg, cmb1);
1235 LONG* Resolutions;
1236 char buf[255];
1237 DWORD i;
1238 int dpiX, dpiY;
1239 HDC hPrinterDC = CreateDCA(PrintStructures->lpPrinterInfo->pDriverName,
1240 PrintStructures->lpPrinterInfo->pPrinterName,
1241 0, lpdm);
1242
1243 Resolutions = malloc(numResolutions * sizeof(LONG) * 2);
1245 PrintStructures->lpPrinterInfo->pPortName,
1246 DC_ENUMRESOLUTIONS, (LPSTR)Resolutions, lpdm);
1247
1248 dpiX = GetDeviceCaps(hPrinterDC, LOGPIXELSX);
1249 dpiY = GetDeviceCaps(hPrinterDC, LOGPIXELSY);
1250 DeleteDC(hPrinterDC);
1251
1252 SendMessageA(hQuality, CB_RESETCONTENT, 0, 0);
1253 for(i = 0; i < (numResolutions * 2); i += 2)
1254 {
1255 BOOL IsDefault = FALSE;
1256 LRESULT Index;
1257
1258 if(Resolutions[i] == Resolutions[i+1])
1259 {
1260 if(dpiX == Resolutions[i])
1261 IsDefault = TRUE;
1262 sprintf(buf, "%ld dpi", Resolutions[i]);
1263 } else
1264 {
1265 if(dpiX == Resolutions[i] && dpiY == Resolutions[i+1])
1266 IsDefault = TRUE;
1267 sprintf(buf, "%ld dpi x %ld dpi", Resolutions[i], Resolutions[i+1]);
1268 }
1269
1270 Index = SendMessageA(hQuality, CB_ADDSTRING, 0, (LPARAM)buf);
1271
1272 if(IsDefault)
1273 SendMessageA(hQuality, CB_SETCURSEL, Index, 0);
1274
1275 SendMessageA(hQuality, CB_SETITEMDATA, Index, MAKELONG(Resolutions[i], Resolutions[i+1]));
1276 }
1277 free(Resolutions);
1278 }
1279 }
1280 } else { /* PD_PRINTSETUP */
1281 BOOL bPortrait = (lpdm->dmOrientation == DMORIENT_PORTRAIT);
1282
1284 PrintStructures->lpPrinterInfo->pPrinterName,
1285 PrintStructures->lpPrinterInfo->pPortName,
1286 lpdm);
1288 PrintStructures->lpPrinterInfo->pPrinterName,
1289 PrintStructures->lpPrinterInfo->pPortName,
1290 lpdm);
1291 CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
1293 (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
1294 PrintStructures->hLandscapeIcon));
1295
1296 }
1297
1298 /* help button */
1299 if ((lppd->Flags & PD_SHOWHELP)==0) {
1300 /* hide if PD_SHOWHELP not specified */
1302 }
1303 return TRUE;
1304}
1305
1307 PRINT_PTRW *PrintStructures)
1308{
1309 LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
1310 LPDEVMODEW lpdm = NULL;
1311 LONG dmSize;
1312 DWORD needed;
1313 HANDLE hprn;
1314
1315 free(PrintStructures->lpPrinterInfo);
1316 free(PrintStructures->lpDriverInfo);
1317 if(!OpenPrinterW(name, &hprn, NULL)) {
1318 ERR("Can't open printer %s\n", debugstr_w(name));
1319 return FALSE;
1320 }
1321 GetPrinterW(hprn, 2, NULL, 0, &needed);
1322 PrintStructures->lpPrinterInfo = malloc(needed);
1323 GetPrinterW(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
1324 &needed);
1325 GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
1326 PrintStructures->lpDriverInfo = malloc(needed);
1327 if (!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo,
1328 needed, &needed)) {
1329 ERR("GetPrinterDriverA failed for %s, fix your config!\n",debugstr_w(PrintStructures->lpPrinterInfo->pPrinterName));
1330 return FALSE;
1331 }
1332 ClosePrinter(hprn);
1333
1334 PRINTDLG_UpdatePrinterInfoTextsW(hDlg, lppd->Flags, PrintStructures->lpPrinterInfo);
1335
1336 free(PrintStructures->lpDevMode);
1337 PrintStructures->lpDevMode = NULL;
1338
1339 dmSize = DocumentPropertiesW(0, 0, name, NULL, NULL, 0);
1340 if(dmSize == -1) {
1341 ERR("DocumentProperties fails on %s\n", debugstr_w(name));
1342 return FALSE;
1343 }
1344 PrintStructures->lpDevMode = malloc(dmSize);
1345 dmSize = DocumentPropertiesW(0, 0, name, PrintStructures->lpDevMode, NULL,
1347 if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
1348 !lstrcmpW(lpdm->dmDeviceName,
1349 PrintStructures->lpDevMode->dmDeviceName)) {
1350 /* Supplied devicemode matches current printer so try to use it */
1351 DocumentPropertiesW(0, 0, name, PrintStructures->lpDevMode, lpdm,
1353 }
1354 if(lpdm)
1355 GlobalUnlock(lppd->hDevMode);
1356
1357 lpdm = PrintStructures->lpDevMode; /* use this as a shortcut */
1358
1359 if(!(lppd->Flags & PD_PRINTSETUP)) {
1360 /* Print range (All/Range/Selection) */
1361 if(lppd->nFromPage != 0xffff)
1362 SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
1363 if(lppd->nToPage != 0xffff)
1364 SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
1365
1366 CheckRadioButton(hDlg, rad1, rad3, rad1); /* default */
1367 if (lppd->Flags & PD_NOSELECTION)
1369 else
1370 if (lppd->Flags & PD_SELECTION)
1371 CheckRadioButton(hDlg, rad1, rad3, rad2);
1372 if (lppd->Flags & PD_NOPAGENUMS) {
1378 } else {
1379 if (lppd->Flags & PD_PAGENUMS)
1380 CheckRadioButton(hDlg, rad1, rad3, rad3);
1381 }
1382
1383 /* Collate pages
1384 *
1385 * FIXME: The ico3 is not displayed for some reason. I don't know why.
1386 */
1387 if (lppd->Flags & PD_COLLATE) {
1389 (LPARAM)PrintStructures->hCollateIcon);
1390 CheckDlgButton(hDlg, chx2, 1);
1391 } else {
1393 (LPARAM)PrintStructures->hNoCollateIcon);
1394 CheckDlgButton(hDlg, chx2, 0);
1395 }
1396
1398 /* if printer doesn't support it: no Collate */
1399 if (!(lpdm->dmFields & DM_COLLATE)) {
1402 }
1403 }
1404
1405 /* nCopies */
1406 {
1407 INT copies;
1408 if (lppd->hDevMode == 0)
1409 copies = lppd->nCopies;
1410 else
1411 copies = lpdm->dmCopies;
1412 if(copies == 0) copies = 1;
1413 else if(copies < 0) copies = MAX_COPIES;
1414 SetDlgItemInt(hDlg, edt3, copies, FALSE);
1415 }
1416
1418 /* if printer doesn't support it: no nCopies */
1419 if (!(lpdm->dmFields & DM_COPIES)) {
1422 }
1423 }
1424
1425 /* print to file */
1426 CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
1427 if (lppd->Flags & PD_DISABLEPRINTTOFILE)
1429 if (lppd->Flags & PD_HIDEPRINTTOFILE)
1431
1432 /* Fill print quality combo, PrintDlg16 */
1433 if (GetDlgItem(hDlg, cmb1))
1434 {
1435 DWORD num_resolutions = DeviceCapabilitiesW(PrintStructures->lpPrinterInfo->pPrinterName,
1436 PrintStructures->lpPrinterInfo->pPortName,
1437 DC_ENUMRESOLUTIONS, NULL, lpdm);
1438
1439 if (num_resolutions != -1)
1440 {
1441 HWND quality = GetDlgItem(hDlg, cmb1);
1442 LONG* resolutions;
1443 WCHAR buf[255];
1444 DWORD i;
1445 int dpiX, dpiY;
1446 HDC printer = CreateDCW(PrintStructures->lpPrinterInfo->pDriverName,
1447 PrintStructures->lpPrinterInfo->pPrinterName,
1448 0, lpdm);
1449
1450 resolutions = malloc(num_resolutions * sizeof(LONG) * 2);
1452 PrintStructures->lpPrinterInfo->pPortName,
1453 DC_ENUMRESOLUTIONS, (LPWSTR)resolutions, lpdm);
1454
1455 dpiX = GetDeviceCaps(printer, LOGPIXELSX);
1456 dpiY = GetDeviceCaps(printer, LOGPIXELSY);
1457 DeleteDC(printer);
1458
1460 for (i = 0; i < (num_resolutions * 2); i += 2)
1461 {
1462 BOOL is_default = FALSE;
1463 LRESULT index;
1464
1465 if (resolutions[i] == resolutions[i+1])
1466 {
1467 if (dpiX == resolutions[i])
1468 is_default = TRUE;
1469 swprintf(buf, sizeof(buf), L"%ld dpi", resolutions[i]);
1470 } else
1471 {
1472 if (dpiX == resolutions[i] && dpiY == resolutions[i+1])
1473 is_default = TRUE;
1474 swprintf(buf, sizeof(buf), L"%ld dpi x %ld dpi", resolutions[i], resolutions[i+1]);
1475 }
1476
1478
1479 if (is_default)
1481
1482 SendMessageW(quality, CB_SETITEMDATA, index, MAKELONG(resolutions[i], resolutions[i+1]));
1483 }
1484 free(resolutions);
1485 }
1486 }
1487 } else { /* PD_PRINTSETUP */
1488 BOOL bPortrait = (lpdm->dmOrientation == DMORIENT_PORTRAIT);
1489
1491 PrintStructures->lpPrinterInfo->pPrinterName,
1492 PrintStructures->lpPrinterInfo->pPortName,
1493 lpdm);
1495 PrintStructures->lpPrinterInfo->pPrinterName,
1496 PrintStructures->lpPrinterInfo->pPortName,
1497 lpdm);
1498 CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
1500 (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
1501 PrintStructures->hLandscapeIcon));
1502
1503 }
1504
1505 /* help button */
1506 if ((lppd->Flags & PD_SHOWHELP)==0) {
1507 /* hide if PD_SHOWHELP not specified */
1509 }
1510 return TRUE;
1511}
1512
1513 /***********************************************************************
1514 * check_printer_setup [internal]
1515 */
1517{
1518 DWORD needed,num;
1519 WCHAR resourcestr[256],resultstr[256];
1520
1521 EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
1522 if(needed == 0)
1523 {
1525 }
1526 if(needed > 0)
1527 return TRUE;
1528 else
1529 {
1532 MessageBoxW(hDlg, resultstr, resourcestr,MB_OK | MB_ICONWARNING);
1533 return FALSE;
1534 }
1535}
1536
1537/***********************************************************************
1538 * PRINTDLG_WMInitDialog [internal]
1539 */
1541 PRINT_PTRA* PrintStructures)
1542{
1543 LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
1544 DEVNAMES *pdn;
1545 DEVMODEA *pdm;
1546 char *name = NULL;
1547 UINT comboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
1548
1549 /* load Collate ICONs */
1550 /* We load these with LoadImage because they are not a standard
1551 size and we don't want them rescaled */
1552 PrintStructures->hCollateIcon =
1553 LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0);
1554 PrintStructures->hNoCollateIcon =
1555 LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0);
1556
1557 /* These can be done with LoadIcon */
1558 PrintStructures->hPortraitIcon =
1559 LoadIconA(COMDLG32_hInstance, "PD32_PORTRAIT");
1560 PrintStructures->hLandscapeIcon =
1561 LoadIconA(COMDLG32_hInstance, "PD32_LANDSCAPE");
1562
1563 /* display the collate/no_collate icon */
1565 (LPARAM)PrintStructures->hNoCollateIcon);
1566
1567 if(PrintStructures->hCollateIcon == 0 ||
1568 PrintStructures->hNoCollateIcon == 0 ||
1569 PrintStructures->hPortraitIcon == 0 ||
1570 PrintStructures->hLandscapeIcon == 0) {
1571 ERR("no icon in resource file\n");
1573 EndDialog(hDlg, FALSE);
1574 }
1575
1576 /*
1577 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1578 * must be registered and the Help button must be shown.
1579 */
1580 if (lppd->Flags & PD_SHOWHELP) {
1581 if((PrintStructures->HelpMessageID =
1584 return FALSE;
1585 }
1586 } else
1587 PrintStructures->HelpMessageID = 0;
1588
1589 if(!(lppd->Flags &PD_PRINTSETUP)) {
1590 PrintStructures->hwndUpDown =
1593 UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
1595 GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
1596 }
1597
1598 /* FIXME: I allow more freedom than either Win95 or WinNT,
1599 * which do not agree on what errors should be thrown or not
1600 * in case nToPage or nFromPage is out-of-range.
1601 */
1602 if (lppd->nMaxPage < lppd->nMinPage)
1603 lppd->nMaxPage = lppd->nMinPage;
1604 if (lppd->nMinPage == lppd->nMaxPage)
1605 lppd->Flags |= PD_NOPAGENUMS;
1606 if (lppd->nToPage < lppd->nMinPage)
1607 lppd->nToPage = lppd->nMinPage;
1608 if (lppd->nToPage > lppd->nMaxPage)
1609 lppd->nToPage = lppd->nMaxPage;
1610 if (lppd->nFromPage < lppd->nMinPage)
1611 lppd->nFromPage = lppd->nMinPage;
1612 if (lppd->nFromPage > lppd->nMaxPage)
1613 lppd->nFromPage = lppd->nMaxPage;
1614
1615 /* if we have the combo box, fill it */
1616 if (GetDlgItem(hDlg,comboID)) {
1617 /* Fill Combobox
1618 */
1619 pdn = GlobalLock(lppd->hDevNames);
1620 pdm = GlobalLock(lppd->hDevMode);
1621 if(pdn)
1622 name = (char*)pdn + pdn->wDeviceOffset;
1623 else if(pdm)
1624 name = (char*)pdm->dmDeviceName;
1625 PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name);
1626 if(pdm) GlobalUnlock(lppd->hDevMode);
1627 if(pdn) GlobalUnlock(lppd->hDevNames);
1628
1629 /* Now find selected printer and update rest of dlg */
1630 name = malloc(256);
1631 if (GetDlgItemTextA(hDlg, comboID, name, 255))
1632 PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
1633 free(name);
1634 } else {
1635 /* else use default printer */
1636 char name[200];
1637 DWORD dwBufLen = ARRAY_SIZE(name);
1638 BOOL ret = GetDefaultPrinterA(name, &dwBufLen);
1639
1640 if (ret)
1641 PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
1642 else
1643 FIXME("No default printer found, expect problems!\n");
1644 }
1645 return TRUE;
1646}
1647
1649 PRINT_PTRW* PrintStructures)
1650{
1651 LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
1652 DEVNAMES *pdn;
1653 DEVMODEW *pdm;
1654 WCHAR *name = NULL;
1655 UINT comboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
1656
1657 /* load Collate ICONs */
1658 /* We load these with LoadImage because they are not a standard
1659 size and we don't want them rescaled */
1660 PrintStructures->hCollateIcon =
1661 LoadImageW(COMDLG32_hInstance, L"PD32_COLLATE", IMAGE_ICON, 0, 0, 0);
1662 PrintStructures->hNoCollateIcon =
1663 LoadImageW(COMDLG32_hInstance, L"PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0);
1664
1665 /* These can be done with LoadIcon */
1666 PrintStructures->hPortraitIcon =
1667 LoadIconW(COMDLG32_hInstance, L"PD32_PORTRAIT");
1668 PrintStructures->hLandscapeIcon =
1669 LoadIconW(COMDLG32_hInstance, L"PD32_LANDSCAPE");
1670
1671 /* display the collate/no_collate icon */
1673 (LPARAM)PrintStructures->hNoCollateIcon);
1674
1675 if(PrintStructures->hCollateIcon == 0 ||
1676 PrintStructures->hNoCollateIcon == 0 ||
1677 PrintStructures->hPortraitIcon == 0 ||
1678 PrintStructures->hLandscapeIcon == 0) {
1679 ERR("no icon in resource file\n");
1681 EndDialog(hDlg, FALSE);
1682 }
1683
1684 /*
1685 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message
1686 * must be registered and the Help button must be shown.
1687 */
1688 if (lppd->Flags & PD_SHOWHELP) {
1689 if((PrintStructures->HelpMessageID =
1692 return FALSE;
1693 }
1694 } else
1695 PrintStructures->HelpMessageID = 0;
1696
1697 if(!(lppd->Flags &PD_PRINTSETUP)) {
1698 PrintStructures->hwndUpDown =
1701 UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,
1703 GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);
1704 }
1705
1706 /* FIXME: I allow more freedom than either Win95 or WinNT,
1707 * which do not agree to what errors should be thrown or not
1708 * in case nToPage or nFromPage is out-of-range.
1709 */
1710 if (lppd->nMaxPage < lppd->nMinPage)
1711 lppd->nMaxPage = lppd->nMinPage;
1712 if (lppd->nMinPage == lppd->nMaxPage)
1713 lppd->Flags |= PD_NOPAGENUMS;
1714 if (lppd->nToPage < lppd->nMinPage)
1715 lppd->nToPage = lppd->nMinPage;
1716 if (lppd->nToPage > lppd->nMaxPage)
1717 lppd->nToPage = lppd->nMaxPage;
1718 if (lppd->nFromPage < lppd->nMinPage)
1719 lppd->nFromPage = lppd->nMinPage;
1720 if (lppd->nFromPage > lppd->nMaxPage)
1721 lppd->nFromPage = lppd->nMaxPage;
1722
1723 /* if we have the combo box, fill it */
1724 if (GetDlgItem(hDlg,comboID)) {
1725 /* Fill Combobox
1726 */
1727 pdn = GlobalLock(lppd->hDevNames);
1728 pdm = GlobalLock(lppd->hDevMode);
1729 if(pdn)
1730 name = (WCHAR*)pdn + pdn->wDeviceOffset;
1731 else if(pdm)
1732 name = pdm->dmDeviceName;
1733 PRINTDLG_SetUpPrinterListComboW(hDlg, comboID, name);
1734 if(pdm) GlobalUnlock(lppd->hDevMode);
1735 if(pdn) GlobalUnlock(lppd->hDevNames);
1736
1737 /* Now find selected printer and update rest of dlg */
1738 /* ansi is ok here */
1739 name = malloc(256 * sizeof(WCHAR));
1740 if (GetDlgItemTextW(hDlg, comboID, name, 255))
1741 PRINTDLG_ChangePrinterW(hDlg, name, PrintStructures);
1742 free(name);
1743 } else {
1744 /* else use default printer */
1745 WCHAR name[200];
1746 DWORD dwBufLen = ARRAY_SIZE(name);
1747 BOOL ret = GetDefaultPrinterW(name, &dwBufLen);
1748
1749 if (ret)
1750 PRINTDLG_ChangePrinterW(hDlg, name, PrintStructures);
1751 else
1752 FIXME("No default printer found, expect problems!\n");
1753 }
1754 return TRUE;
1755}
1756
1757/***********************************************************************
1758 * PRINTDLG_WMCommand [internal]
1759 */
1761 PRINT_PTRA* PrintStructures)
1762{
1763 LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
1764 UINT PrinterComboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
1765 LPDEVMODEA lpdm = PrintStructures->lpDevMode;
1766
1767 switch (LOWORD(wParam)) {
1768 case IDOK:
1769 TRACE(" OK button was hit\n");
1770 if (!PRINTDLG_UpdatePrintDlgA(hDlg, PrintStructures)) {
1771 FIXME("Update printdlg was not successful!\n");
1772 return(FALSE);
1773 }
1774 EndDialog(hDlg, TRUE);
1775 return(TRUE);
1776
1777 case IDCANCEL:
1778 TRACE(" CANCEL button was hit\n");
1779 EndDialog(hDlg, FALSE);
1780 return(FALSE);
1781
1782 case pshHelp:
1783 TRACE(" HELP button was hit\n");
1784 SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID,
1785 (WPARAM) hDlg, (LPARAM) lppd);
1786 break;
1787
1788 case chx2: /* collate pages checkbox */
1789 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
1791 (LPARAM)PrintStructures->hCollateIcon);
1792 else
1794 (LPARAM)PrintStructures->hNoCollateIcon);
1795 break;
1796 case edt1: /* from page nr editbox */
1797 case edt2: /* to page nr editbox */
1798 if (HIWORD(wParam)==EN_CHANGE) {
1799 WORD nToPage;
1800 WORD nFromPage;
1801 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
1802 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
1803 if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage)
1804 CheckRadioButton(hDlg, rad1, rad3, rad3);
1805 }
1806 break;
1807
1808 case edt3:
1809 if(HIWORD(wParam) == EN_CHANGE) {
1810 INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
1811 if(copies <= 1)
1813 else
1815 }
1816 break;
1817
1818 case psh1: /* Setup button */
1819 case psh2: /* Properties button */
1820 {
1821 HANDLE hPrinter;
1822 char PrinterName[256];
1823
1824 GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255);
1825 if (!OpenPrinterA(PrinterName, &hPrinter, NULL)) {
1826 FIXME(" Call to OpenPrinter did not succeed!\n");
1827 break;
1828 }
1829 DocumentPropertiesA(hDlg, hPrinter, PrinterName,
1830 PrintStructures->lpDevMode,
1831 PrintStructures->lpDevMode,
1833 ClosePrinter(hPrinter);
1834 break;
1835 }
1836
1837 case rad1: /* Paperorientation */
1838 if (lppd->Flags & PD_PRINTSETUP)
1839 {
1842 (LPARAM)(PrintStructures->hPortraitIcon));
1843 }
1844 break;
1845
1846 case rad2: /* Paperorientation */
1847 if (lppd->Flags & PD_PRINTSETUP)
1848 {
1851 (LPARAM)(PrintStructures->hLandscapeIcon));
1852 }
1853 break;
1854
1855 case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT16 */
1856 if (PrinterComboID != LOWORD(wParam)) {
1857 break;
1858 }
1859 /* FALLTHROUGH */
1860 case cmb4: /* Printer combobox */
1861 if (HIWORD(wParam)==CBN_SELCHANGE) {
1862 char *PrinterName;
1865 PrinterName = malloc(length + 1);
1866 SendDlgItemMessageA(hDlg, LOWORD(wParam), CB_GETLBTEXT, index, (LPARAM)PrinterName);
1867 PRINTDLG_ChangePrinterA(hDlg, PrinterName, PrintStructures);
1868 free(PrinterName);
1869 }
1870 break;
1871
1872 case cmb2: /* Papersize */
1873 {
1874 DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
1875 if(Sel != CB_ERR) {
1876 lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, Sel, 0);
1877 GetDlgItemTextA(hDlg, cmb2, (char *)lpdm->dmFormName, CCHFORMNAME);
1878 }
1879 }
1880 break;
1881
1882 case cmb3: /* Bin */
1883 {
1884 DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
1885 if(Sel != CB_ERR)
1887 }
1888 break;
1889 }
1890 if(lppd->Flags & PD_PRINTSETUP) {
1891 switch (LOWORD(wParam)) {
1892 case rad1: /* orientation */
1893 case rad2:
1894 if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
1895 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {
1898 (LPARAM)PrintStructures->hPortraitIcon);
1900 (LPARAM)PrintStructures->hPortraitIcon);
1901 }
1902 } else {
1903 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {
1906 (LPARAM)PrintStructures->hLandscapeIcon);
1908 (LPARAM)PrintStructures->hLandscapeIcon);
1909 }
1910 }
1911 break;
1912 }
1913 }
1914 return FALSE;
1915}
1916
1918 PRINT_PTRW* PrintStructures)
1919{
1920 LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
1921 UINT PrinterComboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4;
1922 LPDEVMODEW lpdm = PrintStructures->lpDevMode;
1923
1924 switch (LOWORD(wParam)) {
1925 case IDOK:
1926 TRACE(" OK button was hit\n");
1927 if (!PRINTDLG_UpdatePrintDlgW(hDlg, PrintStructures)) {
1928 FIXME("Update printdlg was not successful!\n");
1929 return(FALSE);
1930 }
1931 EndDialog(hDlg, TRUE);
1932 return(TRUE);
1933
1934 case IDCANCEL:
1935 TRACE(" CANCEL button was hit\n");
1936 EndDialog(hDlg, FALSE);
1937 return(FALSE);
1938
1939 case pshHelp:
1940 TRACE(" HELP button was hit\n");
1941 SendMessageW(lppd->hwndOwner, PrintStructures->HelpMessageID,
1942 (WPARAM) hDlg, (LPARAM) lppd);
1943 break;
1944
1945 case chx2: /* collate pages checkbox */
1946 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
1948 (LPARAM)PrintStructures->hCollateIcon);
1949 else
1951 (LPARAM)PrintStructures->hNoCollateIcon);
1952 break;
1953 case edt1: /* from page nr editbox */
1954 case edt2: /* to page nr editbox */
1955 if (HIWORD(wParam)==EN_CHANGE) {
1956 WORD nToPage;
1957 WORD nFromPage;
1958 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);
1959 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE);
1960 if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage)
1961 CheckRadioButton(hDlg, rad1, rad3, rad3);
1962 }
1963 break;
1964
1965 case edt3:
1966 if(HIWORD(wParam) == EN_CHANGE) {
1967 INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
1968 if(copies <= 1)
1970 else
1972 }
1973 break;
1974
1975 case psh1: /* Setup button */
1976 case psh2: /* Properties button */
1977 {
1978 HANDLE hPrinter;
1979 WCHAR PrinterName[256];
1980
1981 if (!GetDlgItemTextW(hDlg, PrinterComboID, PrinterName, 255)) break;
1982 if (!OpenPrinterW(PrinterName, &hPrinter, NULL)) {
1983 FIXME(" Call to OpenPrinter did not succeed!\n");
1984 break;
1985 }
1986 DocumentPropertiesW(hDlg, hPrinter, PrinterName,
1987 PrintStructures->lpDevMode,
1988 PrintStructures->lpDevMode,
1990 ClosePrinter(hPrinter);
1991 break;
1992 }
1993
1994 case rad1: /* Paperorientation */
1995 if (lppd->Flags & PD_PRINTSETUP)
1996 {
1999 (LPARAM)(PrintStructures->hPortraitIcon));
2000 }
2001 break;
2002
2003 case rad2: /* Paperorientation */
2004 if (lppd->Flags & PD_PRINTSETUP)
2005 {
2008 (LPARAM)(PrintStructures->hLandscapeIcon));
2009 }
2010 break;
2011
2012 case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT16 */
2013 if (PrinterComboID != LOWORD(wParam)) {
2014 break;
2015 }
2016 /* FALLTHROUGH */
2017 case cmb4: /* Printer combobox */
2018 if (HIWORD(wParam)==CBN_SELCHANGE) {
2019 WCHAR *PrinterName;
2022
2023 PrinterName = malloc(sizeof(WCHAR) * (length + 1));
2024 SendDlgItemMessageW(hDlg, LOWORD(wParam), CB_GETLBTEXT, index, (LPARAM)PrinterName);
2025 PRINTDLG_ChangePrinterW(hDlg, PrinterName, PrintStructures);
2026 free(PrinterName);
2027 }
2028 break;
2029
2030 case cmb2: /* Papersize */
2031 {
2032 DWORD Sel = SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0);
2033 if(Sel != CB_ERR) {
2034 lpdm->dmPaperSize = SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, Sel, 0);
2036 }
2037 }
2038 break;
2039
2040 case cmb3: /* Bin */
2041 {
2042 DWORD Sel = SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0);
2043 if(Sel != CB_ERR)
2045 }
2046 break;
2047 }
2048 if(lppd->Flags & PD_PRINTSETUP) {
2049 switch (LOWORD(wParam)) {
2050 case rad1: /* orientation */
2051 case rad2:
2052 if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {
2053 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {
2056 (LPARAM)PrintStructures->hPortraitIcon);
2058 (LPARAM)PrintStructures->hPortraitIcon);
2059 }
2060 } else {
2061 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {
2064 (LPARAM)PrintStructures->hLandscapeIcon);
2066 (LPARAM)PrintStructures->hLandscapeIcon);
2067 }
2068 }
2069 break;
2070 }
2071 }
2072 return FALSE;
2073}
2074
2075/***********************************************************************
2076 * PrintDlgProcA [internal]
2077 */
2079 LPARAM lParam)
2080{
2081 PRINT_PTRA* PrintStructures;
2082 INT_PTR res = FALSE;
2083
2084 if (uMsg!=WM_INITDIALOG) {
2085 PrintStructures = GetPropW(hDlg, printdlg_prop);
2086 if (!PrintStructures)
2087 return FALSE;
2088 } else {
2089 PrintStructures = (PRINT_PTRA*) lParam;
2090 SetPropW(hDlg, printdlg_prop, PrintStructures);
2091 if(!check_printer_setup(hDlg))
2092 {
2093 EndDialog(hDlg,FALSE);
2094 return FALSE;
2095 }
2096 res = PRINTDLG_WMInitDialog(hDlg, PrintStructures);
2097
2098 if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
2099 res = PrintStructures->lpPrintDlg->lpfnPrintHook(
2100 hDlg, uMsg, wParam, (LPARAM)PrintStructures->lpPrintDlg
2101 );
2102 return res;
2103 }
2104
2105 if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
2106 res = PrintStructures->lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam,
2107 lParam);
2108 if(res) return res;
2109 }
2110
2111 switch (uMsg) {
2112 case WM_COMMAND:
2113 return PRINTDLG_WMCommandA(hDlg, wParam, PrintStructures);
2114
2115 case WM_DESTROY:
2116 DestroyIcon(PrintStructures->hCollateIcon);
2117 DestroyIcon(PrintStructures->hNoCollateIcon);
2118 DestroyIcon(PrintStructures->hPortraitIcon);
2119 DestroyIcon(PrintStructures->hLandscapeIcon);
2120 if(PrintStructures->hwndUpDown)
2121 DestroyWindow(PrintStructures->hwndUpDown);
2122 return FALSE;
2123 }
2124 return res;
2125}
2126
2128 LPARAM lParam)
2129{
2130 PRINT_PTRW* PrintStructures;
2131 INT_PTR res = FALSE;
2132
2133 if (uMsg!=WM_INITDIALOG) {
2134 PrintStructures = GetPropW(hDlg, printdlg_prop);
2135 if (!PrintStructures)
2136 return FALSE;
2137 } else {
2138 PrintStructures = (PRINT_PTRW*) lParam;
2139 SetPropW(hDlg, printdlg_prop, PrintStructures);
2140 if(!check_printer_setup(hDlg))
2141 {
2142 EndDialog(hDlg,FALSE);
2143 return FALSE;
2144 }
2145 res = PRINTDLG_WMInitDialogW(hDlg, PrintStructures);
2146
2147 if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)
2148 res = PrintStructures->lpPrintDlg->lpfnPrintHook(hDlg, uMsg, wParam, (LPARAM)PrintStructures->lpPrintDlg);
2149 return res;
2150 }
2151
2152 if(PrintStructures->lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
2153 res = PrintStructures->lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam, lParam);
2154 if(res) return res;
2155 }
2156
2157 switch (uMsg) {
2158 case WM_COMMAND:
2159 return PRINTDLG_WMCommandW(hDlg, wParam, PrintStructures);
2160
2161 case WM_DESTROY:
2162 DestroyIcon(PrintStructures->hCollateIcon);
2163 DestroyIcon(PrintStructures->hNoCollateIcon);
2164 DestroyIcon(PrintStructures->hPortraitIcon);
2165 DestroyIcon(PrintStructures->hLandscapeIcon);
2166 if(PrintStructures->hwndUpDown)
2167 DestroyWindow(PrintStructures->hwndUpDown);
2168 return FALSE;
2169 }
2170 return res;
2171}
2172
2173/************************************************************
2174 *
2175 * PRINTDLG_GetDlgTemplate
2176 *
2177 */
2179{
2180 HRSRC hResInfo;
2181 HGLOBAL hDlgTmpl;
2182
2183 if (lppd->Flags & PD_PRINTSETUP) {
2185 hDlgTmpl = lppd->hSetupTemplate;
2186 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
2187 hResInfo = FindResourceA(lppd->hInstance,
2189 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
2190 } else {
2191 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP",
2192 (LPSTR)RT_DIALOG);
2193 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
2194 }
2195 } else {
2197 hDlgTmpl = lppd->hPrintTemplate;
2198 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
2199 hResInfo = FindResourceA(lppd->hInstance,
2200 lppd->lpPrintTemplateName,
2201 (LPSTR)RT_DIALOG);
2202 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
2203 } else {
2204 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32",
2205 (LPSTR)RT_DIALOG);
2206 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
2207 }
2208 }
2209 return hDlgTmpl;
2210}
2211
2213{
2214 HRSRC hResInfo;
2215 HGLOBAL hDlgTmpl;
2216
2217 if (lppd->Flags & PD_PRINTSETUP) {
2219 hDlgTmpl = lppd->hSetupTemplate;
2220 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
2221 hResInfo = FindResourceW(lppd->hInstance,
2223 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
2224 } else {
2225 hResInfo = FindResourceW(COMDLG32_hInstance, L"PRINT32_SETUP", (LPWSTR)RT_DIALOG);
2226 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
2227 }
2228 } else {
2230 hDlgTmpl = lppd->hPrintTemplate;
2231 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
2232 hResInfo = FindResourceW(lppd->hInstance,
2233 lppd->lpPrintTemplateName,
2234 (LPWSTR)RT_DIALOG);
2235 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
2236 } else {
2237 hResInfo = FindResourceW(COMDLG32_hInstance, L"PRINT32", (LPWSTR)RT_DIALOG);
2238 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
2239 }
2240 }
2241 return hDlgTmpl;
2242}
2243
2244/***********************************************************************
2245 *
2246 * PRINTDLG_CreateDC
2247 *
2248 */
2250{
2251 DEVNAMES *pdn = GlobalLock(lppd->hDevNames);
2252 DEVMODEA *pdm = GlobalLock(lppd->hDevMode);
2253
2254 if(lppd->Flags & PD_RETURNDC) {
2255 lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset,
2256 (char*)pdn + pdn->wDeviceOffset,
2257 (char*)pdn + pdn->wOutputOffset,
2258 pdm );
2259 } else if(lppd->Flags & PD_RETURNIC) {
2260 lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset,
2261 (char*)pdn + pdn->wDeviceOffset,
2262 (char*)pdn + pdn->wOutputOffset,
2263 pdm );
2264 }
2265 GlobalUnlock(lppd->hDevNames);
2266 GlobalUnlock(lppd->hDevMode);
2267 return lppd->hDC != NULL;
2268}
2269
2271{
2272 DEVNAMES *pdn = GlobalLock(lppd->hDevNames);
2273 DEVMODEW *pdm = GlobalLock(lppd->hDevMode);
2274
2275 if(lppd->Flags & PD_RETURNDC) {
2276 lppd->hDC = CreateDCW((WCHAR*)pdn + pdn->wDriverOffset,
2277 (WCHAR*)pdn + pdn->wDeviceOffset,
2278 (WCHAR*)pdn + pdn->wOutputOffset,
2279 pdm );
2280 } else if(lppd->Flags & PD_RETURNIC) {
2281 lppd->hDC = CreateICW((WCHAR*)pdn + pdn->wDriverOffset,
2282 (WCHAR*)pdn + pdn->wDeviceOffset,
2283 (WCHAR*)pdn + pdn->wOutputOffset,
2284 pdm );
2285 }
2286 GlobalUnlock(lppd->hDevNames);
2287 GlobalUnlock(lppd->hDevMode);
2288 return lppd->hDC != NULL;
2289}
2290
2291/***********************************************************************
2292 * PrintDlgA (COMDLG32.@)
2293 *
2294 * Displays the PRINT dialog box, which enables the user to specify
2295 * specific properties of the print job.
2296 *
2297 * PARAMS
2298 * lppd [IO] ptr to PRINTDLG32 struct
2299 *
2300 * RETURNS
2301 * nonzero if the user pressed the OK button
2302 * zero if the user cancelled the window or an error occurred
2303 *
2304 * BUGS
2305 * PrintDlg:
2306 * * The Collate Icons do not display, even though they are in the code.
2307 * * The Properties Button(s) should call DocumentPropertiesA().
2308 */
2309
2311{
2312 BOOL bRet = FALSE;
2313 LPVOID ptr;
2315
2316 if (!lppd)
2317 {
2319 return FALSE;
2320 }
2321
2322 if(TRACE_ON(commdlg)) {
2323 char flagstr[1000] = "";
2324 const struct pd_flags *pflag = pd_flags;
2325 for( ; pflag->name; pflag++) {
2326 if(lppd->Flags & pflag->flag)
2327 strcat(flagstr, pflag->name);
2328 }
2329 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2330 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
2331 "flags %08lx (%s)\n",
2332 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
2333 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
2334 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
2335 }
2336
2337 if(lppd->lStructSize != sizeof(PRINTDLGA)) {
2338 WARN("structure size failure!!!\n");
2340 return FALSE;
2341 }
2342
2343 if(lppd->Flags & PD_RETURNDEFAULT) {
2345 DRIVER_INFO_3A *dbuf;
2346 HANDLE hprn;
2347 DWORD needed;
2348
2349 if(lppd->hDevMode || lppd->hDevNames) {
2350 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
2352 return FALSE;
2353 }
2354 if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
2355 WARN("Can't find default printer\n");
2357 return FALSE;
2358 }
2359
2360 GetPrinterA(hprn, 2, NULL, 0, &needed);
2361 pbuf = malloc(needed);
2362 GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);
2363
2364 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
2365 dbuf = malloc(needed);
2366 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
2367 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",
2368 GetLastError(),pbuf->pPrinterName);
2369 free(dbuf);
2370 free(pbuf);
2372 return FALSE;
2373 }
2374 ClosePrinter(hprn);
2375
2377 dbuf->pDriverPath,
2378 pbuf->pPrinterName,
2379 pbuf->pPortName);
2380 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
2381 pbuf->pDevMode->dmDriverExtra);
2382 ptr = GlobalLock(lppd->hDevMode);
2383 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
2384 pbuf->pDevMode->dmDriverExtra);
2385 GlobalUnlock(lppd->hDevMode);
2386 free(pbuf);
2387 free(dbuf);
2388 bRet = TRUE;
2389 } else {
2390 HGLOBAL hDlgTmpl;
2391 PRINT_PTRA *PrintStructures;
2392
2393 /* load Dialog resources,
2394 * depending on Flags indicates Print32 or Print32_setup dialog
2395 */
2396 hDlgTmpl = PRINTDLG_GetDlgTemplateA(lppd);
2397 if (!hDlgTmpl) {
2399 return FALSE;
2400 }
2401 ptr = LockResource( hDlgTmpl );
2402 if (!ptr) {
2404 return FALSE;
2405 }
2406
2407 PrintStructures = calloc(1, sizeof(PRINT_PTRA));
2408 PrintStructures->lpPrintDlg = lppd;
2409
2410 /* and create & process the dialog .
2411 * -1 is failure, 0 is broken hwnd, everything else is ok.
2412 */
2415 bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner,
2417 (LPARAM)PrintStructures));
2418
2419 if(bRet) {
2420 DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
2421 PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;
2422 DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;
2423
2424 if (lppd->hDevMode == 0) {
2425 TRACE(" No hDevMode yet... Need to create my own\n");
2427 lpdm->dmSize + lpdm->dmDriverExtra);
2428 } else {
2429 lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,
2430 lpdm->dmSize + lpdm->dmDriverExtra,
2432 }
2433 lpdmReturn = GlobalLock(lppd->hDevMode);
2434 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
2435
2437 di->pDriverPath,
2438 pi->pPrinterName,
2439 pi->pPortName
2440 );
2441 GlobalUnlock(lppd->hDevMode);
2442 }
2443 free(PrintStructures->lpDevMode);
2444 free(PrintStructures->lpPrinterInfo);
2445 free(PrintStructures->lpDriverInfo);
2446 free(PrintStructures);
2447 }
2448 if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
2449 bRet = PRINTDLG_CreateDCA(lppd);
2450
2451 TRACE("exit! (%d)\n", bRet);
2452 return bRet;
2453}
2454
2455/***********************************************************************
2456 * PrintDlgW (COMDLG32.@)
2457 *
2458 * See PrintDlgA.
2459 */
2461{
2462 BOOL bRet = FALSE;
2463 LPVOID ptr;
2465
2466 if (!lppd)
2467 {
2469 return FALSE;
2470 }
2471
2472 if(TRACE_ON(commdlg)) {
2473 char flagstr[1000] = "";
2474 const struct pd_flags *pflag = pd_flags;
2475 for( ; pflag->name; pflag++) {
2476 if(lppd->Flags & pflag->flag)
2477 strcat(flagstr, pflag->name);
2478 }
2479 TRACE("(%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
2480 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %p\n"
2481 "flags %08lx (%s)\n",
2482 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,
2483 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,
2484 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);
2485 }
2486
2487 if(lppd->lStructSize != sizeof(PRINTDLGW)) {
2488 WARN("structure size failure!!!\n");
2490 return FALSE;
2491 }
2492
2493 if(lppd->Flags & PD_RETURNDEFAULT) {
2495 DRIVER_INFO_3W *dbuf;
2496 HANDLE hprn;
2497 DWORD needed;
2498
2499 if(lppd->hDevMode || lppd->hDevNames) {
2500 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
2502 return FALSE;
2503 }
2504 if(!PRINTDLG_OpenDefaultPrinter(&hprn)) {
2505 WARN("Can't find default printer\n");
2507 return FALSE;
2508 }
2509
2510 GetPrinterW(hprn, 2, NULL, 0, &needed);
2511 pbuf = malloc(needed);
2512 GetPrinterW(hprn, 2, (LPBYTE)pbuf, needed, &needed);
2513
2514 GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
2515 dbuf = malloc(needed);
2516 if (!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
2517 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",
2518 GetLastError(),debugstr_w(pbuf->pPrinterName));
2519 free(dbuf);
2520 free(pbuf);
2522 return FALSE;
2523 }
2524 ClosePrinter(hprn);
2525
2527 dbuf->pDriverPath,
2528 pbuf->pPrinterName,
2529 pbuf->pPortName);
2530 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +
2531 pbuf->pDevMode->dmDriverExtra);
2532 ptr = GlobalLock(lppd->hDevMode);
2533 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +
2534 pbuf->pDevMode->dmDriverExtra);
2535 GlobalUnlock(lppd->hDevMode);
2536 free(pbuf);
2537 free(dbuf);
2538 bRet = TRUE;
2539 } else {
2540 HGLOBAL hDlgTmpl;
2541 PRINT_PTRW *PrintStructures;
2542
2543 /* load Dialog resources,
2544 * depending on Flags indicates Print32 or Print32_setup dialog
2545 */
2546 hDlgTmpl = PRINTDLG_GetDlgTemplateW(lppd);
2547 if (!hDlgTmpl) {
2549 return FALSE;
2550 }
2551 ptr = LockResource( hDlgTmpl );
2552 if (!ptr) {
2554 return FALSE;
2555 }
2556
2557 PrintStructures = calloc(1, sizeof(PRINT_PTRW));
2558 PrintStructures->lpPrintDlg = lppd;
2559
2560 /* and create & process the dialog .
2561 * -1 is failure, 0 is broken hwnd, everything else is ok.
2562 */
2565 bRet = (0<DialogBoxIndirectParamW(hInst, ptr, lppd->hwndOwner,
2567 (LPARAM)PrintStructures));
2568
2569 if(bRet) {
2570 DEVMODEW *lpdm = PrintStructures->lpDevMode, *lpdmReturn;
2571 PRINTER_INFO_2W *pi = PrintStructures->lpPrinterInfo;
2572 DRIVER_INFO_3W *di = PrintStructures->lpDriverInfo;
2573
2574 if (lppd->hDevMode == 0) {
2575 TRACE(" No hDevMode yet... Need to create my own\n");
2577 lpdm->dmSize + lpdm->dmDriverExtra);
2578 } else {
2579 WORD locks;
2580 if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {
2581 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);
2582 while(locks--) {
2583 GlobalUnlock(lppd->hDevMode);
2584 TRACE("Now got %d locks\n", locks);
2585 }
2586 }
2587 lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,
2588 lpdm->dmSize + lpdm->dmDriverExtra,
2590 }
2591 lpdmReturn = GlobalLock(lppd->hDevMode);
2592 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);
2593
2594 if (lppd->hDevNames != 0) {
2595 WORD locks;
2596 if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) {
2597 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);
2598 while(locks--)
2599 GlobalUnlock(lppd->hDevNames);
2600 }
2601 }
2603 di->pDriverPath,
2604 pi->pPrinterName,
2605 pi->pPortName
2606 );
2607 GlobalUnlock(lppd->hDevMode);
2608 }
2609 free(PrintStructures->lpDevMode);
2610 free(PrintStructures->lpPrinterInfo);
2611 free(PrintStructures->lpDriverInfo);
2612 free(PrintStructures);
2613 }
2614 if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
2615 bRet = PRINTDLG_CreateDCW(lppd);
2616
2617 TRACE("exit! (%d)\n", bRet);
2618 return bRet;
2619}
2620
2621/***********************************************************************
2622 *
2623 * PageSetupDlg
2624 * rad1 - portrait
2625 * rad2 - landscape
2626 * cmb1 - printer select (not in standard dialog template)
2627 * cmb2 - paper size
2628 * cmb3 - source (tray?)
2629 * edt4 - border left
2630 * edt5 - border top
2631 * edt6 - border right
2632 * edt7 - border bottom
2633 * psh3 - "Printer..."
2634 */
2635
2636typedef struct
2637{
2639 union
2640 {
2643 } u;
2644 HWND hDlg; /* Page Setup dialog handle */
2645 RECT rtDrawRect; /* Drawing rect for page */
2647
2649{
2650 return data->u.dlgw->Flags;
2651}
2652
2653static inline BOOL is_metric(const pagesetup_data *data)
2654{
2656}
2657
2659{
2660 if (is_metric(data))
2661 return 10 * size;
2662 else
2663 return 10 * size * 100 / 254;
2664}
2665
2667{
2668 if (is_metric(data))
2669 return size * 254 / 100;
2670 else
2671 return size;
2672}
2673
2675{
2676 static WCHAR sep;
2677
2678 if(!sep)
2679 {
2680 WCHAR buf[] = L".";
2682 sep = buf[0];
2683 }
2684 return sep;
2685}
2686
2687static void size2str(const pagesetup_data *data, DWORD size, LPWSTR strout)
2688{
2689 /* FIXME use LOCALE_SDECIMAL when the edit parsing code can cope */
2690
2691 if (is_metric(data))
2692 {
2693 if(size % 100)
2694 wsprintfW(strout, L"%d%c%02d", size / 100, get_decimal_sep(), size % 100);
2695 else
2696 wsprintfW(strout, L"%d", size / 100);
2697 }
2698 else
2699 {
2700 if(size % 1000)
2701 wsprintfW(strout, L"%d%c%03d", size / 1000, get_decimal_sep(), size % 1000);
2702 else
2703 wsprintfW(strout, L"%d", size / 1000);
2704
2705 }
2706}
2707
2708static inline BOOL is_default_metric(void)
2709{
2710 DWORD system;
2711 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IMEASURE | LOCALE_RETURN_NUMBER,
2712 (LPWSTR)&system, sizeof(system));
2713 return system == 0;
2714}
2715
2716/**********************************************
2717 * rotate_rect
2718 * Cyclically permute the four members of rc
2719 * If sense is TRUE l -> t -> r -> b
2720 * otherwise l <- t <- r <- b
2721 */
2722static inline void rotate_rect(RECT *rc, BOOL sense)
2723{
2724 INT tmp;
2725 if(sense)
2726 {
2727 tmp = rc->bottom;
2728 rc->bottom = rc->right;
2729 rc->right = rc->top;
2730 rc->top = rc->left;
2731 rc->left = tmp;
2732 }
2733 else
2734 {
2735 tmp = rc->left;
2736 rc->left = rc->top;
2737 rc->top = rc->right;
2738 rc->right = rc->bottom;
2739 rc->bottom = tmp;
2740 }
2741}
2742
2744{
2745 DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2746
2747 assert(orient == DMORIENT_PORTRAIT || orient == DMORIENT_LANDSCAPE);
2748
2749 if(data->unicode)
2750 dm->dmOrientation = orient;
2751 else
2752 {
2753 DEVMODEA *dmA = (DEVMODEA *)dm;
2754 dmA->dmOrientation = orient;
2755 }
2756 GlobalUnlock(data->u.dlgw->hDevMode);
2757}
2758
2760{
2761 DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2762 WORD orient;
2763
2764 if(data->unicode)
2765 orient = dm->dmOrientation;
2766 else
2767 {
2768 DEVMODEA *dmA = (DEVMODEA *)dm;
2769 orient = dmA->dmOrientation;
2770 }
2771 GlobalUnlock(data->u.dlgw->hDevMode);
2772 return orient;
2773}
2774
2776{
2777 DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2778
2779 if(data->unicode)
2780 dm->dmPaperSize = paper;
2781 else
2782 {
2783 DEVMODEA *dmA = (DEVMODEA *)dm;
2784 dmA->dmPaperSize = paper;
2785 }
2786 GlobalUnlock(data->u.dlgw->hDevMode);
2787}
2788
2790{
2791 DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2792 WORD paper;
2793
2794 if(data->unicode)
2795 paper = dm->dmPaperSize;
2796 else
2797 {
2798 DEVMODEA *dmA = (DEVMODEA *)dm;
2799 paper = dmA->dmPaperSize;
2800 }
2801 GlobalUnlock(data->u.dlgw->hDevMode);
2802 return paper;
2803}
2804
2806{
2807 DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2808
2809 if(data->unicode)
2810 dm->dmDefaultSource = source;
2811 else
2812 {
2813 DEVMODEA *dmA = (DEVMODEA *)dm;
2814 dmA->dmDefaultSource = source;
2815 }
2816 GlobalUnlock(data->u.dlgw->hDevMode);
2817}
2818
2819typedef enum
2820{
2825
2826
2828{
2829 switch(which)
2830 {
2831 case devnames_driver_name: return dn->wDriverOffset;
2832 case devnames_device_name: return dn->wDeviceOffset;
2833 case devnames_output_name: return dn->wOutputOffset;
2834 }
2835 ERR("Shouldn't be here\n");
2836 return 0;
2837}
2838
2840{
2841 DEVNAMES *dn;
2842 WCHAR *name;
2843
2844 dn = GlobalLock(data->u.dlgw->hDevNames);
2845 if(data->unicode)
2846 name = wcsdup((WCHAR *)dn + get_devname_offset(dn, which));
2847 else
2848 {
2849 int len = MultiByteToWideChar(CP_ACP, 0, (char*)dn + get_devname_offset(dn, which), -1, NULL, 0);
2850 name = malloc(len * sizeof(WCHAR));
2851 MultiByteToWideChar(CP_ACP, 0, (char*)dn + get_devname_offset(dn, which), -1, name, len);
2852 }
2853 GlobalUnlock(data->u.dlgw->hDevNames);
2854 return name;
2855}
2856
2858{
2860}
2861
2863{
2865}
2866
2868{
2870}
2871
2873{
2874 free(name);
2875}
2876
2878{
2879 DEVNAMES *dn;
2880 WCHAR def[256];
2881 DWORD len = sizeof(DEVNAMES), drv_len, dev_len, port_len;
2882
2883 if(data->unicode)
2884 {
2885 drv_len = (lstrlenW(drv) + 1) * sizeof(WCHAR);
2886 dev_len = (lstrlenW(devname) + 1) * sizeof(WCHAR);
2887 port_len = (lstrlenW(port) + 1) * sizeof(WCHAR);
2888 }
2889 else
2890 {
2891 drv_len = WideCharToMultiByte(CP_ACP, 0, drv, -1, NULL, 0, NULL, NULL);
2892 dev_len = WideCharToMultiByte(CP_ACP, 0, devname, -1, NULL, 0, NULL, NULL);
2893 port_len = WideCharToMultiByte(CP_ACP, 0, port, -1, NULL, 0, NULL, NULL);
2894 }
2895 len += drv_len + dev_len + port_len;
2896
2897 if(data->u.dlgw->hDevNames)
2898 data->u.dlgw->hDevNames = GlobalReAlloc(data->u.dlgw->hDevNames, len, GMEM_MOVEABLE);
2899 else
2900 data->u.dlgw->hDevNames = GlobalAlloc(GMEM_MOVEABLE, len);
2901
2902 dn = GlobalLock(data->u.dlgw->hDevNames);
2903
2904 if(data->unicode)
2905 {
2906 WCHAR *ptr = (WCHAR *)(dn + 1);
2907 len = sizeof(DEVNAMES) / sizeof(WCHAR);
2908 dn->wDriverOffset = len;
2909 lstrcpyW(ptr, drv);
2910 ptr += drv_len / sizeof(WCHAR);
2911 len += drv_len / sizeof(WCHAR);
2912 dn->wDeviceOffset = len;
2913 lstrcpyW(ptr, devname);
2914 ptr += dev_len / sizeof(WCHAR);
2915 len += dev_len / sizeof(WCHAR);
2916 dn->wOutputOffset = len;
2917 lstrcpyW(ptr, port);
2918 }
2919 else
2920 {
2921 char *ptr = (char *)(dn + 1);
2922 len = sizeof(DEVNAMES);
2923 dn->wDriverOffset = len;
2924 WideCharToMultiByte(CP_ACP, 0, drv, -1, ptr, drv_len, NULL, NULL);
2925 ptr += drv_len;
2926 len += drv_len;
2927 dn->wDeviceOffset = len;
2928 WideCharToMultiByte(CP_ACP, 0, devname, -1, ptr, dev_len, NULL, NULL);
2929 ptr += dev_len;
2930 len += dev_len;
2931 dn->wOutputOffset = len;
2932 WideCharToMultiByte(CP_ACP, 0, port, -1, ptr, port_len, NULL, NULL);
2933 }
2934
2935 dn->wDefault = 0;
2936 len = ARRAY_SIZE(def);
2937 GetDefaultPrinterW(def, &len);
2938 if(!lstrcmpW(def, devname))
2939 dn->wDefault = 1;
2940
2941 GlobalUnlock(data->u.dlgw->hDevNames);
2942}
2943
2945{
2946 DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2947 DEVMODEW *ret;
2948
2949 if(data->unicode)
2950 {
2951 /* We make a copy even in the unicode case because the ptr
2952 may get passed back to us in pagesetup_set_devmode. */
2953 ret = malloc(dm->dmSize + dm->dmDriverExtra);
2954 memcpy(ret, dm, dm->dmSize + dm->dmDriverExtra);
2955 }
2956 else
2958
2959 GlobalUnlock(data->u.dlgw->hDevMode);
2960 return ret;
2961}
2962
2964{
2965 free(dm);
2966}
2967
2969{
2970 DEVMODEA *dmA = NULL;
2971 void *src, *dst;
2972 DWORD size;
2973
2974 if(data->unicode)
2975 {
2976 size = dm->dmSize + dm->dmDriverExtra;
2977 src = dm;
2978 }
2979 else
2980 {
2981 dmA = convert_to_devmodeA(dm);
2982 size = dmA->dmSize + dmA->dmDriverExtra;
2983 src = dmA;
2984 }
2985
2986 if(data->u.dlgw->hDevMode)
2987 data->u.dlgw->hDevMode = GlobalReAlloc(data->u.dlgw->hDevMode, size,
2989 else
2990 data->u.dlgw->hDevMode = GlobalAlloc(GMEM_MOVEABLE, size);
2991
2992 dst = GlobalLock(data->u.dlgw->hDevMode);
2993 memcpy(dst, src, size);
2994 GlobalUnlock(data->u.dlgw->hDevMode);
2995 free(dmA);
2996}
2997
2999{
3000 return &data->u.dlgw->ptPaperSize;
3001}
3002
3004{
3005 return &data->u.dlgw->rtMargin;
3006}
3007
3008typedef enum
3009{
3013
3015{
3016 switch(which)
3017 {
3018 case page_setup_hook: return data->u.dlgw->lpfnPageSetupHook;
3019 case page_paint_hook: return data->u.dlgw->lpfnPagePaintHook;
3020 }
3021 return NULL;
3022}
3023
3024/* This should only be used in calls to hook procs so we return the ptr
3025 already cast to LPARAM */
3027{
3028 return (LPARAM)data->u.dlgw;
3029}
3030
3031static inline void swap_point(POINT *pt)
3032{
3033 LONG tmp = pt->x;
3034 pt->x = pt->y;
3035 pt->y = tmp;
3036}
3037
3039{
3040 DEVMODEW *dm;
3041 LPWSTR devname, portname;
3042 int i, num;
3043 WORD *words = NULL, paperword;
3044 POINT *points = NULL;
3045 BOOL retval = FALSE;
3046
3048 devname = pagesetup_get_devname(data);
3049 portname = pagesetup_get_portname(data);
3050
3051 num = DeviceCapabilitiesW(devname, portname, DC_PAPERS, NULL, dm);
3052 if (num <= 0)
3053 {
3054 FIXME("No papernames found for %s/%s\n", debugstr_w(devname), debugstr_w(portname));
3055 goto end;
3056 }
3057
3058 words = malloc(num * sizeof(WORD));
3059 points = malloc(num * sizeof(POINT));
3060
3061 if (num != DeviceCapabilitiesW(devname, portname, DC_PAPERS, (LPWSTR)words, dm))
3062 {
3063 FIXME("Number of returned words is not %d\n", num);
3064 goto end;
3065 }
3066
3067 if (num != DeviceCapabilitiesW(devname, portname, DC_PAPERSIZE, (LPWSTR)points, dm))
3068 {
3069 FIXME("Number of returned sizes is not %d\n", num);
3070 goto end;
3071 }
3072
3073 paperword = pagesetup_get_papersize(data);
3074
3075 for (i = 0; i < num; i++)
3076 if (words[i] == paperword)
3077 break;
3078
3079 if (i == num)
3080 {
3081 FIXME("Papersize %d not found in list?\n", paperword);
3082 goto end;
3083 }
3084
3085 /* this is _10ths_ of a millimeter */
3088
3091
3092 retval = TRUE;
3093
3094end:
3095 free(words);
3096 free(points);
3100
3101 return retval;
3102}
3103
3104/**********************************************************************************************
3105 * pagesetup_change_printer
3106 *
3107 * Redefines hDevMode and hDevNames HANDLES and initialises it.
3108 *
3109 */
3111{
3112 HANDLE hprn;
3113 DWORD needed;
3114 PRINTER_INFO_2W *prn_info = NULL;
3115 DRIVER_INFO_3W *drv_info = NULL;
3116 DEVMODEW *dm = NULL;
3117 BOOL retval = FALSE;
3118
3119 if(!OpenPrinterW(name, &hprn, NULL))
3120 {
3121 ERR("Can't open printer %s\n", debugstr_w(name));
3122 goto end;
3123 }
3124
3125 GetPrinterW(hprn, 2, NULL, 0, &needed);
3126 prn_info = malloc(needed);
3127 GetPrinterW(hprn, 2, (LPBYTE)prn_info, needed, &needed);
3128 GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
3129 drv_info = malloc(needed);
3130 if(!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)drv_info, needed, &needed))
3131 {
3132 ERR("GetPrinterDriverA failed for %s, fix your config!\n", debugstr_w(prn_info->pPrinterName));
3133 goto end;
3134 }
3135 ClosePrinter(hprn);
3136
3137 needed = DocumentPropertiesW(0, 0, name, NULL, NULL, 0);
3138 if(needed == -1)
3139 {
3140 ERR("DocumentProperties fails on %s\n", debugstr_w(name));
3141 goto end;
3142 }
3143
3144 dm = malloc(needed);
3146
3149 prn_info->pPortName);
3150
3151 retval = TRUE;
3152end:
3153 free(dm);
3154 free(prn_info);
3155 free(drv_info);
3156 return retval;
3157}
3158
3159/****************************************************************************************
3160 * pagesetup_init_combos
3161 *
3162 * Fills Printers, Paper and Source combos
3163 *
3164 */
3166{
3167 DEVMODEW *dm;
3168 LPWSTR devname, portname;
3169
3171 devname = pagesetup_get_devname(data);
3172 portname = pagesetup_get_portname(data);
3173
3174 PRINTDLG_SetUpPrinterListComboW(hDlg, cmb1, devname);
3175 PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb2, devname, portname, dm);
3176 PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb3, devname, portname, dm);
3177
3181}
3182
3183
3184/****************************************************************************************
3185 * pagesetup_change_printer_dialog
3186 *
3187 * Pops up another dialog that lets the user pick another printer.
3188 *
3189 * For now we display the PrintDlg, this should display a striped down version of it.
3190 */
3192{
3193 PRINTDLGW prnt;
3194 LPWSTR drvname, devname, portname;
3195 DEVMODEW *tmp_dm, *dm;
3196
3197 memset(&prnt, 0, sizeof(prnt));
3198 prnt.lStructSize = sizeof(prnt);
3199 prnt.Flags = 0;
3200 prnt.hwndOwner = hDlg;
3201
3202 drvname = pagesetup_get_drvname(data);
3203 devname = pagesetup_get_devname(data);
3204 portname = pagesetup_get_portname(data);
3205 prnt.hDevNames = 0;
3206 PRINTDLG_CreateDevNamesW(&prnt.hDevNames, drvname, devname, portname);
3210
3211 tmp_dm = pagesetup_get_devmode(data);
3212 prnt.hDevMode = GlobalAlloc(GMEM_MOVEABLE, tmp_dm->dmSize + tmp_dm->dmDriverExtra);
3213 dm = GlobalLock(prnt.hDevMode);
3214 memcpy(dm, tmp_dm, tmp_dm->dmSize + tmp_dm->dmDriverExtra);
3215 GlobalUnlock(prnt.hDevMode);
3217
3218 if (PrintDlgW(&prnt))
3219 {
3220 DEVMODEW *dm = GlobalLock(prnt.hDevMode);
3221 DEVNAMES *dn = GlobalLock(prnt.hDevNames);
3222
3224 (WCHAR*)dn + dn->wDeviceOffset, (WCHAR *)dn + dn->wOutputOffset);
3226 GlobalUnlock(prnt.hDevNames);
3227 GlobalUnlock(prnt.hDevMode);
3229 }
3230
3231 GlobalFree(prnt.hDevMode);
3232 GlobalFree(prnt.hDevNames);
3233
3234}
3235
3236/******************************************************************************************
3237 * pagesetup_change_preview
3238 *
3239 * Changes paper preview size / position
3240 *
3241 */
3243{
3244 LONG width, height, x, y;
3245 RECT tmp;
3246 const int shadow = 4;
3247
3249 {
3250 width = data->rtDrawRect.right - data->rtDrawRect.left;
3252 }
3253 else
3254 {
3255 height = data->rtDrawRect.bottom - data->rtDrawRect.top;
3257 }
3258 x = (data->rtDrawRect.right + data->rtDrawRect.left - width) / 2;
3259 y = (data->rtDrawRect.bottom + data->rtDrawRect.top - height) / 2;
3260 TRACE("draw rect %s x=%ld, y=%ld, w=%ld, h=%ld\n",
3261 wine_dbgstr_rect(&data->rtDrawRect), x, y, width, height);
3262
3263 MoveWindow(GetDlgItem(data->hDlg, rct2), x + width, y + shadow, shadow, height, FALSE);
3264 MoveWindow(GetDlgItem(data->hDlg, rct3), x + shadow, y + height, width, shadow, FALSE);
3266
3267 tmp = data->rtDrawRect;
3268 tmp.right += shadow;
3269 tmp.bottom += shadow;
3270 InvalidateRect(data->hDlg, &tmp, TRUE);
3271}
3272
3273static inline LONG *element_from_margin_id(RECT *rc, WORD id)
3274{
3275 switch(id)
3276 {
3277 case edt4: return &rc->left;
3278 case edt5: return &rc->top;
3279 case edt6: return &rc->right;
3280 case edt7: return &rc->bottom;
3281 }
3282 return NULL;
3283}
3284
3285static void update_margin_edits(HWND hDlg, const pagesetup_data *data, WORD id)
3286{
3287 WCHAR str[100];
3288 WORD idx;
3289
3290 for(idx = edt4; idx <= edt7; idx++)
3291 {
3292 if(id == 0 || id == idx)
3293 {
3295 SetDlgItemTextW(hDlg, idx, str);
3296 }
3297 }
3298}
3299
3301{
3302 switch (msg)
3303 {
3304 case EN_CHANGE:
3305 {
3306 WCHAR buf[10];
3307 LONG val = 0;
3309
3310 if (GetDlgItemTextW(hDlg, id, buf, ARRAY_SIZE(buf)) != 0)
3311 {
3312 WCHAR *end;
3313 WCHAR decimal = get_decimal_sep();
3314
3315 val = wcstol(buf, &end, 10);
3316 if(end != buf || *end == decimal)
3317 {
3318 int mult = is_metric(data) ? 100 : 1000;
3319 val *= mult;
3320 if(*end == decimal)
3321 {
3322 while(mult > 1)
3323 {
3324 end++;
3325 mult /= 10;
3326 if(iswdigit(*end))
3327 val += (*end - '0') * mult;
3328 else
3329 break;
3330 }
3331 }
3332 }
3333 }
3334 *value = val;
3335 return;
3336 }
3337
3338 case EN_KILLFOCUS:
3339 update_margin_edits(hDlg, data, id);
3340 return;
3341 }
3342}
3343
3345{
3346 WCHAR title[256];
3347
3350 SetDlgItemTextW(hDlg, grp4, title);
3351}
3352
3354{
3356 CheckRadioButton(hDlg, rad1, rad2, rad2);
3357 else
3358 CheckRadioButton(hDlg, rad1, rad2, rad1);
3359}
3360
3361/****************************************************************************************
3362 * pagesetup_printer_properties
3363 *
3364 * Handle invocation of the 'Properties' button (not present in the default template).
3365 */
3367{
3368 HANDLE hprn;
3369 LPWSTR devname;
3370 DEVMODEW *dm;
3371 LRESULT count;
3372 int i;
3373
3374 devname = pagesetup_get_devname(data);
3375
3376 if (!OpenPrinterW(devname, &hprn, NULL))
3377 {
3378 FIXME("Call to OpenPrinter did not succeed!\n");
3380 return;
3381 }
3382
3384 DocumentPropertiesW(hDlg, hprn, devname, dm, dm, DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
3388 ClosePrinter(hprn);
3389
3390 /* Changing paper */
3393
3394 /* Changing paper preview */
3396
3397 /* Selecting paper in combo */
3398 count = SendDlgItemMessageW(hDlg, cmb2, CB_GETCOUNT, 0, 0);
3399 if(count != CB_ERR)
3400 {
3401 WORD paperword = pagesetup_get_papersize(data);
3402 for(i = 0; i < count; i++)
3403 {
3404 if(SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, i, 0) == paperword) {
3406 break;
3407 }
3408 }
3409 }
3410}
3411
3412/********************************************************************************
3413 * pagesetup_wm_command
3414 * process WM_COMMAND message for PageSetupDlg
3415 *
3416 * PARAMS
3417 * hDlg [in] Main dialog HANDLE
3418 * wParam [in] WM_COMMAND wParam
3419 * lParam [in] WM_COMMAND lParam
3420 * pda [in/out] ptr to PageSetupDataA
3421 */
3422
3424{
3425 WORD msg = HIWORD(wParam);
3426 WORD id = LOWORD(wParam);
3427
3428 TRACE("loword (lparam) %d, wparam 0x%Ix, lparam %08Ix\n",
3430 switch (id) {
3431 case IDOK:
3432 EndDialog(hDlg, TRUE);
3433 return TRUE ;
3434
3435 case IDCANCEL:
3436 EndDialog(hDlg, FALSE);
3437 return FALSE ;
3438
3439 case psh3: /* Printer... */
3441 return TRUE;
3442
3443 case rad1: /* Portrait */
3444 case rad2: /* Landscape */
3447 {
3451 update_margin_edits(hDlg, data, 0);
3453 }
3454 break;
3455 case cmb1: /* Printer combo */
3456 if(msg == CBN_SELCHANGE)
3457 {
3458 WCHAR *name;
3459 INT index = SendDlgItemMessageW(hDlg, id, CB_GETCURSEL, 0, 0);
3461 name = malloc(sizeof(WCHAR) * (length + 1));
3465 free(name);
3466 }
3467 break;
3468 case cmb2: /* Paper combo */
3469 if(msg == CBN_SELCHANGE)
3470 {
3471 DWORD paperword = SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA,
3472 SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0), 0);
3473 if (paperword != CB_ERR)
3474 {
3475 pagesetup_set_papersize(data, paperword);
3478 } else
3479 FIXME("could not get dialog text for papersize cmbbox?\n");
3480 }
3481 break;
3482 case cmb3: /* Paper Source */
3483 if(msg == CBN_SELCHANGE)
3484 {
3486 SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0), 0);
3488 }
3489 break;
3490 case psh2: /* Printer Properties button */
3492 break;
3493 case edt4:
3494 case edt5:
3495 case edt6:
3496 case edt7:
3497 margin_edit_notification(hDlg, data, msg, id);
3498 break;
3499 }
3501 return FALSE;
3502}
3503
3504/***********************************************************************
3505 * default_page_paint_hook
3506 * Default hook paint procedure that receives WM_PSD_* messages from the dialog box
3507 * whenever the sample page is redrawn.
3508 */
3510 const pagesetup_data *data)
3511{
3513 HDC hdc = (HDC) wParam;
3514 HPEN hpen, holdpen;
3515 LOGFONTW lf;
3516 HFONT hfont, holdfont;
3517 INT oldbkmode;
3518 TRACE("uMsg: WM_USER+%d\n",uMsg-WM_USER);
3519 /* Call user paint hook if enable */
3521 if (pagesetup_get_hook(data, page_paint_hook)(hwndDlg, uMsg, wParam, lParam))
3522 return TRUE;
3523
3524 switch (uMsg) {
3525 /* LPPAGESETUPDLG in lParam */
3527 /* Inform about the sample page rectangle */
3529 /* Inform about the margin rectangle */
3531 return FALSE;
3532
3533 /* Draw dashed rectangle showing margins */
3534 case WM_PSD_MARGINRECT:
3536 holdpen = SelectObject(hdc, hpen);
3538 DeleteObject(SelectObject(hdc, holdpen));
3539 return TRUE;
3540 /* Draw the fake document */
3542 /* select a nice scalable font, because we want the text really small */
3544 lf.lfHeight = 6; /* value chosen based on visual effect */
3546 holdfont = SelectObject(hdc, hfont);
3547
3548 /* if text not loaded, then do so now */
3549 if (wszFakeDocumentText[0] == '\0')
3554
3555 oldbkmode = SetBkMode(hdc, TRANSPARENT);
3557 SetBkMode(hdc, oldbkmode);
3558
3559 DeleteObject(SelectObject(hdc, holdfont));
3560 return TRUE;
3561
3562 /* Envelope stamp */
3564 /* Return address */
3566 FIXME("envelope/stamp is not implemented\n");
3567 return FALSE;
3568 default:
3569 FIXME("Unknown message %x\n",uMsg);
3570 return FALSE;
3571 }
3572 return TRUE;
3573}
3574
3575/***********************************************************************
3576 * PagePaintProc
3577 * The main paint procedure for the PageSetupDlg function.
3578 * The Page Setup dialog box includes an image of a sample page that shows how
3579 * the user's selections affect the appearance of the printed output.
3580 * The image consists of a rectangle that represents the selected paper
3581 * or envelope type, with a dotted-line rectangle representing
3582 * the current margins, and partial (Greek text) characters
3583 * to show how text looks on the printed page.
3584 *
3585 * The following messages in the order sends to user hook procedure:
3586 * WM_PSD_PAGESETUPDLG Draw the contents of the sample page
3587 * WM_PSD_FULLPAGERECT Inform about the bounding rectangle
3588 * WM_PSD_MINMARGINRECT Inform about the margin rectangle (min margin?)
3589 * WM_PSD_MARGINRECT Draw the margin rectangle
3590 * WM_PSD_GREEKTEXTRECT Draw the Greek text inside the margin rectangle
3591 * If any of first three messages returns TRUE, painting done.
3592 *
3593 * PARAMS:
3594 * hWnd [in] Handle to the Page Setup dialog box
3595 * uMsg [in] Received message
3596 *
3597 * TODO:
3598 * WM_PSD_ENVSTAMPRECT Draw in the envelope-stamp rectangle (for envelopes only)
3599 * WM_PSD_YAFULLPAGERECT Draw the return address portion (for envelopes and other paper sizes)
3600 *
3601 * RETURNS:
3602 * FALSE if all done correctly
3603 *
3604 */
3605
3606
3607static LRESULT CALLBACK
3609{
3610 PAINTSTRUCT ps;
3611 RECT rcClient, rcMargin;
3612 HPEN hpen, holdpen;
3613 HDC hdc;
3614 HBRUSH hbrush, holdbrush;
3616 int papersize=0, orientation=0; /* FIXME: set these values for the user paint hook */
3617 double scalx, scaly;
3618
3619 if (uMsg != WM_PAINT)
3621
3622 /* Processing WM_PAINT message */
3624 if (!data) {
3625 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
3626 return FALSE;
3627 }
3628 if (default_page_paint_hook(hWnd, WM_PSD_PAGESETUPDLG, MAKELONG(papersize, orientation),
3630 return FALSE;
3631
3632 hdc = BeginPaint(hWnd, &ps);
3633 GetClientRect(hWnd, &rcClient);
3634
3635 scalx = rcClient.right / (double)pagesetup_get_papersize_pt(data)->x;
3636 scaly = rcClient.bottom / (double)pagesetup_get_papersize_pt(data)->y;
3637 rcMargin = rcClient;
3638
3639 rcMargin.left += pagesetup_get_margin_rect(data)->left * scalx;
3640 rcMargin.top += pagesetup_get_margin_rect(data)->top * scaly;
3641 rcMargin.right -= pagesetup_get_margin_rect(data)->right * scalx;
3642 rcMargin.bottom -= pagesetup_get_margin_rect(data)->bottom * scaly;
3643
3644 /* if the space is too small then we make sure to not draw anything */
3645 rcMargin.left = min(rcMargin.left, rcMargin.right);
3646 rcMargin.top = min(rcMargin.top, rcMargin.bottom);
3647
3650 {
3651 /* fill background */
3653 FillRect(hdc, &rcClient, hbrush);
3654 holdbrush = SelectObject(hdc, hbrush);
3655
3657 holdpen = SelectObject(hdc, hpen);
3658
3659 /* paint left edge */
3660 MoveToEx(hdc, rcClient.left, rcClient.top, NULL);
3661 LineTo(hdc, rcClient.left, rcClient.bottom-1);
3662
3663 /* paint top edge */
3664 MoveToEx(hdc, rcClient.left, rcClient.top, NULL);
3665 LineTo(hdc, rcClient.right, rcClient.top);
3666
3669
3670 /* paint right edge */
3671 MoveToEx(hdc, rcClient.right-1, rcClient.top, NULL);
3672 LineTo(hdc, rcClient.right-1, rcClient.bottom);
3673
3674 /* paint bottom edge */
3675 MoveToEx(hdc, rcClient.left, rcClient.bottom-1, NULL);
3676 LineTo(hdc, rcClient.right, rcClient.bottom-1);
3677
3678 DeleteObject(SelectObject(hdc, holdpen));
3679 DeleteObject(SelectObject(hdc, holdbrush));
3680
3682
3683 /* give text a bit of a space from the frame */
3684 InflateRect(&rcMargin, -2, -2);
3685
3686 /* if the space is too small then we make sure to not draw anything */
3687 rcMargin.left = min(rcMargin.left, rcMargin.right);
3688 rcMargin.top = min(rcMargin.top, rcMargin.bottom);
3689
3691 }
3692
3693 EndPaint(hWnd, &ps);
3694 return FALSE;
3695}
3696
3697/*******************************************************
3698 * The margin edit controls are subclassed to filter
3699 * anything other than numbers and the decimal separator.
3700 */
3702{
3703 if (msg == WM_CHAR)
3704 {
3705 WCHAR decimal = get_decimal_sep();
3706 WCHAR wc = (WCHAR)wparam;
3707 if(!iswdigit(wc) && wc != decimal && wc != VK_BACK) return 0;
3708 }
3710}
3711
3713{
3714 int id;
3716
3717 for(id = edt4; id <= edt7; id++)
3718 {
3723 }
3724}
3725
3726/***********************************************************************
3727 * pagesetup_dlg_proc
3728 *
3729 * Message handler for PageSetupDlg
3730 */
3732{
3734 INT_PTR res = FALSE;
3735 HWND hDrawWnd;
3736
3737 if (uMsg == WM_INITDIALOG) { /*Init dialog*/
3739 data->hDlg = hDlg;
3740
3741 hDrawWnd = GetDlgItem(hDlg, rct1);
3742 TRACE("set property to %p\n", data);
3744 SetPropW(hDrawWnd, pagesetupdlg_prop, data);
3745 GetWindowRect(hDrawWnd, &data->rtDrawRect); /* Calculating rect in client coordinates where paper draws */
3746 MapWindowPoints( 0, hDlg, (LPPOINT)&data->rtDrawRect, 2 );
3748 hDrawWnd,
3751
3752 /* FIXME: Paint hook. Must it be at begin of initialization or at end? */
3753 res = TRUE;
3755 {
3756 if (!pagesetup_get_hook(data, page_setup_hook)(hDlg, uMsg, wParam,
3758 FIXME("Setup page hook failed?\n");
3759 }
3760
3761 /* if printer button disabled */
3764 /* if margin edit boxes disabled */
3766 {
3771 }
3772
3773 /* Set orientation radiobuttons properly */
3775
3776 /* if orientation disabled */
3778 {
3781 }
3782
3783 /* We fill them out enabled or not */
3785 {
3786 /* default is 1 inch */
3789 }
3790 update_margin_edits(hDlg, data, 0);
3793
3794 /* if paper disabled */
3796 {
3799 }
3800
3801 /* filling combos: printer, paper, source. selecting current printer (from DEVMODEA) */
3804 pagesetup_set_defaultsource(data, DMBIN_FORMSOURCE); /* FIXME: This is the auto select bin. Is this correct? */
3805
3806 /* Drawing paper prev */
3808 return TRUE;
3809 } else {
3811 if (!data)
3812 {
3813 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
3814 return FALSE;
3815 }
3817 {
3819 if (res) return res;
3820 }
3821 }
3822 switch (uMsg) {
3823 case WM_COMMAND:
3824 return pagesetup_wm_command(hDlg, wParam, lParam, data);
3825 }
3826 return FALSE;
3827}
3828
3830{
3831 WCHAR *name = NULL;
3832 DWORD len = 0;
3833
3835 if(len)
3836 {
3837 name = malloc(len * sizeof(WCHAR));
3839 }
3840 return name;
3841}
3842
3844{
3845 if(TRACE_ON(commdlg))
3846 {
3847 char flagstr[1000] = "";
3848 const struct pd_flags *pflag = psd_flags;
3849 for( ; pflag->name; pflag++)
3850 {
3851 if(pagesetup_get_flags(data) & pflag->flag)
3852 {
3853 strcat(flagstr, pflag->name);
3854 strcat(flagstr, "|");
3855 }
3856 }
3857 TRACE("%s: (%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
3858 "hinst %p, flags %08lx (%s)\n",
3859 data->unicode ? "unicode" : "ansi",
3860 data->u.dlgw, data->u.dlgw->hwndOwner, data->u.dlgw->hDevMode,
3861 data->u.dlgw->hDevNames, data->u.dlgw->hInstance,
3862 pagesetup_get_flags(data), flagstr);
3863 }
3864}
3865
3867{
3868 HRSRC res;
3869 HGLOBAL tmpl_handle;
3870
3872 {
3873 tmpl_handle = data->u.dlgw->hPageSetupTemplate;
3874 }
3876 {
3877 if(data->unicode)
3878 res = FindResourceW(data->u.dlgw->hInstance,
3879 data->u.dlgw->lpPageSetupTemplateName, (LPWSTR)RT_DIALOG);
3880 else
3881 res = FindResourceA(data->u.dlga->hInstance,
3882 data->u.dlga->lpPageSetupTemplateName, (LPSTR)RT_DIALOG);
3883 tmpl_handle = LoadResource(data->u.dlgw->hInstance, res);
3884 }
3885 else
3886 {
3888 (LPWSTR)RT_DIALOG);
3889 tmpl_handle = LoadResource(COMDLG32_hInstance, res);
3890 }
3891 return LockResource(tmpl_handle);
3892}
3893
3895{
3896 BOOL ret;
3897 void *tmpl;
3898
3900 {
3902 return FALSE;
3903 }
3904
3906
3907 if(data->u.dlgw->lStructSize != sizeof(PAGESETUPDLGW))
3908 {
3910 return FALSE;
3911 }
3912
3915 {
3917 return FALSE;
3918 }
3919
3921 data->u.dlgw->Flags |= is_default_metric() ?
3923
3924 if (!data->u.dlgw->hDevMode || !data->u.dlgw->hDevNames)
3925 {
3926 WCHAR *def = get_default_printer();
3927 if(!def)
3928 {
3930 {
3931 WCHAR errstr[256];
3933 MessageBoxW(data->u.dlgw->hwndOwner, errstr, 0, MB_OK | MB_ICONERROR);
3934 }
3936 return FALSE;
3937 }
3939 free(def);
3940 }
3941
3943 {
3945 return TRUE;
3946 }
3947
3949
3950 ret = DialogBoxIndirectParamW(data->u.dlgw->hInstance, tmpl,
3951 data->u.dlgw->hwndOwner,
3953 return ret;
3954}
3955
3956/***********************************************************************
3957 * PageSetupDlgA (COMDLG32.@)
3958 *
3959 * Displays the PAGE SETUP dialog box, which enables the user to specify
3960 * specific properties of a printed page such as
3961 * size, source, orientation and the width of the page margins.
3962 *
3963 * PARAMS
3964 * setupdlg [IO] PAGESETUPDLGA struct
3965 *
3966 * RETURNS
3967 * TRUE if the user pressed the OK button
3968 * FALSE if the user cancelled the window or an error occurred
3969 *
3970 * NOTES
3971 * The values of hDevMode and hDevNames are filled on output and can be
3972 * changed in PAGESETUPDLG when they are passed in PageSetupDlg.
3973 *
3974 */
3976{
3978
3979 data.unicode = FALSE;
3980 data.u.dlga = setupdlg;
3981
3982 return pagesetup_common(&data);
3983}
3984
3985/***********************************************************************
3986 * PageSetupDlgW (COMDLG32.@)
3987 *
3988 * See PageSetupDlgA.
3989 */
3991{
3993
3994 data.unicode = TRUE;
3995 data.u.dlgw = setupdlg;
3996
3997 return pagesetup_common(&data);
3998}
3999
4000static void pdlgex_to_pdlg(const PRINTDLGEXW *pdlgex, PRINTDLGW *pdlg)
4001{
4002 pdlg->lStructSize = sizeof(*pdlg);
4003 pdlg->hwndOwner = pdlgex->hwndOwner;
4004 pdlg->hDevMode = pdlgex->hDevMode;
4005 pdlg->hDevNames = pdlgex->hDevNames;
4006 pdlg->hDC = pdlgex->hDC;
4007 pdlg->Flags = pdlgex->Flags;
4008 if ((pdlgex->Flags & PD_NOPAGENUMS) || !pdlgex->nPageRanges || !pdlgex->lpPageRanges)
4009 {
4010 pdlg->nFromPage = 0;
4011 pdlg->nToPage = 65534;
4012 }
4013 else
4014 {
4015 pdlg->nFromPage = pdlgex->lpPageRanges[0].nFromPage;
4016 pdlg->nToPage = pdlgex->lpPageRanges[0].nToPage;
4017 }
4018 pdlg->nMinPage = pdlgex->nMinPage;
4019 pdlg->nMaxPage = pdlgex->nMaxPage;
4020 pdlg->nCopies = pdlgex->nCopies;
4021 pdlg->hInstance = pdlgex->hInstance;
4022 pdlg->lCustData = 0;
4023 pdlg->lpfnPrintHook = NULL;
4024 pdlg->lpfnSetupHook = NULL;
4025 pdlg->lpPrintTemplateName = pdlgex->lpPrintTemplateName;
4026 pdlg->lpSetupTemplateName = NULL;
4027 pdlg->hPrintTemplate = NULL;
4028 pdlg->hSetupTemplate = NULL;
4029}
4030
4031/* Only copy fields that are supposed to be changed. */
4032static void pdlg_to_pdlgex(const PRINTDLGW *pdlg, PRINTDLGEXW *pdlgex)
4033{
4034 pdlgex->hDevMode = pdlg->hDevMode;
4035 pdlgex->hDevNames = pdlg->hDevNames;
4036 pdlgex->hDC = pdlg->hDC;
4037 if (!(pdlgex->Flags & PD_NOPAGENUMS) && pdlgex->nPageRanges && pdlgex->lpPageRanges)
4038 {
4039 pdlgex->lpPageRanges[0].nFromPage = pdlg->nFromPage;
4040 pdlgex->lpPageRanges[0].nToPage = pdlg->nToPage;
4041 }
4042 pdlgex->nMinPage = pdlg->nMinPage;
4043 pdlgex->nMaxPage = pdlg->nMaxPage;
4044 pdlgex->nCopies = pdlg->nCopies;
4045}
4046
4048{
4049 IPrintDialogCallback *callback;
4051};
4052
4054{
4055 if (msg == WM_INITDIALOG)
4056 {
4057 PRINTDLGW *pd = (PRINTDLGW *)lp;
4058 struct callback_data *cb = (struct callback_data *)pd->lCustData;
4059
4060 if (cb->callback)
4061 {
4062 cb->callback->lpVtbl->SelectionChange(cb->callback);
4063 cb->callback->lpVtbl->InitDone(cb->callback);
4064 }
4065 }
4066 else
4067 {
4068/* FIXME: store interface pointer somewhere in window properties and call it
4069 HRESULT hres;
4070 cb->callback->lpVtbl->HandleMessage(cb->callback, hwnd, msg, wp, lp, &hres);
4071*/
4072 }
4073
4074 return 0;
4075}
4076
4077/***********************************************************************
4078 * PrintDlgExA (COMDLG32.@)
4079 *
4080 * See PrintDlgExW.
4081 *
4082 * BUGS
4083 * Only a Stub
4084 *
4085 */
4086HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
4087{
4089 DRIVER_INFO_3A *dbuf;
4090 DEVMODEA *dm;
4091 HRESULT hr = S_OK;
4092 HANDLE hprn;
4093
4094 if ((lppd == NULL) || (lppd->lStructSize != sizeof(PRINTDLGEXA)))
4095 return E_INVALIDARG;
4096
4097 if (!IsWindow(lppd->hwndOwner))
4098 return E_HANDLE;
4099
4100 if (lppd->nStartPage != START_PAGE_GENERAL)
4101 {
4102 if (!lppd->nPropertyPages)
4103 return E_INVALIDARG;
4104
4105 FIXME("custom property sheets (%ld at %p) not supported\n", lppd->nPropertyPages, lppd->lphPropertyPages);
4106 }
4107
4108 /* Use PD_NOPAGENUMS or set nMaxPageRanges and lpPageRanges */
4109 if (!(lppd->Flags & PD_NOPAGENUMS) && (!lppd->nMaxPageRanges || !lppd->lpPageRanges))
4110 {
4111 return E_INVALIDARG;
4112 }
4113
4114 if (lppd->Flags & PD_RETURNDEFAULT)
4115 {
4116 if (lppd->hDevMode || lppd->hDevNames)
4117 {
4118 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
4120 return E_INVALIDARG;
4121 }
4122 if (!PRINTDLG_OpenDefaultPrinter(&hprn))
4123 {
4124 WARN("Can't find default printer\n");
4126 return E_FAIL;
4127 }
4128
4129 pbuf = get_printer_infoA(hprn);
4130 if (!pbuf)
4131 {
4132 ClosePrinter(hprn);
4133 return E_FAIL;
4134 }
4135
4136 dbuf = get_driver_infoA(hprn);
4137 if (!dbuf)
4138 {
4139 free(pbuf);
4141 ClosePrinter(hprn);
4142 return E_FAIL;
4143 }
4144 dm = pbuf->pDevMode;
4145 }
4146 else
4147 {
4148 PRINTDLGA pdlg;
4149 struct callback_data cb_data = { 0 };
4150
4151 FIXME("(%p) semi-stub\n", lppd);
4152
4153 if (lppd->lpCallback)
4154 {
4155 IUnknown_QueryInterface((IUnknown *)lppd->lpCallback, &IID_IPrintDialogCallback, (void **)&cb_data.callback);
4156 IUnknown_QueryInterface((IUnknown *)lppd->lpCallback, &IID_IObjectWithSite, (void **)&cb_data.object);
4157 }
4158
4159 /*
4160 * PRINTDLGEXA/W and PRINTDLGA/W layout is the same for A and W variants.
4161 */
4162 pdlgex_to_pdlg((const PRINTDLGEXW *)lppd, (PRINTDLGW *)&pdlg);
4163 pdlg.Flags |= PD_ENABLEPRINTHOOK;
4165 pdlg.lCustData = (LPARAM)&cb_data;
4166
4167 if (PrintDlgA(&pdlg))
4168 {
4169 pdlg_to_pdlgex((const PRINTDLGW *)&pdlg, (PRINTDLGEXW *)lppd);
4170 lppd->dwResultAction = PD_RESULT_PRINT;
4171 }
4172 else
4173 lppd->dwResultAction = PD_RESULT_CANCEL;
4174
4175 if (cb_data.callback)
4176 cb_data.callback->lpVtbl->Release(cb_data.callback);
4177 if (cb_data.object)
4178 cb_data.object->lpVtbl->Release(cb_data.object);
4179
4180 return S_OK;
4181 }
4182
4183 ClosePrinter(hprn);
4184
4185 PRINTDLG_CreateDevNames(&(lppd->hDevNames), dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName);
4186 if (!lppd->hDevNames)
4187 hr = E_FAIL;
4188
4189 lppd->hDevMode = update_devmode_handleA(lppd->hDevMode, dm);
4190 if (hr == S_OK && lppd->hDevMode) {
4191 if (lppd->Flags & PD_RETURNDC) {
4192 lppd->hDC = CreateDCA(dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName, dm);
4193 if (!lppd->hDC)
4194 hr = E_FAIL;
4195 }
4196 else if (lppd->Flags & PD_RETURNIC) {
4197 lppd->hDC = CreateICA(dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName, dm);
4198 if (!lppd->hDC)
4199 hr = E_FAIL;
4200 }
4201 }
4202 else
4203 hr = E_FAIL;
4204
4205 free(pbuf);
4206 free(dbuf);
4207
4208 return hr;
4209}
4210
4211/***********************************************************************
4212 * PrintDlgExW (COMDLG32.@)
4213 *
4214 * Display the property sheet style PRINT dialog box
4215 *
4216 * PARAMS
4217 * lppd [IO] ptr to PRINTDLGEX struct
4218 *
4219 * RETURNS
4220 * Success: S_OK
4221 * Failure: One of the following COM error codes:
4222 * E_OUTOFMEMORY Insufficient memory.
4223 * E_INVALIDARG One or more arguments are invalid.
4224 * E_POINTER Invalid pointer.
4225 * E_HANDLE Invalid handle.
4226 * E_FAIL Unspecified error.
4227 *
4228 * NOTES
4229 * This Dialog enables the user to specify specific properties of the print job.
4230 * The property sheet can also have additional application-specific and
4231 * driver-specific property pages.
4232 *
4233 * BUGS
4234 * Not fully implemented
4235 *
4236 */
4237HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
4238{
4240 DRIVER_INFO_3W *dbuf;
4241 DEVMODEW *dm;
4242 HRESULT hr = S_OK;
4243 HANDLE hprn;
4244
4245 if ((lppd == NULL) || (lppd->lStructSize != sizeof(PRINTDLGEXW))) {
4246 return E_INVALIDARG;
4247 }
4248
4249 if (!IsWindow(lppd->hwndOwner)) {
4250 return E_HANDLE;
4251 }
4252
4253 if (lppd->nStartPage != START_PAGE_GENERAL)
4254 {
4255 if (!lppd->nPropertyPages)
4256 return E_INVALIDARG;
4257
4258 FIXME("custom property sheets (%ld at %p) not supported\n", lppd->nPropertyPages, lppd->lphPropertyPages);
4259 }
4260
4261 /* Use PD_NOPAGENUMS or set nMaxPageRanges and lpPageRanges */
4262 if (!(lppd->Flags & PD_NOPAGENUMS) && (!lppd->nMaxPageRanges || !lppd->lpPageRanges))
4263 {
4264 return E_INVALIDARG;
4265 }
4266
4267 if (lppd->Flags & PD_RETURNDEFAULT) {
4268
4269 if (lppd->hDevMode || lppd->hDevNames) {
4270 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");
4272 return E_INVALIDARG;
4273 }
4274 if (!PRINTDLG_OpenDefaultPrinter(&hprn)) {
4275 WARN("Can't find default printer\n");
4277 return E_FAIL;
4278 }
4279
4280 pbuf = get_printer_infoW(hprn);
4281 if (!pbuf)
4282 {
4283 ClosePrinter(hprn);
4284 return E_FAIL;
4285 }
4286
4287 dbuf = get_driver_infoW(hprn);
4288 if (!dbuf)
4289 {
4290 free(pbuf);
4292 ClosePrinter(hprn);
4293 return E_FAIL;
4294 }
4295 dm = pbuf->pDevMode;
4296 }
4297 else
4298 {
4299 PRINTDLGW pdlg;
4300 struct callback_data cb_data = { 0 };
4301
4302 FIXME("(%p) semi-stub\n", lppd);
4303
4304 if (lppd->lpCallback)
4305 {
4306 IUnknown_QueryInterface((IUnknown *)lppd->lpCallback, &IID_IPrintDialogCallback, (void **)&cb_data.callback);
4307 IUnknown_QueryInterface((IUnknown *)lppd->lpCallback, &IID_IObjectWithSite, (void **)&cb_data.object);
4308 }
4309
4310 pdlgex_to_pdlg(lppd, &pdlg);
4311 pdlg.Flags |= PD_ENABLEPRINTHOOK;
4313 pdlg.lCustData = (LPARAM)&cb_data;
4314
4315 if (PrintDlgW(&pdlg))
4316 {
4317 pdlg_to_pdlgex(&pdlg, lppd);
4318 lppd->dwResultAction = PD_RESULT_PRINT;
4319 }
4320 else
4321 lppd->dwResultAction = PD_RESULT_CANCEL;
4322
4323 if (cb_data.callback)
4324 cb_data.callback->lpVtbl->Release(cb_data.callback);
4325 if (cb_data.object)
4326 cb_data.object->lpVtbl->Release(cb_data.object);
4327
4328 return S_OK;
4329 }
4330
4331 ClosePrinter(hprn);
4332
4333 PRINTDLG_CreateDevNamesW(&(lppd->hDevNames), dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName);
4334 if (!lppd->hDevNames)
4335 hr = E_FAIL;
4336
4337 lppd->hDevMode = update_devmode_handleW(lppd->hDevMode, dm);
4338 if (hr == S_OK && lppd->hDevMode) {
4339 if (lppd->Flags & PD_RETURNDC) {
4340 lppd->hDC = CreateDCW(dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName, dm);
4341 if (!lppd->hDC)
4342 hr = E_FAIL;
4343 }
4344 else if (lppd->Flags & PD_RETURNIC) {
4345 lppd->hDC = CreateICW(dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName, dm);
4346 if (!lppd->hDC)
4347 hr = E_FAIL;
4348 }
4349 }
4350 else
4351 hr = E_FAIL;
4352
4353 free(pbuf);
4354 free(dbuf);
4355
4356 return hr;
4357}
static UNICODE_STRING PortName
static HFONT hfont
static HBRUSH hbrush
static HPEN hpen
PWSTR Names[]
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define PDERR_RETDEFFAILURE
Definition: cderr.h:21
#define CDERR_REGISTERMSGFAIL
Definition: cderr.h:17
#define PDERR_NODEFAULTPRN
Definition: cderr.h:26
#define CDERR_NOHOOK
Definition: cderr.h:16
#define CDERR_INITIALIZATION
Definition: cderr.h:7
#define CDERR_LOADRESFAILURE
Definition: cderr.h:12
#define CDERR_STRUCTSIZE
Definition: cderr.h:6
#define PD32_NO_DEVICES
Definition: cdlg.h:65
#define PD32_NO_DEFAULT_PRINTER
Definition: cdlg.h:60
#define PD32_MARGINS_IN_MILLIMETERS
Definition: cdlg.h:98
#define PD32_PRINTER_STATUS_PAUSED
Definition: cdlg.h:68
#define PD32_INVALID_PAGE_RANGE
Definition: cdlg.h:54
void COMDLG32_SetCommDlgExtendedError(DWORD err)
Definition: cdlg32.c:124
#define PD32_PRINT_TITLE
Definition: cdlg.h:51
HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
#define PD32_PRINTER_STATUS_READY
Definition: cdlg.h:67
#define PD32_MARGINS_IN_INCHES
Definition: cdlg.h:97
#define IDS_FAKEDOCTEXT
Definition: cdlg.h:164
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HWND WINAPI CreateUpDownControl(DWORD style, INT x, INT y, INT cx, INT cy, HWND parent, INT id, HINSTANCE inst, HWND buddy, INT maxVal, INT minVal, INT curVal)
Definition: commctrl.c:840
#define PSD_ENABLEPAGESETUPHOOK
Definition: commdlg.h:183
#define PSD_SHOWHELP
Definition: commdlg.h:182
#define PD_NONETWORKBUTTON
Definition: commdlg.h:169
struct tagDEVNAMES * LPDEVNAMES
#define PSD_ENABLEPAGESETUPTEMPLATE
Definition: commdlg.h:184
#define PSD_MARGINS
Definition: commdlg.h:173
#define PD_ENABLEPRINTTEMPLATEHANDLE
Definition: commdlg.h:163
#define PSD_DISABLEORIENTATION
Definition: commdlg.h:179
#define PD_ENABLESETUPTEMPLATE
Definition: commdlg.h:162
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
#define PD_RESULT_CANCEL
Definition: commdlg.h:201
#define PSD_MINMARGINS
Definition: commdlg.h:172
#define PD_NOSELECTION
Definition: commdlg.h:149
#define PD_RETURNIC
Definition: commdlg.h:156
#define PSD_INTHOUSANDTHSOFINCHES
Definition: commdlg.h:174
#define PD_SELECTION
Definition: commdlg.h:147
#define START_PAGE_GENERAL
Definition: commdlg.h:205
#define WM_PSD_MINMARGINRECT
Definition: commdlg.h:190
#define PD_ENABLESETUPTEMPLATEHANDLE
Definition: commdlg.h:164
#define PD_USEDEVMODECOPIES
Definition: commdlg.h:165
#define HELPMSGSTRINGW
Definition: commdlg.h:27
#define PD_RETURNDC
Definition: commdlg.h:155
#define PD_ENABLEPRINTHOOK
Definition: commdlg.h:159
__CDHOOKPROC LPPAGESETUPHOOK
Definition: commdlg.h:235
#define WM_PSD_MARGINRECT
Definition: commdlg.h:191
#define PD_RETURNDEFAULT
Definition: commdlg.h:157
#define PSD_DISABLEPRINTER
Definition: commdlg.h:177
#define PSD_DISABLEMARGINS
Definition: commdlg.h:176
#define PD_PRINTTOFILE
Definition: commdlg.h:152
#define PSD_RETURNDEFAULT
Definition: commdlg.h:181
#define PD_COLLATE
Definition: commdlg.h:151
#define WM_PSD_ENVSTAMPRECT
Definition: commdlg.h:193
#define PD_ENABLESETUPHOOK
Definition: commdlg.h:160
#define PSD_DISABLEPAPER
Definition: commdlg.h:180
#define PD_NOWARNING
Definition: commdlg.h:154
#define PSD_NOWARNING
Definition: commdlg.h:178
#define PSD_ENABLEPAGEPAINTHOOK
Definition: commdlg.h:186
#define PD_DISABLEPRINTTOFILE
Definition: commdlg.h:167
#define PD_RESULT_PRINT
Definition: commdlg.h:202
#define PSD_DISABLEPAGEPAINTING
Definition: commdlg.h:187
#define WM_PSD_PAGESETUPDLG
Definition: commdlg.h:188
#define WM_PSD_YAFULLPAGERECT
Definition: commdlg.h:194
#define PSD_INHUNDREDTHSOFMILLIMETERS
Definition: commdlg.h:175
#define PD_PAGENUMS
Definition: commdlg.h:148
#define PD_SHOWHELP
Definition: commdlg.h:158
struct tagDEVNAMES DEVNAMES
#define WM_PSD_FULLPAGERECT
Definition: commdlg.h:189
#define PSD_ENABLEPAGESETUPTEMPLATEHANDLE
Definition: commdlg.h:185
#define HELPMSGSTRINGA
Definition: commdlg.h:20
#define PD_PRINTSETUP
Definition: commdlg.h:153
#define PD_HIDEPRINTTOFILE
Definition: commdlg.h:168
#define PD_NOPAGENUMS
Definition: commdlg.h:150
#define PD_ENABLEPRINTTEMPLATE
Definition: commdlg.h:161
#define WM_PSD_GREEKTEXTRECT
Definition: commdlg.h:192
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
#define cmb1
Definition: dlgs.h:53
#define edt7
Definition: dlgs.h:76
#define stc2
Definition: dlgs.h:166
#define stc14
Definition: dlgs.h:178
#define rad3
Definition: dlgs.h:137
#define psh1
Definition: dlgs.h:117
#define ico3
Definition: dlgs.h:97
#define pshHelp
Definition: dlgs.h:132
#define stc5
Definition: dlgs.h:169
#define rct1
Definition: dlgs.h:152
#define psh2
Definition: dlgs.h:118
#define rad2
Definition: dlgs.h:136
#define edt1
Definition: dlgs.h:70
#define cmb3
Definition: dlgs.h:55
#define psh3
Definition: dlgs.h:119
#define stc10
Definition: dlgs.h:174
#define cmb4
Definition: dlgs.h:56
#define stc11
Definition: dlgs.h:175
#define grp4
Definition: dlgs.h:94
#define stc1
Definition: dlgs.h:165
#define edt6
Definition: dlgs.h:75
#define rct3
Definition: dlgs.h:154
#define rct2
Definition: dlgs.h:153
#define edt2
Definition: dlgs.h:71
#define stc13
Definition: dlgs.h:177
#define chx1
Definition: dlgs.h:36
#define chx2
Definition: dlgs.h:37
#define stc12
Definition: dlgs.h:176
#define cmb2
Definition: dlgs.h:54
#define stc3
Definition: dlgs.h:167
#define edt4
Definition: dlgs.h:73
#define rad1
Definition: dlgs.h:135
#define edt5
Definition: dlgs.h:74
#define edt3
Definition: dlgs.h:72
#define ico1
Definition: dlgs.h:95
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:40
static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, const char *DeviceDriverName, const char *DeviceName, const char *OutputPort)
Definition: printdlg.c:457
hook_type
Definition: printdlg.c:3009
@ page_paint_hook
Definition: printdlg.c:3011
@ page_setup_hook
Definition: printdlg.c:3010
static PRINTER_INFO_2W * get_printer_infoW(HANDLE hprn)
Definition: printdlg.c:199
static void pagesetup_dump_dlg_struct(const pagesetup_data *data)
Definition: printdlg.c:3843
static DEVMODEW * pagesetup_get_devmode(const pagesetup_data *data)
Definition: printdlg.c:2944
devnames_name
Definition: printdlg.c:2820
@ devnames_driver_name
Definition: printdlg.c:2821
@ devnames_output_name
Definition: printdlg.c:2823
@ devnames_device_name
Definition: printdlg.c:2822
static LPARAM pagesetup_get_dlg_struct(const pagesetup_data *data)
Definition: printdlg.c:3026
static void set_margin_groupbox_title(HWND hDlg, const pagesetup_data *data)
Definition: printdlg.c:3344
#define UPDOWN_ID
Definition: printdlg.c:50
HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
Definition: printdlg.c:4237
static void * pagesetup_get_template(pagesetup_data *data)
Definition: printdlg.c:3866
static BOOL PRINTDLG_CreateDCA(LPPRINTDLGA lppd)
Definition: printdlg.c:2249
static WNDPROC lpfnStaticWndProc
Definition: printdlg.c:138
static INT_PTR CALLBACK PrintDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: printdlg.c:2127
static BOOL PRINTDLG_UpdatePrintDlgA(HWND hDlg, PRINT_PTRA *PrintStructures)
Definition: printdlg.c:575
static void swap_point(POINT *pt)
Definition: printdlg.c:3031
static BOOL is_metric(const pagesetup_data *data)
Definition: printdlg.c:2653
static WCHAR wszFakeDocumentText[1024]
Definition: printdlg.c:141
static void subclass_margin_edits(HWND hDlg)
Definition: printdlg.c:3712
static void pagesetup_change_preview(const pagesetup_data *data)
Definition: printdlg.c:3242
static WCHAR * get_default_printer(void)
Definition: printdlg.c:3829
static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam, PRINT_PTRW *PrintStructures)
Definition: printdlg.c:1917
static void rotate_rect(RECT *rc, BOOL sense)
Definition: printdlg.c:2722
static void pagesetup_init_combos(HWND hDlg, pagesetup_data *data)
Definition: printdlg.c:3165
static void pdlg_to_pdlgex(const PRINTDLGW *pdlg, PRINTDLGEXW *pdlgex)
Definition: printdlg.c:4032
static BOOL PRINTDLG_UpdatePrintDlgW(HWND hDlg, PRINT_PTRW *PrintStructures)
Definition: printdlg.c:678
static LPPAGESETUPHOOK pagesetup_get_hook(const pagesetup_data *data, hook_type which)
Definition: printdlg.c:3014
static INT_PTR CALLBACK PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: printdlg.c:2078
static void update_margin_edits(HWND hDlg, const pagesetup_data *data, WORD id)
Definition: printdlg.c:3285
static void pagesetup_set_devmode(pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2968
static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, PRINT_PTRA *PrintStructures)
Definition: printdlg.c:1540
static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg, DWORD flags, const PRINTER_INFO_2W *pi)
Definition: printdlg.c:1048
static BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, PRINT_PTRA *PrintStructures)
Definition: printdlg.c:1100
static const WCHAR printdlg_prop[]
Definition: printdlg.c:142
HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
Definition: printdlg.c:4086
static LONG tenths_mm_to_size(const pagesetup_data *data, LONG size)
Definition: printdlg.c:2658
static void margin_edit_notification(HWND hDlg, const pagesetup_data *data, WORD msg, WORD id)
Definition: printdlg.c:3300
static INT PRINTDLG_SetUpPrinterListComboW(HWND hDlg, UINT id, LPCWSTR name)
Definition: printdlg.c:411
static BOOL pagesetup_wm_command(HWND hDlg, WPARAM wParam, LPARAM lParam, pagesetup_data *data)
Definition: printdlg.c:3423
static DRIVER_INFO_3W * get_driver_infoW(HANDLE hprn)
Definition: printdlg.c:152
static DEVMODEA * convert_to_devmodeA(const DEVMODEW *dmW)
Definition: printdlg.c:306
static const struct pd_flags psd_flags[]
Definition: printdlg.c:92
static UINT_PTR default_page_paint_hook(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, const pagesetup_data *data)
Definition: printdlg.c:3509
static void pagesetup_set_devnames(pagesetup_data *data, LPCWSTR drv, LPCWSTR devname, LPCWSTR port)
Definition: printdlg.c:2877
static BOOL is_default_metric(void)
Definition: printdlg.c:2708
static void pagesetup_release_a_devname(const pagesetup_data *data, WCHAR *name)
Definition: printdlg.c:2872
static UINT_PTR CALLBACK pdlgex_hook_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: printdlg.c:4053
static BOOL PRINTDLG_CreateDCW(LPPRINTDLGW lppd)
Definition: printdlg.c:2270
static RECT * pagesetup_get_margin_rect(const pagesetup_data *data)
Definition: printdlg.c:3003
static WCHAR * pagesetup_get_drvname(const pagesetup_data *data)
Definition: printdlg.c:2857
static POINT * pagesetup_get_papersize_pt(const pagesetup_data *data)
Definition: printdlg.c:2998
BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg)
Definition: printdlg.c:3975
static void pagesetup_update_orientation_buttons(HWND hDlg, const pagesetup_data *data)
Definition: printdlg.c:3353
static BOOL PRINTDLG_ChangePrinterW(HWND hDlg, WCHAR *name, PRINT_PTRW *PrintStructures)
Definition: printdlg.c:1306
static INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name)
Definition: printdlg.c:375
static WCHAR * pagesetup_get_portname(const pagesetup_data *data)
Definition: printdlg.c:2867
static void pagesetup_release_devmode(const pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2963
static DWORD pagesetup_get_flags(const pagesetup_data *data)
Definition: printdlg.c:2648
static LONG thousandths_inch_to_size(const pagesetup_data *data, LONG size)
Definition: printdlg.c:2666
static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg, DWORD flags, const PRINTER_INFO_2A *pi)
Definition: printdlg.c:1000
static const WCHAR pagesetupdlg_prop[]
Definition: printdlg.c:143
static WORD pagesetup_get_orientation(const pagesetup_data *data)
Definition: printdlg.c:2759
static void pagesetup_printer_properties(HWND hDlg, pagesetup_data *data)
Definition: printdlg.c:3366
BOOL WINAPI PrintDlgW(LPPRINTDLGW lppd)
Definition: printdlg.c:2460
static WORD get_devname_offset(const DEVNAMES *dn, devnames_name which)
Definition: printdlg.c:2827
static void pagesetup_set_papersize(pagesetup_data *data, WORD paper)
Definition: printdlg.c:2775
static HGLOBAL update_devmode_handleA(HGLOBAL hdm, DEVMODEA *dm)
Definition: printdlg.c:273
static BOOL pagesetup_change_printer(LPWSTR name, pagesetup_data *data)
Definition: printdlg.c:3110
BOOL WINAPI PageSetupDlgW(LPPAGESETUPDLGW setupdlg)
Definition: printdlg.c:3990
static BOOL pagesetup_update_papersize(pagesetup_data *data)
Definition: printdlg.c:3038
static BOOL PRINTDLG_OpenDefaultPrinter(HANDLE *hprn)
Definition: printdlg.c:349
static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg, int nIDComboBox, const WCHAR *PrinterName, const WCHAR *PortName, LPDEVMODEW dm)
Definition: printdlg.c:886
static void size2str(const pagesetup_data *data, DWORD size, LPWSTR strout)
Definition: printdlg.c:2687
static LRESULT CALLBACK PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: printdlg.c:3608
static BOOL pagesetup_common(pagesetup_data *data)
Definition: printdlg.c:3894
static void pagesetup_set_defaultsource(pagesetup_data *data, WORD source)
Definition: printdlg.c:2805
static WNDPROC edit_wndproc
Definition: printdlg.c:139
static LONG * element_from_margin_id(RECT *rc, WORD id)
Definition: printdlg.c:3273
static WCHAR * pagesetup_get_a_devname(const pagesetup_data *data, devnames_name which)
Definition: printdlg.c:2839
static INT_PTR CALLBACK pagesetup_dlg_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: printdlg.c:3731
#define MAX_COPIES
Definition: printdlg.c:51
static WORD pagesetup_get_papersize(const pagesetup_data *data)
Definition: printdlg.c:2789
static LRESULT check_printer_setup(HWND hDlg)
Definition: printdlg.c:1516
static LRESULT CALLBACK pagesetup_margin_editproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: printdlg.c:3701
static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg, PRINT_PTRW *PrintStructures)
Definition: printdlg.c:1648
static void pagesetup_set_orientation(pagesetup_data *data, WORD orient)
Definition: printdlg.c:2743
static WCHAR get_decimal_sep(void)
Definition: printdlg.c:2674
static void pagesetup_change_printer_dialog(HWND hDlg, pagesetup_data *data)
Definition: printdlg.c:3191
static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg, int nIDComboBox, char *PrinterName, char *PortName, LPDEVMODEA dm)
Definition: printdlg.c:777
static void pdlgex_to_pdlg(const PRINTDLGEXW *pdlgex, PRINTDLGW *pdlg)
Definition: printdlg.c:4000
static LRESULT PRINTDLG_WMCommandA(HWND hDlg, WPARAM wParam, PRINT_PTRA *PrintStructures)
Definition: printdlg.c:1760
static HGLOBAL PRINTDLG_GetDlgTemplateA(const PRINTDLGA *lppd)
Definition: printdlg.c:2178
static PRINTER_INFO_2A * get_printer_infoA(HANDLE hprn)
Definition: printdlg.c:219
BOOL WINAPI PrintDlgA(LPPRINTDLGA lppd)
Definition: printdlg.c:2310
static HGLOBAL update_devmode_handleW(HGLOBAL hdm, DEVMODEW *dm)
Definition: printdlg.c:245
static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName, LPCWSTR DeviceName, LPCWSTR OutputPort)
Definition: printdlg.c:511
static HGLOBAL PRINTDLG_GetDlgTemplateW(const PRINTDLGW *lppd)
Definition: printdlg.c:2212
static WCHAR * pagesetup_get_devname(const pagesetup_data *data)
Definition: printdlg.c:2862
static DRIVER_INFO_3A * get_driver_infoA(HANDLE hprn)
Definition: printdlg.c:172
#define wcsrchr
Definition: compat.h:16
#define CP_ACP
Definition: compat.h:109
#define lstrcpynA
Definition: compat.h:751
#define TRACE_ON(x)
Definition: compat.h:75
#define CALLBACK
Definition: compat.h:35
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
INT WINAPI DECLSPEC_HOTPATCH LoadStringA(HINSTANCE instance, UINT resource_id, LPSTR buffer, INT buflen)
Definition: string.c:1307
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2752
_ACRTIMP int __cdecl system(const char *)
Definition: process.c:1297
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
_ACRTIMP char *__cdecl strrchr(const char *, int)
Definition: string.c:3303
char * va_list
Definition: vadefs.h:50
USHORT port
Definition: uri.c:210
#define swprintf
Definition: precomp.h:40
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
GLsizei const GLfloat * points
Definition: glext.h:8112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
unsigned int UINT
Definition: sysinfo.c:13
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HGLOBAL NTAPI GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:825
UINT NTAPI GlobalFlags(HGLOBAL hMem)
Definition: heapmem.c:520
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
ULONG Release()
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
#define S_OK
Definition: intsafe.h:52
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
int quality
Definition: jpeglib.h:994
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
if(dx< 0)
Definition: linetemp.h:194
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
#define sprintf
Definition: sprintf.c:45
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
const IID IID_IObjectWithSite
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:91
static WNDPROC old_proc
Definition: clipboard.c:236
#define min(a, b)
Definition: monoChain.cc:55
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define LOCALE_USER_DEFAULT
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
short WCHAR
Definition: pedump.c:58
#define WS_BORDER
Definition: pedump.c:625
#define WS_VISIBLE
Definition: pedump.c:620
#define RT_DIALOG
Definition: pedump.c:367
long LONG
Definition: pedump.c:60
char CHAR
Definition: pedump.c:57
static char title[]
Definition: ps.c:92
#define UDS_SETBUDDYINT
Definition: commctrl.h:2137
#define UDS_NOTHOUSANDS
Definition: commctrl.h:2143
#define UDS_ARROWKEYS
Definition: commctrl.h:2141
#define UDS_ALIGNRIGHT
Definition: commctrl.h:2138
#define WM_PAINT
Definition: winuser.h:1648
DWORD WINAPI GetSysColor(_In_ int)
#define CB_SETITEMDATA
Definition: winuser.h:1995
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SW_HIDE
Definition: winuser.h:779
#define CB_GETLBTEXTLEN
Definition: winuser.h:1982
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)
#define DT_NOPREFIX
Definition: winuser.h:537
#define CB_GETLBTEXT
Definition: winuser.h:1981
#define EN_KILLFOCUS
Definition: winuser.h:2054
INT_PTR WINAPI DialogBoxIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDCANCEL
Definition: winuser.h:842
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1768
#define CB_ERR
Definition: winuser.h:2471
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2572
#define CB_SETCURSEL
Definition: winuser.h:1990
#define COLOR_3DDKSHADOW
Definition: winuser.h:950
#define COLOR_3DHIGHLIGHT
Definition: winuser.h:947
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define COLOR_3DSHADOW
Definition: winuser.h:942
#define CB_RESETCONTENT
Definition: winuser.h:1988
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1969
#define WM_INITDIALOG
Definition: winuser.h:1767
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1391
#define CB_GETCOUNT
Definition: winuser.h:1971
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define STM_SETIMAGE
Definition: winuser.h:2129
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
#define CBN_SELCHANGE
Definition: winuser.h:2008
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_ICONERROR
Definition: winuser.h:798
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define DT_LEFT
Definition: winuser.h:534
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define DT_TOP
Definition: winuser.h:542
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2429
#define DT_WORDBREAK
Definition: winuser.h:544
#define CB_ADDSTRING
Definition: winuser.h:1965
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
#define CB_GETITEMDATA
Definition: winuser.h:1979
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define VK_BACK
Definition: winuser.h:2234
BOOL WINAPI SetDlgItemTextA(_In_ HWND, _In_ int, _In_ LPCSTR)
#define MB_OK
Definition: winuser.h:801
INT_PTR WINAPI DialogBoxIndirectParamA(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_CHAR
Definition: winuser.h:1745
#define MB_ICONWARNING
Definition: winuser.h:797
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4620
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
HANDLE WINAPI LoadImageA(_In_opt_ HINSTANCE hInst, _In_ LPCSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2547
#define WM_USER
Definition: winuser.h:1923
#define WM_DESTROY
Definition: winuser.h:1637
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define CB_GETCURSEL
Definition: winuser.h:1972
#define SetWindowLongPtrW
Definition: winuser.h:5512
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendDlgItemMessageA(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DestroyWindow(_In_ HWND)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2444
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2422
#define EN_CHANGE
Definition: winuser.h:2051
#define calloc
Definition: rosglue.h:14
const WCHAR * str
#define iswdigit(_c)
Definition: ctype.h:667
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
#define LoadStringW
Definition: utils.h:64
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
LONG lfHeight
Definition: dimm.idl:59
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
HICON hCollateIcon
Definition: printdlg.c:64
LPDEVMODEA lpDevMode
Definition: printdlg.c:59
HWND hwndUpDown
Definition: printdlg.c:68
HICON hPortraitIcon
Definition: printdlg.c:66
HICON hNoCollateIcon
Definition: printdlg.c:65
UINT HelpMessageID
Definition: printdlg.c:63
LPDRIVER_INFO_3A lpDriverInfo
Definition: printdlg.c:62
HICON hLandscapeIcon
Definition: printdlg.c:67
LPPRINTER_INFO_2A lpPrinterInfo
Definition: printdlg.c:61
LPPRINTDLGA lpPrintDlg
Definition: printdlg.c:60
HICON hLandscapeIcon
Definition: printdlg.c:81
HWND hwndUpDown
Definition: printdlg.c:82
LPDEVMODEW lpDevMode
Definition: printdlg.c:73
LPPRINTER_INFO_2W lpPrinterInfo
Definition: printdlg.c:75
UINT HelpMessageID
Definition: printdlg.c:77
LPPRINTDLGW lpPrintDlg
Definition: printdlg.c:74
LPDRIVER_INFO_3W lpDriverInfo
Definition: printdlg.c:76
HICON hPortraitIcon
Definition: printdlg.c:80
HICON hNoCollateIcon
Definition: printdlg.c:79
HICON hCollateIcon
Definition: printdlg.c:78
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
LPSTR pDriverPath
Definition: winspool.h:406
LPWSTR pDriverPath
Definition: winspool.h:419
LPSTR pDriverName
Definition: winspool.h:42
LPSTR pPrinterName
Definition: winspool.h:39
LPSTR pPortName
Definition: winspool.h:41
LPWSTR pPrinterName
Definition: winspool.h:63
LPWSTR pPortName
Definition: winspool.h:65
LPWSTR pDriverName
Definition: winspool.h:66
BYTE dmFormName[CCHFORMNAME]
Definition: wingdi.h:2039
short dmCopies
Definition: wingdi.h:2024
DWORD dmFields
Definition: wingdi.h:2016
WORD dmSpecVersion
Definition: wingdi.h:2012
short dmDefaultSource
Definition: wingdi.h:2025
short dmYResolution
Definition: wingdi.h:2036
WORD dmLogPixels
Definition: wingdi.h:2040
short dmPaperSize
Definition: wingdi.h:2020
short dmCollate
Definition: wingdi.h:2038
short dmOrientation
Definition: wingdi.h:2019
WORD dmDriverExtra
Definition: wingdi.h:2015
BYTE dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:2011
short dmPrintQuality
Definition: wingdi.h:2026
WORD dmSize
Definition: wingdi.h:2014
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:2063
DWORD dmFields
Definition: wingdi.h:2068
short dmCopies
Definition: wingdi.h:2076
short dmDefaultSource
Definition: wingdi.h:2077
short dmPaperSize
Definition: wingdi.h:2072
short dmOrientation
Definition: wingdi.h:2071
WORD dmDriverExtra
Definition: wingdi.h:2067
WORD dmSpecVersion
Definition: wingdi.h:2064
WCHAR dmFormName[CCHFORMNAME]
Definition: wingdi.h:2091
WORD dmLogPixels
Definition: wingdi.h:2092
WORD dmSize
Definition: wingdi.h:2066
short dmCollate
Definition: wingdi.h:2090
Definition: match.c:390
IPrintDialogCallback * callback
Definition: printdlg.c:4049
IObjectWithSite * object
Definition: printdlg.c:4050
Definition: fci.c:123
Definition: name.c:39
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2642
LPPAGESETUPDLGA dlga
Definition: printdlg.c:2641
Definition: pbuf.h:186
DWORD flag
Definition: printdlg.c:88
LPCSTR name
Definition: printdlg.c:89
WORD wDeviceOffset
Definition: commdlg.h:298
WORD wDriverOffset
Definition: commdlg.h:297
WORD wDefault
Definition: commdlg.h:300
WORD wOutputOffset
Definition: commdlg.h:299
WORD nMaxPage
Definition: commdlg.h:474
HGLOBAL hSetupTemplate
Definition: commdlg.h:483
HDC hDC
Definition: commdlg.h:469
DWORD Flags
Definition: commdlg.h:470
LPARAM lCustData
Definition: commdlg.h:477
LPCSTR lpPrintTemplateName
Definition: commdlg.h:480
HINSTANCE hInstance
Definition: commdlg.h:476
WORD nCopies
Definition: commdlg.h:475
HGLOBAL hPrintTemplate
Definition: commdlg.h:482
LPPRINTHOOKPROC lpfnPrintHook
Definition: commdlg.h:478
WORD nFromPage
Definition: commdlg.h:471
HGLOBAL hDevMode
Definition: commdlg.h:467
LPCSTR lpSetupTemplateName
Definition: commdlg.h:481
WORD nToPage
Definition: commdlg.h:472
WORD nMinPage
Definition: commdlg.h:473
HGLOBAL hDevNames
Definition: commdlg.h:468
HWND hwndOwner
Definition: commdlg.h:466
DWORD lStructSize
Definition: commdlg.h:465
HGLOBAL hSetupTemplate
Definition: commdlg.h:504
LPPRINTHOOKPROC lpfnPrintHook
Definition: commdlg.h:499
HGLOBAL hDevMode
Definition: commdlg.h:488
LPSETUPHOOKPROC lpfnSetupHook
Definition: commdlg.h:500
LPCWSTR lpPrintTemplateName
Definition: commdlg.h:501
DWORD Flags
Definition: commdlg.h:491
HWND hwndOwner
Definition: commdlg.h:487
HINSTANCE hInstance
Definition: commdlg.h:497
LPCWSTR lpSetupTemplateName
Definition: commdlg.h:502
WORD nToPage
Definition: commdlg.h:493
HGLOBAL hPrintTemplate
Definition: commdlg.h:503
HGLOBAL hDevNames
Definition: commdlg.h:489
WORD nMaxPage
Definition: commdlg.h:495
WORD nMinPage
Definition: commdlg.h:494
HDC hDC
Definition: commdlg.h:490
DWORD lStructSize
Definition: commdlg.h:486
WORD nCopies
Definition: commdlg.h:496
LPARAM lCustData
Definition: commdlg.h:498
WORD nFromPage
Definition: commdlg.h:492
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#define GWLP_WNDPROC
Definition: treelist.c:66
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
Definition: pdh_main.c:64
int retval
Definition: wcstombs.cpp:91
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281
static GLenum which
Definition: wgl_font.c:159
#define LPRECT
Definition: precomp.h:28
#define dpi
Definition: sysparams.c:23
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2283
UINT WINAPI GetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount)
Definition: dialog.c:2265
const char * errstr(int errcode)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:398
#define GMEM_LOCKCOUNT
Definition: winbase.h:333
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:401
#define GMEM_MOVEABLE
Definition: winbase.h:318
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define DC_BINS
Definition: windef.h:161
#define DM_IN_BUFFER
Definition: windef.h:151
#define DC_PAPERNAMES
Definition: windef.h:171
#define DC_PAPERSIZE
Definition: windef.h:158
#define DM_IN_PROMPT
Definition: windef.h:152
#define DC_PAPERS
Definition: windef.h:157
#define DC_BINNAMES
Definition: windef.h:167
#define DC_ENUMRESOLUTIONS
Definition: windef.h:168
#define DM_OUT_BUFFER
Definition: windef.h:153
#define WINAPI
Definition: msvc.h:6
#define E_HANDLE
Definition: winerror.h:4117
#define DMORIENT_LANDSCAPE
Definition: wingdi.h:1111
#define PS_DASH
Definition: wingdi.h:587
#define DMBIN_FORMSOURCE
Definition: wingdi.h:1197
DWORD WINAPI DeviceCapabilitiesA(_In_ LPCSTR pDevice, _In_opt_ LPCSTR pPort, _In_ WORD fwCapability, _Out_writes_opt_(_Inexpressible_(1)) LPSTR pOutput, _In_opt_ const DEVMODEA *pDevMode)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
DWORD WINAPI DeviceCapabilitiesW(_In_ LPCWSTR pDevice, _In_opt_ LPCWSTR pPort, _In_ WORD fwCapability, _Out_writes_opt_(_Inexpressible_(1)) LPWSTR pOutput, _In_opt_ const DEVMODEW *pDevMode)
DEVMODEW *WINAPI GdiConvertToDevmodeW(const DEVMODEA *)
Definition: misc.c:969
#define CCHFORMNAME
Definition: wingdi.h:67
#define LOGPIXELSY
Definition: wingdi.h:719
HDC WINAPI CreateICW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ const DEVMODEW *)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
#define TRANSPARENT
Definition: wingdi.h:950
#define DM_COLLATE
Definition: wingdi.h:1265
#define DM_PRINTQUALITY
Definition: wingdi.h:1260
#define DMORIENT_PORTRAIT
Definition: wingdi.h:1110
#define LOGPIXELSX
Definition: wingdi.h:718
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define DMPAPER_USER
Definition: wingdi.h:1182
#define DM_COPIES
Definition: wingdi.h:1258
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define PS_SOLID
Definition: wingdi.h:586
#define DM_YRESOLUTION
Definition: wingdi.h:1263
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
#define LOCALE_SDECIMAL
Definition: winnls.h:52
#define LOCALE_IMEASURE
Definition: winnls.h:51
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:2582
#define PRINTER_ENUM_LOCAL
Definition: winspool.h:896
WINBOOL WINAPI GetDefaultPrinterW(LPWSTR pszBuffer, LPDWORD pcchBuffer)
Definition: printers.c:1971
WINBOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:2533
WINBOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
WINBOOL WINAPI EnumPrintersW(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
WINBOOL WINAPI GetDefaultPrinterA(LPSTR pszBuffer, LPDWORD pcchBuffer)
Definition: printers.c:1925
WINBOOL WINAPI GetPrinterDriverA(HANDLE hPrinter, LPSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LPWSTR pDeviceName, PDEVMODEW pDevModeOutput, PDEVMODEW pDevModeInput, DWORD fMode)
Definition: printers.c:1177
LONG WINAPI DocumentPropertiesA(HWND hWnd, HANDLE hPrinter, LPSTR pDeviceName, PDEVMODEA pDevModeOutput, PDEVMODEA pDevModeInput, DWORD fMode)
Definition: printers.c:666
WINBOOL WINAPI OpenPrinterW(LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault)
Definition: printers.c:2653
WINBOOL WINAPI GetPrinterA(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:2062
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
#define PRINTER_ENUM_CONNECTIONS
Definition: winspool.h:897
WINBOOL WINAPI EnumPrintersA(DWORD Flags, LPSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)