- Timestamp:
- Oct 28, 2002, 6:55:09 PM (23 years ago)
- Location:
- trunk/src/comdlg32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/makefile
r7397 r9364 1 # $Id: makefile,v 1.3 1 2001-11-19 12:32:00sandervl Exp $1 # $Id: makefile,v 1.32 2002-10-28 17:55:09 sandervl Exp $ 2 2 3 3 # … … 36 36 $(OBJDIR)\filedlg.obj \ 37 37 $(OBJDIR)\filedlg95.obj \ 38 $(OBJDIR)\comdlg32.obj \38 ##$(OBJDIR)\comdlg32.obj \ 39 39 $(OBJDIR)\filedlgbrowser.obj \ 40 ##$(OBJDIR)\printdlg.obj \40 $(OBJDIR)\printdlg.obj \ 41 41 $(OBJDIR)\rsrc.obj 42 42 -
trunk/src/comdlg32/printdlg.c
r6709 r9364 6 6 * Copyright 1999 Klaas van Gend 7 7 * Copyright 2000 Huw D M Davies 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License as published by the Free Software Foundation; either 12 * version 2.1 of the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 8 22 */ 9 23 #include <ctype.h> … … 19 33 #include "commdlg.h" 20 34 #include "dlgs.h" 21 #include " debugtools.h"35 #include "wine/debug.h" 22 36 #include "cderr.h" 23 37 #include "winspool.h" 24 38 #include "winerror.h" 25 39 26 DEFAULT_DEBUG_CHANNEL(commdlg);40 WINE_DEFAULT_DEBUG_CHANNEL(commdlg); 27 41 28 42 #include "cdlg.h" … … 30 44 /* This PRINTDLGA internal structure stores 31 45 * pointers to several throughout useful structures. 32 * 46 * 33 47 */ 34 typedef struct 48 typedef struct 35 49 { 36 50 LPDEVMODEA lpDevMode; … … 48 62 HWND hwndUpDown; 49 63 } PRINT_PTRA; 64 65 typedef struct 66 { 67 LPDEVMODEW lpDevMode; 68 struct { 69 LPPRINTDLGW lpPrintDlg; 70 } dlg; 71 LPPRINTER_INFO_2W lpPrinterInfo; 72 LPDRIVER_INFO_3W lpDriverInfo; 73 UINT HelpMessageID; 74 HICON hCollateIcon; /* PrintDlg only */ 75 HICON hNoCollateIcon; /* PrintDlg only */ 76 HICON hPortraitIcon; /* PrintSetupDlg only */ 77 HICON hLandscapeIcon; /* PrintSetupDlg only */ 78 HWND hwndUpDown; 79 } PRINT_PTRW; 50 80 51 81 /* Debugging info */ … … 108 138 * 109 139 * Returns the default printer name in buf. 110 * Even under WinNT/2000 default printer is retrieved via GetProfileString - 140 * Even under WinNT/2000 default printer is retrieved via GetProfileString - 111 141 * these entries are mapped somewhere in the registry rather than win.ini. 112 142 * 113 143 * Returns TRUE on success else FALSE 114 144 */ 115 static BOOL PRINTDLG_GetDefaultPrinterName (LPSTR buf, DWORD len)145 static BOOL PRINTDLG_GetDefaultPrinterNameA(LPSTR buf, DWORD len) 116 146 { 117 147 char *ptr; … … 129 159 } 130 160 161 static BOOL PRINTDLG_GetDefaultPrinterNameW(LPWSTR buf, DWORD len) 162 { 163 LPSTR ptr, bufA = (LPSTR)HeapAlloc(GetProcessHeap(),0,len+1); 164 165 166 if(!GetProfileStringA("windows", "device", "", bufA, len)) { 167 TRACE("No profile entry for default printer found.\n"); 168 HeapFree(GetProcessHeap(),0,bufA); 169 return FALSE; 170 } 171 if((ptr = strchr(bufA, ',')) == NULL) { 172 FIXME("bad format for default printer (%s)!\n",bufA); 173 HeapFree(GetProcessHeap(),0,bufA); 174 return FALSE; 175 } 176 *ptr = '\0'; 177 MultiByteToWideChar( CP_ACP, 0, bufA, -1, buf, len ); 178 HeapFree(GetProcessHeap(),0,bufA); 179 return TRUE; 180 } 181 131 182 /*********************************************************************** 132 183 * PRINTDLG_OpenDefaultPrinter … … 141 192 char buf[260]; 142 193 BOOL res; 143 if(!PRINTDLG_GetDefaultPrinterName (buf, sizeof(buf)))194 if(!PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf))) 144 195 return FALSE; 145 196 res = OpenPrinterA(buf, hprn, NULL); … … 162 213 * Returns number of printers added to list. 163 214 */ 164 static INT PRINTDLG_SetUpPrinterListCombo (HWND hDlg, UINT id, LPCSTR name)215 static INT PRINTDLG_SetUpPrinterListComboA(HWND hDlg, UINT id, LPCSTR name) 165 216 { 166 217 DWORD needed, num; … … 169 220 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num); 170 221 pi = HeapAlloc(GetProcessHeap(), 0, needed); 171 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 222 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 172 223 &num); 173 224 … … 184 235 FIXME("Can't find '%s' in printer list so trying to find default\n", 185 236 name); 186 if(!PRINTDLG_GetDefaultPrinterName (buf, sizeof(buf)))237 if(!PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf))) 187 238 return num; 188 239 i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf); … … 194 245 } 195 246 247 static INT PRINTDLG_SetUpPrinterListComboW(HWND hDlg, UINT id, LPCWSTR name) 248 { 249 DWORD needed, num; 250 INT i; 251 LPPRINTER_INFO_2W pi; 252 EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num); 253 pi = HeapAlloc(GetProcessHeap(), 0, needed); 254 EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 255 &num); 256 257 for(i = 0; i < num; i++) { 258 SendDlgItemMessageW(hDlg, id, CB_ADDSTRING, 0, 259 (LPARAM)pi[i].pPrinterName ); 260 } 261 HeapFree(GetProcessHeap(), 0, pi); 262 if(!name || 263 (i = SendDlgItemMessageW(hDlg, id, CB_FINDSTRINGEXACT, -1, 264 (LPARAM)name)) == CB_ERR) { 265 266 /* ansi is ok */ 267 char buf[260]; 268 FIXME("Can't find '%s' in printer list so trying to find default\n", 269 debugstr_w(name)); 270 if(!PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf))) 271 return num; 272 i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf); 273 if(i == CB_ERR) 274 FIXME("Can't find default printer in printer list\n"); 275 } 276 SendDlgItemMessageW(hDlg, id, CB_SETCURSEL, i, 0); 277 return num; 278 } 279 196 280 /*********************************************************************** 197 281 * PRINTDLG_CreateDevNames [internal] … … 202 286 * (NB. when we handle unicode the offsets will be in wchars). 203 287 */ 204 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 288 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 205 289 char* DeviceName, char* OutputPort) 206 290 { … … 215 299 + strlen(OutputPort) + 1 216 300 + sizeof(DEVNAMES); 217 301 218 302 if(*hmem) 219 303 *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE); … … 233 317 strcpy(pTempPtr, DeviceName); 234 318 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace; 235 319 236 320 pTempPtr += strlen(DeviceName) + 1; 237 321 strcpy(pTempPtr, OutputPort); 238 322 lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace; 239 323 240 PRINTDLG_GetDefaultPrinterName (buf, sizeof(buf));324 PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf)); 241 325 lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0; 242 326 GlobalUnlock(*hmem); 243 327 return TRUE; 244 328 } 329 330 static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName, 331 LPCWSTR DeviceName, LPCWSTR OutputPort) 332 { 333 long size; 334 LPWSTR pDevNamesSpace; 335 LPWSTR pTempPtr; 336 LPDEVNAMES lpDevNames; 337 WCHAR bufW[260]; 338 char buf[260]; 339 340 size = sizeof(WCHAR)*lstrlenW(DeviceDriverName) + 2 341 + sizeof(WCHAR)*lstrlenW(DeviceName) + 2 342 + sizeof(WCHAR)*lstrlenW(OutputPort) + 2 343 + sizeof(DEVNAMES); 344 345 if(*hmem) 346 *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE); 347 else 348 *hmem = GlobalAlloc(GMEM_MOVEABLE, size); 349 if (*hmem == 0) 350 return FALSE; 351 352 pDevNamesSpace = GlobalLock(*hmem); 353 lpDevNames = (LPDEVNAMES) pDevNamesSpace; 354 355 pTempPtr = (LPWSTR)((LPDEVNAMES)pDevNamesSpace + 1); 356 lstrcpyW(pTempPtr, DeviceDriverName); 357 lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace; 358 359 pTempPtr += lstrlenW(DeviceDriverName) + 1; 360 lstrcpyW(pTempPtr, DeviceName); 361 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace; 362 363 pTempPtr += lstrlenW(DeviceName) + 1; 364 lstrcpyW(pTempPtr, OutputPort); 365 lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace; 366 367 PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf)); 368 MultiByteToWideChar(CP_ACP, 0, buf, -1, bufW, -1); 369 lpDevNames->wDefault = (lstrcmpW(bufW, DeviceName) == 0) ? 1 : 0; 370 GlobalUnlock(*hmem); 371 return TRUE; 372 } 373 374 245 375 #ifndef __WIN32OS2__ 246 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 376 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 247 377 char* DeviceName, char* OutputPort) 248 378 { … … 257 387 + strlen(OutputPort) + 1 258 388 + sizeof(DEVNAMES); 259 389 260 390 if(*hmem) 261 391 *hmem = GlobalReAlloc16(*hmem, size, GMEM_MOVEABLE); … … 275 405 strcpy(pTempPtr, DeviceName); 276 406 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace; 277 407 278 408 pTempPtr += strlen(DeviceName) + 1; 279 409 strcpy(pTempPtr, OutputPort); 280 410 lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace; 281 411 282 PRINTDLG_GetDefaultPrinterName (buf, sizeof(buf));412 PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf)); 283 413 lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0; 284 414 GlobalUnlock16(*hmem); … … 292 422 * 293 423 * updates the PrintDlg structure for returnvalues. 294 * 424 * 295 425 * RETURNS 296 426 * FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values) 297 427 * TRUE if succesful. 298 428 */ 299 static BOOL PRINTDLG_UpdatePrintDlg (HWND hDlg,429 static BOOL PRINTDLG_UpdatePrintDlgA(HWND hDlg, 300 430 PRINT_PTRA* PrintStructures) 301 431 { … … 324 454 char resourcestr[256]; 325 455 char resultstr[256]; 326 LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, 456 LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, 327 457 resourcestr, 255); 328 458 sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage); 329 LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE, 459 LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE, 330 460 resourcestr, 255); 331 461 MessageBoxA(hDlg, resultstr, resourcestr, … … 335 465 lppd->nFromPage = nFromPage; 336 466 lppd->nToPage = nToPage; 337 } 467 lppd->Flags |= PD_PAGENUMS; 468 } 469 else 470 lppd->Flags &= ~PD_PAGENUMS; 338 471 339 472 if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */ … … 356 489 */ 357 490 if (lpdm->dmFields & DM_COLLATE) 358 lpdm->dmCollate = 491 lpdm->dmCollate = 359 492 (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED); 360 493 if (lpdm->dmFields & DM_COPIES) … … 371 504 } 372 505 373 static BOOL PRINTDLG_PaperSize( 506 static BOOL PRINTDLG_UpdatePrintDlgW(HWND hDlg, 507 PRINT_PTRW* PrintStructures) 508 { 509 LPPRINTDLGW lppd = PrintStructures->dlg.lpPrintDlg; 510 PDEVMODEW lpdm = PrintStructures->lpDevMode; 511 LPPRINTER_INFO_2W pi = PrintStructures->lpPrinterInfo; 512 513 514 if(!lpdm) { 515 FIXME("No lpdm ptr?\n"); 516 return FALSE; 517 } 518 519 520 if(!(lppd->Flags & PD_PRINTSETUP)) { 521 /* check whether nFromPage and nToPage are within range defined by 522 * nMinPage and nMaxPage 523 */ 524 if (IsDlgButtonChecked(hDlg, rad3) == BST_CHECKED) { /* Pages */ 525 WORD nToPage; 526 WORD nFromPage; 527 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE); 528 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE); 529 if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage || 530 nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) { 531 char resourcestr[256]; 532 char resultstr[256]; 533 LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, 534 resourcestr, 255); 535 sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage); 536 LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE, 537 resourcestr, 255); 538 MessageBoxA(hDlg, resultstr, resourcestr, 539 MB_OK | MB_ICONWARNING); 540 return FALSE; 541 } 542 lppd->nFromPage = nFromPage; 543 lppd->nToPage = nToPage; 544 } 545 546 if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */ 547 static WCHAR file[] = {'F','I','L','E',':',0}; 548 lppd->Flags |= PD_PRINTTOFILE; 549 pi->pPortName = file; 550 } 551 552 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */ 553 FIXME("Collate lppd not yet implemented as output\n"); 554 } 555 556 /* set PD_Collate and nCopies */ 557 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 558 /* The application doesn't support multiple copies or collate... 559 */ 560 lppd->Flags &= ~PD_COLLATE; 561 lppd->nCopies = 1; 562 /* if the printer driver supports it... store info there 563 * otherwise no collate & multiple copies ! 564 */ 565 if (lpdm->dmFields & DM_COLLATE) 566 lpdm->dmCollate = 567 (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED); 568 if (lpdm->dmFields & DM_COPIES) 569 lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 570 } else { 571 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) 572 lppd->Flags |= PD_COLLATE; 573 else 574 lppd->Flags &= ~PD_COLLATE; 575 lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 576 } 577 } 578 return TRUE; 579 } 580 581 static BOOL PRINTDLG_PaperSizeA( 374 582 PRINTDLGA *pdlga,const char *PaperSize,LPPOINT size 375 583 ) { … … 378 586 LPSTR devname,portname; 379 587 int i; 380 DWORDNrOfEntries,ret;588 INT NrOfEntries,ret; 381 589 char *Names = NULL; 382 590 POINT *points = NULL; 383 591 BOOL retval = FALSE; 384 592 385 593 dn = GlobalLock(pdlga->hDevNames); 386 594 dm = GlobalLock(pdlga->hDevMode); … … 394 602 goto out; 395 603 } 604 if (NrOfEntries == -1) { 605 ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n"); 606 goto out; 607 } 608 396 609 Names = (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries*64); 397 610 if (NrOfEntries != (ret=DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,Names,dm))) { 398 FIXME("Number of returned vals % ld is not %ld\n",NrOfEntries,ret);611 FIXME("Number of returned vals %d is not %d\n",NrOfEntries,ret); 399 612 goto out; 400 613 } … … 409 622 points = HeapAlloc(GetProcessHeap(),0,sizeof(points[0])*NrOfEntries); 410 623 if (NrOfEntries!=(ret=DeviceCapabilitiesA(devname,portname,DC_PAPERSIZE,(LPBYTE)points,dm))) { 411 FIXME("Number of returned sizes % ld is not %ld?\n",NrOfEntries,ret);624 FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries,ret); 412 625 goto out; 413 626 } … … 415 628 size->x=points[i].x; 416 629 size->y=points[i].y; 417 FIXME("papersize is %ld x %ld\n",size->x,size->y);418 630 retval = TRUE; 419 631 out: … … 425 637 } 426 638 639 static BOOL PRINTDLG_PaperSizeW( 640 PRINTDLGW *pdlga,const WCHAR *PaperSize,LPPOINT size 641 ) { 642 DEVNAMES *dn; 643 DEVMODEW *dm; 644 LPWSTR devname,portname; 645 int i; 646 INT NrOfEntries,ret; 647 WCHAR *Names = NULL; 648 POINT *points = NULL; 649 BOOL retval = FALSE; 650 651 dn = GlobalLock(pdlga->hDevNames); 652 dm = GlobalLock(pdlga->hDevMode); 653 devname = ((WCHAR*)dn)+dn->wDeviceOffset; 654 portname = ((WCHAR*)dn)+dn->wOutputOffset; 655 656 657 NrOfEntries = DeviceCapabilitiesW(devname,portname,DC_PAPERNAMES,NULL,dm); 658 if (!NrOfEntries) { 659 FIXME("No papernames found for %s/%s\n",debugstr_w(devname),debugstr_w(portname)); 660 goto out; 661 } 662 if (NrOfEntries == -1) { 663 ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n"); 664 goto out; 665 } 666 667 Names = (WCHAR*)HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*NrOfEntries*64); 668 if (NrOfEntries != (ret=DeviceCapabilitiesW(devname,portname,DC_PAPERNAMES,Names,dm))) { 669 FIXME("Number of returned vals %d is not %d\n",NrOfEntries,ret); 670 goto out; 671 } 672 for (i=0;i<NrOfEntries;i++) 673 if (!lstrcmpW(PaperSize,Names+(64*i))) 674 break; 675 HeapFree(GetProcessHeap(),0,Names); 676 if (i==NrOfEntries) { 677 FIXME("Papersize %s not found in list?\n",debugstr_w(PaperSize)); 678 goto out; 679 } 680 points = HeapAlloc(GetProcessHeap(),0,sizeof(points[0])*NrOfEntries); 681 if (NrOfEntries!=(ret=DeviceCapabilitiesW(devname,portname,DC_PAPERSIZE,(LPWSTR)points,dm))) { 682 FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries,ret); 683 goto out; 684 } 685 /* this is _10ths_ of a millimeter */ 686 size->x=points[i].x; 687 size->y=points[i].y; 688 retval = TRUE; 689 out: 690 GlobalUnlock(pdlga->hDevNames); 691 GlobalUnlock(pdlga->hDevMode); 692 if (Names) HeapFree(GetProcessHeap(),0,Names); 693 if (points) HeapFree(GetProcessHeap(),0,points); 694 return retval; 695 } 696 427 697 428 698 /************************************************************************ … … 433 703 * We also try to re-select the old selection. 434 704 */ 435 static BOOL PRINTDLG_SetUpPaperComboBox (HWND hDlg,705 static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg, 436 706 int nIDComboBox, 437 char* PrinterName, 707 char* PrinterName, 438 708 char* PortName, 439 709 LPDEVMODEA dm) 440 710 { 441 711 int i; 442 DWORDNrOfEntries;712 int NrOfEntries; 443 713 char* Names; 444 714 WORD* Words; … … 448 718 int fwCapability_Names; 449 719 int fwCapability_Words; 450 451 TRACE(" Printer: %s, ComboID: %d\n",PrinterName,nIDComboBox);452 720 721 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",PrinterName,PortName,nIDComboBox); 722 453 723 /* query the dialog box for the current selected value */ 454 724 Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0); … … 462 732 if (dm) { 463 733 if (nIDComboBox == cmb2) 464 #ifdef __WIN32OS2__465 dm->dmPaperSize = oldWord;466 #else467 734 dm->u1.s1.dmPaperSize = oldWord; 468 #endif469 735 else 470 736 dm->dmDefaultSource = oldWord; … … 478 744 if (dm) { 479 745 if (nIDComboBox == cmb2) 480 #ifdef __WIN32OS2__481 oldWord = dm->dmPaperSize;482 #else483 746 oldWord = dm->u1.s1.dmPaperSize; 484 #endif485 747 else 486 748 oldWord = dm->dmDefaultSource; … … 498 760 fwCapability_Words = DC_BINS; 499 761 } 500 501 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 762 763 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 502 764 * paper settings. As Wine doesn't allow VXDs, this results in a crash. 503 765 */ … … 507 769 if (NrOfEntries == 0) 508 770 WARN("no Name Entries found!\n"); 771 else if (NrOfEntries < 0) 772 return FALSE; 509 773 510 774 if(DeviceCapabilitiesA(PrinterName, PortName, fwCapability_Words, NULL, dm) … … 514 778 } 515 779 516 Names = HeapAlloc(GetProcessHeap(),0, NrOfEntries* NamesSize);780 Names = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(char)*NamesSize); 517 781 Words = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(WORD)); 518 782 NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName, … … 523 787 /* reset any current content in the combobox */ 524 788 SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0); 525 789 526 790 /* store new content */ 527 791 for (i = 0; i < NrOfEntries; i++) { 528 792 DWORD pos = SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0, 529 793 (LPARAM)(&Names[i*NamesSize]) ); 530 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos, 794 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos, 531 795 Words[i]); 532 796 } … … 549 813 } 550 814 815 static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg, 816 int nIDComboBox, 817 WCHAR* PrinterName, 818 WCHAR* PortName, 819 LPDEVMODEW dm) 820 { 821 int i; 822 int NrOfEntries; 823 WCHAR* Names; 824 WORD* Words; 825 DWORD Sel; 826 WORD oldWord = 0; 827 int NamesSize; 828 int fwCapability_Names; 829 int fwCapability_Words; 830 831 TRACE(" Printer: %s, Port: %s, ComboID: %d\n",debugstr_w(PrinterName),debugstr_w(PortName),nIDComboBox); 832 833 /* query the dialog box for the current selected value */ 834 Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0); 835 if(Sel != CB_ERR) { 836 /* we enter here only if a different printer is selected after 837 * the Print Setup dialog is opened. The current settings are 838 * stored into the newly selected printer. 839 */ 840 oldWord = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, 841 Sel, 0); 842 if (dm) { 843 if (nIDComboBox == cmb2) 844 dm->u1.s1.dmPaperSize = oldWord; 845 else 846 dm->dmDefaultSource = oldWord; 847 } 848 } 849 else { 850 /* we enter here only when the Print setup dialog is initially 851 * opened. In this case the settings are restored from when 852 * the dialog was last closed. 853 */ 854 if (dm) { 855 if (nIDComboBox == cmb2) 856 oldWord = dm->u1.s1.dmPaperSize; 857 else 858 oldWord = dm->dmDefaultSource; 859 } 860 } 861 862 if (nIDComboBox == cmb2) { 863 NamesSize = 64; 864 fwCapability_Names = DC_PAPERNAMES; 865 fwCapability_Words = DC_PAPERS; 866 } else { 867 nIDComboBox = cmb3; 868 NamesSize = 24; 869 fwCapability_Names = DC_BINNAMES; 870 fwCapability_Words = DC_BINS; 871 } 872 873 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 874 * paper settings. As Wine doesn't allow VXDs, this results in a crash. 875 */ 876 WARN(" if your printer driver uses VXDs, expect a crash now!\n"); 877 NrOfEntries = DeviceCapabilitiesW(PrinterName, PortName, 878 fwCapability_Names, NULL, dm); 879 if (NrOfEntries == 0) 880 WARN("no Name Entries found!\n"); 881 else if (NrOfEntries < 0) 882 return FALSE; 883 884 if(DeviceCapabilitiesW(PrinterName, PortName, fwCapability_Words, NULL, dm) 885 != NrOfEntries) { 886 ERR("Number of caps is different\n"); 887 NrOfEntries = 0; 888 } 889 890 Names = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(WCHAR)*NamesSize); 891 Words = HeapAlloc(GetProcessHeap(),0, NrOfEntries*sizeof(WORD)); 892 NrOfEntries = DeviceCapabilitiesW(PrinterName, PortName, 893 fwCapability_Names, Names, dm); 894 NrOfEntries = DeviceCapabilitiesW(PrinterName, PortName, 895 fwCapability_Words, (LPWSTR)Words, dm); 896 897 /* reset any current content in the combobox */ 898 SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0); 899 900 /* store new content */ 901 for (i = 0; i < NrOfEntries; i++) { 902 DWORD pos = SendDlgItemMessageW(hDlg, nIDComboBox, CB_ADDSTRING, 0, 903 (LPARAM)(&Names[i*NamesSize]) ); 904 SendDlgItemMessageW(hDlg, nIDComboBox, CB_SETITEMDATA, pos, 905 Words[i]); 906 } 907 908 /* Look for old selection - can't do this is previous loop since 909 item order will change as more items are added */ 910 Sel = 0; 911 for (i = 0; i < NrOfEntries; i++) { 912 if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == 913 oldWord) { 914 Sel = i; 915 break; 916 } 917 } 918 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0); 919 920 HeapFree(GetProcessHeap(),0,Words); 921 HeapFree(GetProcessHeap(),0,Names); 922 return TRUE; 923 } 924 925 551 926 /*********************************************************************** 552 927 * PRINTDLG_UpdatePrinterInfoTexts [internal] 553 928 */ 554 static void PRINTDLG_UpdatePrinterInfoTexts (HWND hDlg, LPPRINTER_INFO_2A pi)929 static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg, LPPRINTER_INFO_2A pi) 555 930 { 556 931 char StatusMsg[256]; … … 564 939 for (i = 0; i < 25; i++) { 565 940 if (pi->Status & (1<<i)) { 566 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 941 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 567 942 ResourceString, 255); 568 943 strcat(StatusMsg,ResourceString); … … 570 945 } 571 946 /* append "ready" */ 572 /* FIXME: status==ready must only be appended if really so. 947 /* FIXME: status==ready must only be appended if really so. 573 948 but how to detect? */ 574 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 949 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 575 950 ResourceString, 255); 576 951 strcat(StatusMsg,ResourceString); 577 952 578 953 SendDlgItemMessageA(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg); 579 954 … … 589 964 } 590 965 966 static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg, LPPRINTER_INFO_2W pi) 967 { 968 WCHAR StatusMsg[256]; 969 WCHAR ResourceString[256]; 970 int i; 971 972 /* Status Message */ 973 StatusMsg[0]='\0'; 974 975 /* add all status messages */ 976 for (i = 0; i < 25; i++) { 977 if (pi->Status & (1<<i)) { 978 LoadStringW(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 979 ResourceString, 255); 980 lstrcatW(StatusMsg,ResourceString); 981 } 982 } 983 /* append "ready" */ 984 /* FIXME: status==ready must only be appended if really so. 985 but how to detect? */ 986 LoadStringW(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 987 ResourceString, 255); 988 lstrcatW(StatusMsg,ResourceString); 989 990 SendDlgItemMessageW(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg); 991 992 /* set all other printer info texts */ 993 SendDlgItemMessageW(hDlg, stc11, WM_SETTEXT, 0, (LPARAM)pi->pDriverName); 994 if (pi->pLocation != NULL && pi->pLocation[0] != '\0') 995 SendDlgItemMessageW(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pLocation); 996 else 997 SendDlgItemMessageW(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pPortName); 998 SendDlgItemMessageW(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)(pi->pComment ? 999 pi->pComment : (LPCWSTR)"\0\0")); 1000 return; 1001 } 1002 591 1003 592 1004 /******************************************************************* … … 595 1007 * 596 1008 */ 597 static BOOL PRINTDLG_ChangePrinter (HWND hDlg, char *name,1009 static BOOL PRINTDLG_ChangePrinterA(HWND hDlg, char *name, 598 1010 PRINT_PTRA *PrintStructures) 599 1011 { … … 625 1037 ClosePrinter(hprn); 626 1038 627 PRINTDLG_UpdatePrinterInfoTexts (hDlg, PrintStructures->lpPrinterInfo);1039 PRINTDLG_UpdatePrinterInfoTextsA(hDlg, PrintStructures->lpPrinterInfo); 628 1040 629 1041 if(PrintStructures->lpDevMode) { … … 676 1088 char resourcestr[64]; 677 1089 char result[64]; 678 LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES, 1090 LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES, 679 1091 resourcestr, 49); 680 1092 sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1); 681 1093 SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result); 682 1094 } 683 684 /* Collate pages 1095 1096 /* Collate pages 685 1097 * 686 1098 * FIXME: The ico3 is not displayed for some reason. I don't know why. 687 1099 */ 688 1100 if (lppd->Flags & PD_COLLATE) { 689 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1101 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 690 1102 (LPARAM)PrintStructures->hCollateIcon); 691 1103 CheckDlgButton(hDlg, chx2, 1); 692 1104 } else { 693 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1105 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 694 1106 (LPARAM)PrintStructures->hNoCollateIcon); 695 1107 CheckDlgButton(hDlg, chx2, 0); … … 699 1111 /* if printer doesn't support it: no Collate */ 700 1112 if (!(lpdm->dmFields & DM_COLLATE)) { 701 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 702 EnableWindow(GetDlgItem(hDlg, ico3), FALSE); 1113 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 1114 EnableWindow(GetDlgItem(hDlg, ico3), FALSE); 703 1115 } 704 1116 } … … 719 1131 /* if printer doesn't support it: no nCopies */ 720 1132 if (!(lpdm->dmFields & DM_COPIES)) { 721 EnableWindow(GetDlgItem(hDlg, edt3), FALSE); 722 EnableWindow(GetDlgItem(hDlg, stc5), FALSE); 1133 EnableWindow(GetDlgItem(hDlg, edt3), FALSE); 1134 EnableWindow(GetDlgItem(hDlg, stc5), FALSE); 723 1135 } 724 1136 } … … 727 1139 CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0); 728 1140 if (lppd->Flags & PD_DISABLEPRINTTOFILE) 729 EnableWindow(GetDlgItem(hDlg, chx1), FALSE); 1141 EnableWindow(GetDlgItem(hDlg, chx1), FALSE); 730 1142 if (lppd->Flags & PD_HIDEPRINTTOFILE) 731 1143 ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE); 732 1144 733 1145 } else { /* PD_PRINTSETUP */ 734 #ifdef __WIN32OS2__735 BOOL bPortrait = (lpdm->dmOrientation == DMORIENT_PORTRAIT);736 #else737 1146 BOOL bPortrait = (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT); 738 #endif 739 740 PRINTDLG_SetUpPaperComboBox(hDlg, cmb2, 1147 1148 PRINTDLG_SetUpPaperComboBoxA(hDlg, cmb2, 741 1149 PrintStructures->lpPrinterInfo->pPrinterName, 742 1150 PrintStructures->lpPrinterInfo->pPortName, 743 1151 lpdm); 744 PRINTDLG_SetUpPaperComboBox (hDlg, cmb3,1152 PRINTDLG_SetUpPaperComboBoxA(hDlg, cmb3, 745 1153 PrintStructures->lpPrinterInfo->pPrinterName, 746 1154 PrintStructures->lpPrinterInfo->pPortName, … … 750 1158 (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon : 751 1159 PrintStructures->hLandscapeIcon)); 752 1160 753 1161 } 754 1162 … … 756 1164 if ((lppd->Flags & PD_SHOWHELP)==0) { 757 1165 /* hide if PD_SHOWHELP not specified */ 758 ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE); 1166 ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE); 1167 } 1168 return TRUE; 1169 } 1170 1171 static BOOL PRINTDLG_ChangePrinterW(HWND hDlg, WCHAR *name, 1172 PRINT_PTRW *PrintStructures) 1173 { 1174 LPPRINTDLGW lppd = PrintStructures->dlg.lpPrintDlg; 1175 LPDEVMODEW lpdm = NULL; 1176 LONG dmSize; 1177 DWORD needed; 1178 HANDLE hprn; 1179 1180 if(PrintStructures->lpPrinterInfo) 1181 HeapFree(GetProcessHeap(),0, PrintStructures->lpPrinterInfo); 1182 if(PrintStructures->lpDriverInfo) 1183 HeapFree(GetProcessHeap(),0, PrintStructures->lpDriverInfo); 1184 if(!OpenPrinterW(name, &hprn, NULL)) { 1185 ERR("Can't open printer %s\n", debugstr_w(name)); 1186 return FALSE; 1187 } 1188 GetPrinterW(hprn, 2, NULL, 0, &needed); 1189 PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*needed); 1190 GetPrinterW(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed, 1191 &needed); 1192 GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed); 1193 PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*needed); 1194 if (!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo, 1195 needed, &needed)) { 1196 ERR("GetPrinterDriverA failed for %s, fix your config!\n",debugstr_w(PrintStructures->lpPrinterInfo->pPrinterName)); 1197 return FALSE; 1198 } 1199 ClosePrinter(hprn); 1200 1201 PRINTDLG_UpdatePrinterInfoTextsW(hDlg, PrintStructures->lpPrinterInfo); 1202 1203 if(PrintStructures->lpDevMode) { 1204 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode); 1205 PrintStructures->lpDevMode = NULL; 1206 } 1207 1208 dmSize = DocumentPropertiesW(0, 0, name, NULL, NULL, 0); 1209 if(dmSize == -1) { 1210 ERR("DocumentProperties fails on %s\n", debugstr_w(name)); 1211 return FALSE; 1212 } 1213 PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize); 1214 dmSize = DocumentPropertiesW(0, 0, name, PrintStructures->lpDevMode, NULL, 1215 DM_OUT_BUFFER); 1216 if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) && 1217 !lstrcmpW(lpdm->dmDeviceName, 1218 PrintStructures->lpDevMode->dmDeviceName)) { 1219 /* Supplied devicemode matches current printer so try to use it */ 1220 DocumentPropertiesW(0, 0, name, PrintStructures->lpDevMode, lpdm, 1221 DM_OUT_BUFFER | DM_IN_BUFFER); 1222 } 1223 if(lpdm) 1224 GlobalUnlock(lppd->hDevMode); 1225 1226 lpdm = PrintStructures->lpDevMode; /* use this as a shortcut */ 1227 1228 if(!(lppd->Flags & PD_PRINTSETUP)) { 1229 /* Print range (All/Range/Selection) */ 1230 SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE); 1231 SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE); 1232 CheckRadioButton(hDlg, rad1, rad3, rad1); /* default */ 1233 if (lppd->Flags & PD_NOSELECTION) 1234 EnableWindow(GetDlgItem(hDlg, rad2), FALSE); 1235 else 1236 if (lppd->Flags & PD_SELECTION) 1237 CheckRadioButton(hDlg, rad1, rad3, rad2); 1238 if (lppd->Flags & PD_NOPAGENUMS) { 1239 EnableWindow(GetDlgItem(hDlg, rad3), FALSE); 1240 EnableWindow(GetDlgItem(hDlg, stc2),FALSE); 1241 EnableWindow(GetDlgItem(hDlg, edt1), FALSE); 1242 EnableWindow(GetDlgItem(hDlg, stc3),FALSE); 1243 EnableWindow(GetDlgItem(hDlg, edt2), FALSE); 1244 } else { 1245 if (lppd->Flags & PD_PAGENUMS) 1246 CheckRadioButton(hDlg, rad1, rad3, rad3); 1247 } 1248 /* "All xxx pages"... */ 1249 { 1250 /* ansi is ok */ 1251 char resourcestr[64]; 1252 char result[64]; 1253 LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES, 1254 resourcestr, 49); 1255 sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1); 1256 SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result); 1257 } 1258 1259 /* Collate pages 1260 * 1261 * FIXME: The ico3 is not displayed for some reason. I don't know why. 1262 */ 1263 if (lppd->Flags & PD_COLLATE) { 1264 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1265 (LPARAM)PrintStructures->hCollateIcon); 1266 CheckDlgButton(hDlg, chx2, 1); 1267 } else { 1268 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1269 (LPARAM)PrintStructures->hNoCollateIcon); 1270 CheckDlgButton(hDlg, chx2, 0); 1271 } 1272 1273 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 1274 /* if printer doesn't support it: no Collate */ 1275 if (!(lpdm->dmFields & DM_COLLATE)) { 1276 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 1277 EnableWindow(GetDlgItem(hDlg, ico3), FALSE); 1278 } 1279 } 1280 1281 /* nCopies */ 1282 { 1283 INT copies; 1284 if (lppd->hDevMode == 0) 1285 copies = lppd->nCopies; 1286 else 1287 copies = lpdm->dmCopies; 1288 if(copies == 0) copies = 1; 1289 else if(copies < 0) copies = MAX_COPIES; 1290 SetDlgItemInt(hDlg, edt3, copies, FALSE); 1291 } 1292 1293 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 1294 /* if printer doesn't support it: no nCopies */ 1295 if (!(lpdm->dmFields & DM_COPIES)) { 1296 EnableWindow(GetDlgItem(hDlg, edt3), FALSE); 1297 EnableWindow(GetDlgItem(hDlg, stc5), FALSE); 1298 } 1299 } 1300 1301 /* print to file */ 1302 CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0); 1303 if (lppd->Flags & PD_DISABLEPRINTTOFILE) 1304 EnableWindow(GetDlgItem(hDlg, chx1), FALSE); 1305 if (lppd->Flags & PD_HIDEPRINTTOFILE) 1306 ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE); 1307 1308 } else { /* PD_PRINTSETUP */ 1309 BOOL bPortrait = (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT); 1310 1311 PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb2, 1312 PrintStructures->lpPrinterInfo->pPrinterName, 1313 PrintStructures->lpPrinterInfo->pPortName, 1314 lpdm); 1315 PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb3, 1316 PrintStructures->lpPrinterInfo->pPrinterName, 1317 PrintStructures->lpPrinterInfo->pPortName, 1318 lpdm); 1319 CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2); 1320 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1321 (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon : 1322 PrintStructures->hLandscapeIcon)); 1323 1324 } 1325 1326 /* help button */ 1327 if ((lppd->Flags & PD_SHOWHELP)==0) { 1328 /* hide if PD_SHOWHELP not specified */ 1329 ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE); 759 1330 } 760 1331 return TRUE; … … 774 1345 775 1346 /* load Collate ICONs */ 776 /* We load these with LoadImage beca sue they are not a standard1347 /* We load these with LoadImage because they are not a standard 777 1348 size and we don't want them rescaled */ 778 1349 PrintStructures->hCollateIcon = 779 1350 LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0); 780 PrintStructures->hNoCollateIcon = 1351 PrintStructures->hNoCollateIcon = 781 1352 LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0); 782 1353 … … 801 1372 */ 802 1373 if (lppd->Flags & PD_SHOWHELP) { 803 if((PrintStructures->HelpMessageID = 1374 if((PrintStructures->HelpMessageID = 804 1375 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { 805 1376 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); … … 824 1395 if (lppd->nMaxPage < lppd->nMinPage) 825 1396 lppd->nMaxPage = lppd->nMinPage; 826 if (lppd->nMinPage == lppd->nMaxPage) 827 lppd->Flags |= PD_NOPAGENUMS; 1397 if (lppd->nMinPage == lppd->nMaxPage) 1398 lppd->Flags |= PD_NOPAGENUMS; 828 1399 if (lppd->nToPage < lppd->nMinPage) 829 1400 lppd->nToPage = lppd->nMinPage; … … 837 1408 /* if we have the combo box, fill it */ 838 1409 if (GetDlgItem(hDlg,comboID)) { 839 /* Fill Combobox 1410 /* Fill Combobox 840 1411 */ 841 1412 pdn = GlobalLock(lppd->hDevNames); … … 845 1416 else if(pdm) 846 1417 name = pdm->dmDeviceName; 847 PRINTDLG_SetUpPrinterListCombo (hDlg, comboID, name);1418 PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name); 848 1419 if(pdm) GlobalUnlock(lppd->hDevMode); 849 1420 if(pdn) GlobalUnlock(lppd->hDevNames); … … 852 1423 name = HeapAlloc(GetProcessHeap(),0,256); 853 1424 if (GetDlgItemTextA(hDlg, comboID, name, 255)) 854 PRINTDLG_ChangePrinter (hDlg, name, PrintStructures);1425 PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); 855 1426 HeapFree(GetProcessHeap(),0,name); 856 1427 } else { 857 1428 /* else use default printer */ 858 1429 char name[200]; 859 BOOL ret = PRINTDLG_GetDefaultPrinterName (name, sizeof(name));1430 BOOL ret = PRINTDLG_GetDefaultPrinterNameA(name, sizeof(name)); 860 1431 861 1432 if (ret) 862 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 1433 PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); 1434 else 1435 FIXME("No default printer found, expect problems!\n"); 1436 } 1437 return TRUE; 1438 } 1439 1440 static LRESULT PRINTDLG_WMInitDialogW(HWND hDlg, WPARAM wParam, 1441 PRINT_PTRW* PrintStructures) 1442 { 1443 LPPRINTDLGW lppd = PrintStructures->dlg.lpPrintDlg; 1444 DEVNAMES *pdn; 1445 DEVMODEW *pdm; 1446 WCHAR *name = NULL; 1447 UINT comboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4; 1448 1449 /* load Collate ICONs */ 1450 /* We load these with LoadImage because they are not a standard 1451 size and we don't want them rescaled */ 1452 PrintStructures->hCollateIcon = 1453 LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0); 1454 PrintStructures->hNoCollateIcon = 1455 LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0); 1456 1457 /* These can be done with LoadIcon */ 1458 PrintStructures->hPortraitIcon = 1459 LoadIconA(COMDLG32_hInstance, "PD32_PORTRAIT"); 1460 PrintStructures->hLandscapeIcon = 1461 LoadIconA(COMDLG32_hInstance, "PD32_LANDSCAPE"); 1462 1463 if(PrintStructures->hCollateIcon == 0 || 1464 PrintStructures->hNoCollateIcon == 0 || 1465 PrintStructures->hPortraitIcon == 0 || 1466 PrintStructures->hLandscapeIcon == 0) { 1467 ERR("no icon in resourcefile\n"); 1468 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1469 EndDialog(hDlg, FALSE); 1470 } 1471 1472 /* 1473 * if lppd->Flags PD_SHOWHELP is specified, a HELPMESGSTRING message 1474 * must be registered and the Help button must be shown. 1475 */ 1476 if (lppd->Flags & PD_SHOWHELP) { 1477 if((PrintStructures->HelpMessageID = 1478 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { 1479 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); 1480 return FALSE; 1481 } 1482 } else 1483 PrintStructures->HelpMessageID = 0; 1484 1485 if(!(lppd->Flags &PD_PRINTSETUP)) { 1486 PrintStructures->hwndUpDown = 1487 CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER | 1488 UDS_NOTHOUSANDS | UDS_ARROWKEYS | 1489 UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0, 1490 hDlg, UPDOWN_ID, COMDLG32_hInstance, 1491 GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1); 1492 } 1493 1494 /* FIXME: I allow more freedom than either Win95 or WinNT, 1495 * which do not agree to what errors should be thrown or not 1496 * in case nToPage or nFromPage is out-of-range. 1497 */ 1498 if (lppd->nMaxPage < lppd->nMinPage) 1499 lppd->nMaxPage = lppd->nMinPage; 1500 if (lppd->nMinPage == lppd->nMaxPage) 1501 lppd->Flags |= PD_NOPAGENUMS; 1502 if (lppd->nToPage < lppd->nMinPage) 1503 lppd->nToPage = lppd->nMinPage; 1504 if (lppd->nToPage > lppd->nMaxPage) 1505 lppd->nToPage = lppd->nMaxPage; 1506 if (lppd->nFromPage < lppd->nMinPage) 1507 lppd->nFromPage = lppd->nMinPage; 1508 if (lppd->nFromPage > lppd->nMaxPage) 1509 lppd->nFromPage = lppd->nMaxPage; 1510 1511 /* if we have the combo box, fill it */ 1512 if (GetDlgItem(hDlg,comboID)) { 1513 /* Fill Combobox 1514 */ 1515 pdn = GlobalLock(lppd->hDevNames); 1516 pdm = GlobalLock(lppd->hDevMode); 1517 if(pdn) 1518 name = (WCHAR*)pdn + pdn->wDeviceOffset; 1519 else if(pdm) 1520 name = pdm->dmDeviceName; 1521 PRINTDLG_SetUpPrinterListComboW(hDlg, comboID, name); 1522 if(pdm) GlobalUnlock(lppd->hDevMode); 1523 if(pdn) GlobalUnlock(lppd->hDevNames); 1524 1525 /* Now find selected printer and update rest of dlg */ 1526 /* ansi is ok here */ 1527 name = HeapAlloc(GetProcessHeap(),0,256*sizeof(WCHAR)); 1528 if (GetDlgItemTextW(hDlg, comboID, name, 255)) 1529 PRINTDLG_ChangePrinterW(hDlg, name, PrintStructures); 1530 HeapFree(GetProcessHeap(),0,name); 1531 } else { 1532 /* else use default printer */ 1533 WCHAR name[200]; 1534 BOOL ret = PRINTDLG_GetDefaultPrinterNameW(name, sizeof(name)); 1535 1536 if (ret) 1537 PRINTDLG_ChangePrinterW(hDlg, name, PrintStructures); 863 1538 else 864 1539 FIXME("No default printer found, expect problems!\n"); … … 883 1558 PrintStructures->hCollateIcon = 884 1559 LoadIconA(COMDLG32_hInstance, "PD32_COLLATE"); 885 PrintStructures->hNoCollateIcon = 1560 PrintStructures->hNoCollateIcon = 886 1561 LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE"); 887 1562 if(PrintStructures->hCollateIcon == 0 || … … 900 1575 */ 901 1576 if (lppd->Flags & PD_SHOWHELP) { 902 if((PrintStructures->HelpMessageID = 1577 if((PrintStructures->HelpMessageID = 903 1578 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { 904 1579 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); … … 926 1601 } 927 1602 GlobalUnlock16(lppd->hDevMode); 928 } else 1603 } else 929 1604 strcpy(buf,"Default"); 930 1605 SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf); … … 940 1615 if (lppd->nMaxPage < lppd->nMinPage) 941 1616 lppd->nMaxPage = lppd->nMinPage; 942 if (lppd->nMinPage == lppd->nMaxPage) 943 lppd->Flags |= PD_NOPAGENUMS; 1617 if (lppd->nMinPage == lppd->nMaxPage) 1618 lppd->Flags |= PD_NOPAGENUMS; 944 1619 if (lppd->nToPage < lppd->nMinPage) 945 1620 lppd->nToPage = lppd->nMinPage; … … 953 1628 /* If the printer combo box is in the dialog, fill it */ 954 1629 if (GetDlgItem(hDlg,comboID)) { 955 /* Fill Combobox 1630 /* Fill Combobox 956 1631 */ 957 1632 pdn = GlobalLock16(lppd->hDevNames); … … 961 1636 else if(pdm) 962 1637 name = pdm->dmDeviceName; 963 PRINTDLG_SetUpPrinterListCombo (hDlg, comboID, name);1638 PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name); 964 1639 if(pdm) GlobalUnlock16(lppd->hDevMode); 965 1640 if(pdn) GlobalUnlock16(lppd->hDevNames); … … 968 1643 name = HeapAlloc(GetProcessHeap(),0,256); 969 1644 if (GetDlgItemTextA(hDlg, comboID, name, 255)) 970 PRINTDLG_ChangePrinter (hDlg, name, PrintStructures);1645 PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); 971 1646 } else { 972 1647 /* else just use default printer */ 973 1648 char name[200]; 974 BOOL ret = PRINTDLG_GetDefaultPrinterName (name, sizeof(name));1649 BOOL ret = PRINTDLG_GetDefaultPrinterNameA(name, sizeof(name)); 975 1650 976 1651 if (ret) 977 PRINTDLG_ChangePrinter (hDlg, name, PrintStructures);1652 PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures); 978 1653 else 979 1654 FIXME("No default printer found, expect problems!\n"); … … 984 1659 } 985 1660 #endif 986 987 1661 /*********************************************************************** 988 1662 * PRINTDLG_WMCommand [internal] 989 1663 */ 990 static LRESULT PRINTDLG_WMCommand (HWND hDlg, WPARAM wParam,1664 static LRESULT PRINTDLG_WMCommandA(HWND hDlg, WPARAM wParam, 991 1665 LPARAM lParam, PRINT_PTRA* PrintStructures) 992 1666 { … … 998 1672 case IDOK: 999 1673 TRACE(" OK button was hit\n"); 1000 if (PRINTDLG_UpdatePrintDlg (hDlg, PrintStructures)!=TRUE) {1674 if (PRINTDLG_UpdatePrintDlgA(hDlg, PrintStructures)!=TRUE) { 1001 1675 FIXME("Update printdlg was not successful!\n"); 1002 1676 return(FALSE); … … 1012 1686 case pshHelp: 1013 1687 TRACE(" HELP button was hit\n"); 1014 SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 1688 SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 1015 1689 (WPARAM) hDlg, (LPARAM) lppd); 1016 1690 break; … … 1018 1692 case chx2: /* collate pages checkbox */ 1019 1693 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) 1020 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1694 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1021 1695 (LPARAM)PrintStructures->hCollateIcon); 1022 1696 else 1023 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1697 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1024 1698 (LPARAM)PrintStructures->hNoCollateIcon); 1025 break; 1699 break; 1026 1700 case edt1: /* from page nr editbox */ 1027 1701 case edt2: /* to page nr editbox */ … … 1050 1724 { 1051 1725 PRINTDLG16 pdlg; 1052 1726 1053 1727 if (!PrintStructures->dlg.lpPrintDlg16) { 1054 1728 FIXME("The 32bit print dialog does not have this button!?\n"); … … 1058 1732 memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg)); 1059 1733 pdlg.Flags |= PD_PRINTSETUP; 1060 pdlg.hwndOwner = hDlg;1734 pdlg.hwndOwner = HWND_16(hDlg); 1061 1735 if (!PrintDlg16(&pdlg)) 1062 1736 break; … … 1075 1749 break; 1076 1750 } 1077 DocumentPropertiesA(hDlg, hPrinter, PrinterName, 1751 DocumentPropertiesA(hDlg, hPrinter, PrinterName, 1078 1752 PrintStructures->lpDevMode, 1079 1753 PrintStructures->lpDevMode, … … 1086 1760 if (lppd->Flags & PD_PRINTSETUP) 1087 1761 { 1088 #ifdef __WIN32OS2__1089 lpdm->dmOrientation = DMORIENT_PORTRAIT;1090 #else1091 1762 lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT; 1092 #endif1093 1763 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1094 1764 (LPARAM)(PrintStructures->hPortraitIcon)); 1095 1765 } 1096 1766 break; 1097 1767 1098 1768 case rad2: /* Paperorientation */ 1099 1769 if (lppd->Flags & PD_PRINTSETUP) 1100 1770 { 1101 #ifdef __WIN32OS2__1102 lpdm->dmOrientation = DMORIENT_LANDSCAPE;1103 #else1104 1771 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE; 1105 #endif1106 1772 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1107 1773 (LPARAM)(PrintStructures->hLandscapeIcon)); 1108 1774 } 1109 1775 break; 1110 1776 1111 1777 case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */ 1112 1778 if (PrinterComboID != wParam) { … … 1119 1785 char PrinterName[256]; 1120 1786 GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255); 1121 PRINTDLG_ChangePrinter (hDlg, PrinterName, PrintStructures);1787 PRINTDLG_ChangePrinterA(hDlg, PrinterName, PrintStructures); 1122 1788 } 1123 1789 break; … … 1127 1793 DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0); 1128 1794 if(Sel != CB_ERR) 1129 #ifdef __WIN32OS2__1130 lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,1131 #else1132 1795 lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2, 1133 #endif1134 1796 CB_GETITEMDATA, 1135 1797 Sel, 0); … … 1145 1807 0); 1146 1808 } 1147 break; 1809 break; 1148 1810 } 1149 1811 if(lppd->Flags & PD_PRINTSETUP) { … … 1152 1814 case rad2: 1153 1815 if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) { 1154 #ifdef __WIN32OS2__1155 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {1156 lpdm->dmOrientation = DMORIENT_PORTRAIT;1157 #else1158 1816 if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) { 1159 1817 lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT; 1160 #endif1161 1818 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE, 1162 1819 (WPARAM)IMAGE_ICON, … … 1167 1824 } 1168 1825 } else { 1169 #ifdef __WIN32OS2__1170 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {1171 lpdm->dmOrientation = DMORIENT_LANDSCAPE;1172 #else1173 1826 if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) { 1174 1827 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE; 1175 #endif1176 1828 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE, 1177 1829 (WPARAM)IMAGE_ICON, … … 1186 1838 } 1187 1839 return FALSE; 1188 } 1840 } 1841 1842 static LRESULT PRINTDLG_WMCommandW(HWND hDlg, WPARAM wParam, 1843 LPARAM lParam, PRINT_PTRW* PrintStructures) 1844 { 1845 LPPRINTDLGW lppd = PrintStructures->dlg.lpPrintDlg; 1846 UINT PrinterComboID = (lppd->Flags & PD_PRINTSETUP) ? cmb1 : cmb4; 1847 LPDEVMODEW lpdm = PrintStructures->lpDevMode; 1848 1849 switch (LOWORD(wParam)) { 1850 case IDOK: 1851 TRACE(" OK button was hit\n"); 1852 if (PRINTDLG_UpdatePrintDlgW(hDlg, PrintStructures)!=TRUE) { 1853 FIXME("Update printdlg was not successful!\n"); 1854 return(FALSE); 1855 } 1856 EndDialog(hDlg, TRUE); 1857 return(TRUE); 1858 1859 case IDCANCEL: 1860 TRACE(" CANCEL button was hit\n"); 1861 EndDialog(hDlg, FALSE); 1862 return(FALSE); 1863 1864 case pshHelp: 1865 TRACE(" HELP button was hit\n"); 1866 SendMessageW(lppd->hwndOwner, PrintStructures->HelpMessageID, 1867 (WPARAM) hDlg, (LPARAM) lppd); 1868 break; 1869 1870 case chx2: /* collate pages checkbox */ 1871 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) 1872 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1873 (LPARAM)PrintStructures->hCollateIcon); 1874 else 1875 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1876 (LPARAM)PrintStructures->hNoCollateIcon); 1877 break; 1878 case edt1: /* from page nr editbox */ 1879 case edt2: /* to page nr editbox */ 1880 if (HIWORD(wParam)==EN_CHANGE) { 1881 WORD nToPage; 1882 WORD nFromPage; 1883 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE); 1884 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE); 1885 if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage) 1886 CheckRadioButton(hDlg, rad1, rad3, rad3); 1887 } 1888 break; 1889 1890 case edt3: 1891 if(HIWORD(wParam) == EN_CHANGE) { 1892 INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 1893 if(copies <= 1) 1894 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 1895 else 1896 EnableWindow(GetDlgItem(hDlg, chx2), TRUE); 1897 } 1898 break; 1899 1900 case psh1: /* Print Setup */ 1901 { 1902 ERR("psh1 is called from 16bit code only, we should not get here.\n"); 1903 } 1904 break; 1905 case psh2: /* Properties button */ 1906 { 1907 HANDLE hPrinter; 1908 WCHAR PrinterName[256]; 1909 1910 GetDlgItemTextW(hDlg, PrinterComboID, PrinterName, 255); 1911 if (!OpenPrinterW(PrinterName, &hPrinter, NULL)) { 1912 FIXME(" Call to OpenPrinter did not succeed!\n"); 1913 break; 1914 } 1915 DocumentPropertiesW(hDlg, hPrinter, PrinterName, 1916 PrintStructures->lpDevMode, 1917 PrintStructures->lpDevMode, 1918 DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT); 1919 ClosePrinter(hPrinter); 1920 break; 1921 } 1922 1923 case rad1: /* Paperorientation */ 1924 if (lppd->Flags & PD_PRINTSETUP) 1925 { 1926 lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT; 1927 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1928 (LPARAM)(PrintStructures->hPortraitIcon)); 1929 } 1930 break; 1931 1932 case rad2: /* Paperorientation */ 1933 if (lppd->Flags & PD_PRINTSETUP) 1934 { 1935 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE; 1936 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1937 (LPARAM)(PrintStructures->hLandscapeIcon)); 1938 } 1939 break; 1940 1941 case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */ 1942 if (PrinterComboID != wParam) { 1943 FIXME("No handling for print quality combo box yet.\n"); 1944 break; 1945 } 1946 /* FALLTHROUGH */ 1947 case cmb4: /* Printer combobox */ 1948 if (HIWORD(wParam)==CBN_SELCHANGE) { 1949 WCHAR PrinterName[256]; 1950 GetDlgItemTextW(hDlg, LOWORD(wParam), PrinterName, 255); 1951 PRINTDLG_ChangePrinterW(hDlg, PrinterName, PrintStructures); 1952 } 1953 break; 1954 1955 case cmb2: /* Papersize */ 1956 { 1957 DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0); 1958 if(Sel != CB_ERR) 1959 lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2, 1960 CB_GETITEMDATA, 1961 Sel, 0); 1962 } 1963 break; 1964 1965 case cmb3: /* Bin */ 1966 { 1967 DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0); 1968 if(Sel != CB_ERR) 1969 lpdm->dmDefaultSource = SendDlgItemMessageW(hDlg, cmb3, 1970 CB_GETITEMDATA, Sel, 1971 0); 1972 } 1973 break; 1974 } 1975 if(lppd->Flags & PD_PRINTSETUP) { 1976 switch (LOWORD(wParam)) { 1977 case rad1: /* orientation */ 1978 case rad2: 1979 if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) { 1980 if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) { 1981 lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT; 1982 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE, 1983 (WPARAM)IMAGE_ICON, 1984 (LPARAM)PrintStructures->hPortraitIcon); 1985 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, 1986 (WPARAM)IMAGE_ICON, 1987 (LPARAM)PrintStructures->hPortraitIcon); 1988 } 1989 } else { 1990 if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) { 1991 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE; 1992 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE, 1993 (WPARAM)IMAGE_ICON, 1994 (LPARAM)PrintStructures->hLandscapeIcon); 1995 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, 1996 (WPARAM)IMAGE_ICON, 1997 (LPARAM)PrintStructures->hLandscapeIcon); 1998 } 1999 } 2000 break; 2001 } 2002 } 2003 return FALSE; 2004 } 1189 2005 1190 2006 /*********************************************************************** 1191 2007 * PrintDlgProcA [internal] 1192 2008 */ 1193 #ifdef __WIN32OS2__1194 LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,1195 LPARAM lParam)1196 #else1197 2009 BOOL WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, 1198 2010 LPARAM lParam) 1199 #endif1200 2011 { 1201 2012 PRINT_PTRA* PrintStructures; … … 1203 2014 1204 2015 if (uMsg!=WM_INITDIALOG) { 1205 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);2016 PrintStructures = (PRINT_PTRA*)GetPropA(hDlg,"__WINE_PRINTDLGDATA"); 1206 2017 if (!PrintStructures) 1207 2018 return FALSE; 1208 2019 } else { 1209 2020 PrintStructures = (PRINT_PTRA*) lParam; 1210 Set WindowLongA(hDlg, DWL_USER, lParam);2021 SetPropA(hDlg,"__WINE_PRINTDLGDATA",lParam); 1211 2022 res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures); 1212 2023 … … 1214 2025 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook( 1215 2026 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg 1216 ); 2027 ); 1217 2028 return res; 1218 2029 } 1219 2030 1220 2031 if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) { 1221 2032 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam, … … 1226 2037 switch (uMsg) { 1227 2038 case WM_COMMAND: 1228 return PRINTDLG_WMCommand (hDlg, wParam, lParam, PrintStructures);2039 return PRINTDLG_WMCommandA(hDlg, wParam, lParam, PrintStructures); 1229 2040 1230 2041 case WM_DESTROY: … … 1236 2047 DestroyWindow(PrintStructures->hwndUpDown); 1237 2048 return FALSE; 1238 } 2049 } 2050 return res; 2051 } 2052 2053 BOOL WINAPI PrintDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, 2054 LPARAM lParam) 2055 { 2056 PRINT_PTRW* PrintStructures; 2057 LRESULT res=FALSE; 2058 2059 if (uMsg!=WM_INITDIALOG) { 2060 PrintStructures = (PRINT_PTRW*) GetWindowLongA(hDlg, DWL_USER); 2061 if (!PrintStructures) 2062 return FALSE; 2063 } else { 2064 PrintStructures = (PRINT_PTRW*) lParam; 2065 SetWindowLongA(hDlg, DWL_USER, lParam); 2066 res = PRINTDLG_WMInitDialogW(hDlg, wParam, PrintStructures); 2067 2068 if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) 2069 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook( 2070 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg 2071 ); 2072 return res; 2073 } 2074 2075 if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) { 2076 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam, 2077 lParam); 2078 if(res) return res; 2079 } 2080 2081 switch (uMsg) { 2082 case WM_COMMAND: 2083 return PRINTDLG_WMCommandW(hDlg, wParam, lParam, PrintStructures); 2084 2085 case WM_DESTROY: 2086 DestroyIcon(PrintStructures->hCollateIcon); 2087 DestroyIcon(PrintStructures->hNoCollateIcon); 2088 DestroyIcon(PrintStructures->hPortraitIcon); 2089 DestroyIcon(PrintStructures->hLandscapeIcon); 2090 if(PrintStructures->hwndUpDown) 2091 DestroyWindow(PrintStructures->hwndUpDown); 2092 return FALSE; 2093 } 1239 2094 return res; 1240 2095 } … … 1250 2105 static HGLOBAL16 PRINTDLG_Get16TemplateFrom32(char *PrintResourceName) 1251 2106 { 1252 HANDLE hResInfo, hDlgTmpl32; 2107 HRSRC hResInfo; 2108 HGLOBAL hDlgTmpl32; 1253 2109 LPCVOID template32; 1254 2110 DWORD size; 1255 2111 HGLOBAL16 hGlobal16; 1256 2112 LPVOID template; 1257 2113 1258 2114 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 1259 2115 PrintResourceName, RT_DIALOGA))) … … 1295 2151 * 1296 2152 */ 1297 static HGLOBAL PRINTDLG_GetDlgTemplate(PRINTDLGA *lppd) 1298 { 1299 HGLOBAL hDlgTmpl, hResInfo; 2153 static HGLOBAL PRINTDLG_GetDlgTemplateA(PRINTDLGA *lppd) 2154 { 2155 HRSRC hResInfo; 2156 HGLOBAL hDlgTmpl; 1300 2157 1301 2158 if (lppd->Flags & PD_PRINTSETUP) { 1302 2159 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 1303 2160 hDlgTmpl = lppd->hSetupTemplate; 1304 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 2161 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 1305 2162 hResInfo = FindResourceA(lppd->hInstance, 1306 2163 lppd->lpSetupTemplateName, RT_DIALOGA); … … 1328 2185 } 1329 2186 1330 1331 #ifndef __WIN32OS2__ 1332 /************************************************************ 1333 * 1334 * PRINTDLG_GetDlgTemplate 1335 * 1336 */ 1337 static HGLOBAL16 PRINTDLG_GetDlgTemplate16(PRINTDLG16 *lppd) 1338 { 1339 HGLOBAL16 hDlgTmpl, hResInfo; 2187 static HGLOBAL PRINTDLG_GetDlgTemplateW(PRINTDLGW *lppd) 2188 { 2189 HRSRC hResInfo; 2190 HGLOBAL hDlgTmpl; 2191 const WCHAR xpsetup[] = { 'P','R','I','N','T','3','2','_','S','E','T','U','P',0}; 2192 const WCHAR xprint[] = { 'P','R','I','N','T','3','2',0}; 1340 2193 1341 2194 if (lppd->Flags & PD_PRINTSETUP) { 1342 2195 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 1343 2196 hDlgTmpl = lppd->hSetupTemplate; 1344 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 2197 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 2198 hResInfo = FindResourceW(lppd->hInstance, 2199 lppd->lpSetupTemplateName, RT_DIALOGW); 2200 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 2201 } else { 2202 hResInfo = FindResourceW(COMDLG32_hInstance, xpsetup, RT_DIALOGW); 2203 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 2204 } 2205 } else { 2206 if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) { 2207 hDlgTmpl = lppd->hPrintTemplate; 2208 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) { 2209 hResInfo = FindResourceW(lppd->hInstance, 2210 lppd->lpPrintTemplateName, 2211 RT_DIALOGW); 2212 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 2213 } else { 2214 hResInfo = FindResourceW(COMDLG32_hInstance, xprint, RT_DIALOGW); 2215 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 2216 } 2217 } 2218 return hDlgTmpl; 2219 } 2220 2221 2222 #ifndef __WIN32OS2__ 2223 /************************************************************ 2224 * 2225 * PRINTDLG_GetDlgTemplate 2226 * 2227 */ 2228 static HGLOBAL16 PRINTDLG_GetDlgTemplate16(PRINTDLG16 *lppd) 2229 { 2230 HGLOBAL16 hDlgTmpl, hResInfo; 2231 2232 if (lppd->Flags & PD_PRINTSETUP) { 2233 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 2234 hDlgTmpl = lppd->hSetupTemplate; 2235 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 1345 2236 hResInfo = FindResource16(lppd->hInstance, 1346 2237 MapSL(lppd->lpSetupTemplateName), RT_DIALOGA); … … 1370 2261 * 1371 2262 */ 1372 static BOOL PRINTDLG_CreateDC (LPPRINTDLGA lppd)2263 static BOOL PRINTDLG_CreateDCA(LPPRINTDLGA lppd) 1373 2264 { 1374 2265 DEVNAMES *pdn = GlobalLock(lppd->hDevNames); … … 1391 2282 } 1392 2283 2284 static BOOL PRINTDLG_CreateDCW(LPPRINTDLGW lppd) 2285 { 2286 DEVNAMES *pdn = GlobalLock(lppd->hDevNames); 2287 DEVMODEW *pdm = GlobalLock(lppd->hDevMode); 2288 2289 if(lppd->Flags & PD_RETURNDC) { 2290 lppd->hDC = CreateDCW((WCHAR*)pdn + pdn->wDriverOffset, 2291 (WCHAR*)pdn + pdn->wDeviceOffset, 2292 (WCHAR*)pdn + pdn->wOutputOffset, 2293 pdm ); 2294 } else if(lppd->Flags & PD_RETURNIC) { 2295 lppd->hDC = CreateICW((WCHAR*)pdn + pdn->wDriverOffset, 2296 (WCHAR*)pdn + pdn->wDeviceOffset, 2297 (WCHAR*)pdn + pdn->wOutputOffset, 2298 pdm ); 2299 } 2300 GlobalUnlock(lppd->hDevNames); 2301 GlobalUnlock(lppd->hDevMode); 2302 return lppd->hDC ? TRUE : FALSE; 2303 } 2304 1393 2305 #ifndef __WIN32OS2__ 1394 2306 static BOOL PRINTDLG_CreateDC16(LPPRINTDLG16 lppd) … … 1431 2343 * * The Paper Orientation Icons are not implemented yet. 1432 2344 * * The Properties Button(s) should call DocumentPropertiesA(). 1433 * * Settings are not yet taken from a provided DevMode or 2345 * * Settings are not yet taken from a provided DevMode or 1434 2346 * default printer settings. 1435 2347 */ 2348 1436 2349 BOOL WINAPI PrintDlgA( 1437 2350 LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */ … … 1441 2354 LPVOID ptr; 1442 2355 HINSTANCE hInst = GetWindowLongA( lppd->hwndOwner, GWL_HINSTANCE ); 1443 1444 #ifdef __WIN32OS2__1445 dprintf(("PrintDlgA %x", lppd));1446 #endif1447 2356 1448 2357 if(TRACE_ON(commdlg)) { … … 1464 2373 WARN("structure size failure !!!\n"); 1465 2374 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); 1466 return FALSE; 2375 return FALSE; 1467 2376 } 1468 2377 … … 1475 2384 if(lppd->hDevMode || lppd->hDevNames) { 1476 2385 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n"); 1477 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 2386 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1478 2387 return FALSE; 1479 2388 } 1480 2389 if(!PRINTDLG_OpenDefaultPrinter(&hprn)) { 1481 2390 WARN("Can't find default printer\n"); 1482 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 2391 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 1483 2392 return FALSE; 1484 2393 } … … 1492 2401 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) { 1493 2402 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName); 1494 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 2403 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1495 2404 return FALSE; 1496 2405 } … … 1514 2423 PRINT_PTRA *PrintStructures; 1515 2424 1516 /* load Dialog resources, 1517 * depending on Flags indicates Print32 or Print32_setup dialog 2425 /* load Dialog resources, 2426 * depending on Flags indicates Print32 or Print32_setup dialog 1518 2427 */ 1519 hDlgTmpl = PRINTDLG_GetDlgTemplate (lppd);2428 hDlgTmpl = PRINTDLG_GetDlgTemplateA(lppd); 1520 2429 if (!hDlgTmpl) { 1521 2430 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); … … 1585 2494 } 1586 2495 if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC)) 1587 bRet = PRINTDLG_CreateDC(lppd); 1588 1589 TRACE("exit! (%d)\n", bRet); 1590 return bRet; 1591 } 1592 1593 #ifndef __WIN32OS2__ 2496 bRet = PRINTDLG_CreateDCA(lppd); 2497 2498 TRACE("exit! (%d)\n", bRet); 2499 return bRet; 2500 } 2501 1594 2502 /*********************************************************************** 1595 * PrintDlg (COMMDLG.20) 1596 * 1597 * Displays the the PRINT dialog box, which enables the user to specify 1598 * specific properties of the print job. 1599 * 1600 * RETURNS 1601 * nonzero if the user pressed the OK button 1602 * zero if the user cancelled the window or an error occurred 1603 * 1604 * BUGS 1605 * * calls up to the 32-bit versions of the Dialogs, which look different 1606 * * Customizing is *not* implemented. 2503 * PrintDlgW (COMDLG32.@) 1607 2504 */ 1608 1609 BOOL16 WINAPI PrintDlg16( 1610 LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */1611 ){2505 BOOL WINAPI PrintDlgW( 2506 LPPRINTDLGW lppd /* [in/out] ptr to PRINTDLG32 struct */ 2507 ) 2508 { 1612 2509 BOOL bRet = FALSE; 1613 2510 LPVOID ptr; … … 1629 2526 } 1630 2527 2528 if(lppd->lStructSize != sizeof(PRINTDLGW)) { 2529 WARN("structure size failure !!!\n"); 2530 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); 2531 return FALSE; 2532 } 2533 2534 if(lppd->Flags & PD_RETURNDEFAULT) { 2535 PRINTER_INFO_2W *pbuf; 2536 DRIVER_INFO_3W *dbuf; 2537 HANDLE hprn; 2538 DWORD needed; 2539 2540 if(lppd->hDevMode || lppd->hDevNames) { 2541 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n"); 2542 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 2543 return FALSE; 2544 } 2545 if(!PRINTDLG_OpenDefaultPrinter(&hprn)) { 2546 WARN("Can't find default printer\n"); 2547 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 2548 return FALSE; 2549 } 2550 2551 GetPrinterW(hprn, 2, NULL, 0, &needed); 2552 pbuf = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*needed); 2553 GetPrinterW(hprn, 2, (LPBYTE)pbuf, needed, &needed); 2554 2555 GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed); 2556 dbuf = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*needed); 2557 if (!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) { 2558 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),debugstr_w(pbuf->pPrinterName)); 2559 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 2560 return FALSE; 2561 } 2562 ClosePrinter(hprn); 2563 2564 PRINTDLG_CreateDevNamesW(&(lppd->hDevNames), 2565 dbuf->pDriverPath, 2566 pbuf->pPrinterName, 2567 pbuf->pPortName); 2568 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize + 2569 pbuf->pDevMode->dmDriverExtra); 2570 ptr = GlobalLock(lppd->hDevMode); 2571 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize + 2572 pbuf->pDevMode->dmDriverExtra); 2573 GlobalUnlock(lppd->hDevMode); 2574 HeapFree(GetProcessHeap(), 0, pbuf); 2575 HeapFree(GetProcessHeap(), 0, dbuf); 2576 bRet = TRUE; 2577 } else { 2578 HGLOBAL hDlgTmpl; 2579 PRINT_PTRW *PrintStructures; 2580 2581 /* load Dialog resources, 2582 * depending on Flags indicates Print32 or Print32_setup dialog 2583 */ 2584 hDlgTmpl = PRINTDLG_GetDlgTemplateW(lppd); 2585 if (!hDlgTmpl) { 2586 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 2587 return FALSE; 2588 } 2589 ptr = LockResource( hDlgTmpl ); 2590 if (!ptr) { 2591 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 2592 return FALSE; 2593 } 2594 2595 PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2596 sizeof(PRINT_PTRW)); 2597 PrintStructures->dlg.lpPrintDlg = lppd; 2598 2599 /* and create & process the dialog . 2600 * -1 is failure, 0 is broken hwnd, everything else is ok. 2601 */ 2602 bRet = (0<DialogBoxIndirectParamW(hInst, ptr, lppd->hwndOwner, 2603 PrintDlgProcW, 2604 (LPARAM)PrintStructures)); 2605 2606 if(bRet) { 2607 DEVMODEW *lpdm = PrintStructures->lpDevMode, *lpdmReturn; 2608 PRINTER_INFO_2W *pi = PrintStructures->lpPrinterInfo; 2609 DRIVER_INFO_3W *di = PrintStructures->lpDriverInfo; 2610 2611 if (lppd->hDevMode == 0) { 2612 TRACE(" No hDevMode yet... Need to create my own\n"); 2613 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, 2614 lpdm->dmSize + lpdm->dmDriverExtra); 2615 } else { 2616 WORD locks; 2617 if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) { 2618 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks); 2619 while(locks--) { 2620 GlobalUnlock(lppd->hDevMode); 2621 TRACE("Now got %d locks\n", locks); 2622 } 2623 } 2624 lppd->hDevMode = GlobalReAlloc(lppd->hDevMode, 2625 lpdm->dmSize + lpdm->dmDriverExtra, 2626 GMEM_MOVEABLE); 2627 } 2628 lpdmReturn = GlobalLock(lppd->hDevMode); 2629 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra); 2630 2631 if (lppd->hDevNames != 0) { 2632 WORD locks; 2633 if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) { 2634 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks); 2635 while(locks--) 2636 GlobalUnlock(lppd->hDevNames); 2637 } 2638 } 2639 PRINTDLG_CreateDevNamesW(&(lppd->hDevNames), 2640 di->pDriverPath, 2641 pi->pPrinterName, 2642 pi->pPortName 2643 ); 2644 GlobalUnlock(lppd->hDevMode); 2645 } 2646 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode); 2647 HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo); 2648 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo); 2649 HeapFree(GetProcessHeap(), 0, PrintStructures); 2650 } 2651 if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC)) 2652 bRet = PRINTDLG_CreateDCW(lppd); 2653 2654 TRACE("exit! (%d)\n", bRet); 2655 return bRet; 2656 } 2657 2658 #ifndef __WIN32OS2__ 2659 /*********************************************************************** 2660 * PrintDlg (COMMDLG.20) 2661 * 2662 * Displays the the PRINT dialog box, which enables the user to specify 2663 * specific properties of the print job. 2664 * 2665 * RETURNS 2666 * nonzero if the user pressed the OK button 2667 * zero if the user cancelled the window or an error occurred 2668 * 2669 * BUGS 2670 * * calls up to the 32-bit versions of the Dialogs, which look different 2671 * * Customizing is *not* implemented. 2672 */ 2673 2674 BOOL16 WINAPI PrintDlg16( 2675 LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */ 2676 ) { 2677 BOOL bRet = FALSE; 2678 LPVOID ptr; 2679 HINSTANCE hInst = GetWindowLongA( HWND_32(lppd->hwndOwner), GWL_HINSTANCE ); 2680 2681 if(TRACE_ON(commdlg)) { 2682 char flagstr[1000] = ""; 2683 struct pd_flags *pflag = pd_flags; 2684 for( ; pflag->name; pflag++) { 2685 if(lppd->Flags & pflag->flag) 2686 strcat(flagstr, pflag->name); 2687 } 2688 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n" 2689 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n" 2690 "flags %08lx (%s)\n", 2691 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames, 2692 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage, 2693 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr); 2694 } 2695 1631 2696 if(lppd->lStructSize != sizeof(PRINTDLG16)) { 1632 2697 ERR("structure size (%ld/%d)\n",lppd->lStructSize,sizeof(PRINTDLG16)); … … 1643 2708 if(lppd->hDevMode || lppd->hDevNames) { 1644 2709 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n"); 1645 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 2710 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1646 2711 return FALSE; 1647 2712 } 1648 2713 if(!PRINTDLG_OpenDefaultPrinter(&hprn)) { 1649 2714 WARN("Can't find default printer\n"); 1650 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 2715 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 1651 2716 return FALSE; 1652 2717 } … … 1660 2725 ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n", 1661 2726 pbuf->pPrinterName,GetLastError()); 1662 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 2727 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1663 2728 return FALSE; 1664 2729 } … … 1681 2746 PRINT_PTRA *PrintStructures; 1682 2747 1683 /* load Dialog resources, 1684 * depending on Flags indicates Print32 or Print32_setup dialog 2748 /* load Dialog resources, 2749 * depending on Flags indicates Print32 or Print32_setup dialog 1685 2750 */ 1686 2751 hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd); … … 1695 2760 #define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x; 1696 2761 #define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x); 1697 CVAL(Flags);CVAL(hwndOwner);CVAL(hDC); 2762 CVAL(Flags); 2763 PrintStructures->dlg.lpPrintDlg->hwndOwner = HWND_32(lppd->hwndOwner); 2764 CVAL(hDC); 1698 2765 CVAL(nFromPage);CVAL(nToPage);CVAL(nMinPage);CVAL(nMaxPage); 1699 2766 CVAL(nCopies);CVAL(hInstance);CVAL(lCustData); … … 1765 2832 bRet = PRINTDLG_CreateDC16(lppd); 1766 2833 1767 TRACE("exit! (%d)\n", bRet); 1768 return bRet; 2834 TRACE("exit! (%d)\n", bRet); 2835 return bRet; 1769 2836 } 1770 2837 #endif 1771 1772 1773 /***********************************************************************1774 * PrintDlgW (COMDLG32.@)1775 */1776 BOOL WINAPI PrintDlgW( LPPRINTDLGW printdlg )1777 {1778 #ifdef __WIN32OS2__1779 dprintf(("PrintDlgW %x NOT IMPLEMENTED", printdlg));1780 #endif1781 FIXME("A really empty stub\n" );1782 return FALSE;1783 }1784 2838 1785 2839 /*********************************************************************** … … 1799 2853 typedef struct { 1800 2854 LPPAGESETUPDLGA dlga; 1801 1802 2855 PRINTDLGA pdlg; 1803 } PageSetupData; 1804 1805 static HGLOBAL PRINTDLG_GetPGSTemplate(PAGESETUPDLGA *lppd) 1806 { 1807 HGLOBAL hDlgTmpl, hResInfo; 2856 } PageSetupDataA; 2857 2858 typedef struct { 2859 LPPAGESETUPDLGW dlga; 2860 PRINTDLGW pdlg; 2861 } PageSetupDataW; 2862 2863 static HGLOBAL PRINTDLG_GetPGSTemplateA(PAGESETUPDLGA *lppd) 2864 { 2865 HRSRC hResInfo; 2866 HGLOBAL hDlgTmpl; 1808 2867 1809 2868 if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATEHANDLE) { 1810 2869 hDlgTmpl = lppd->hPageSetupTemplate; 1811 } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) { 2870 } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) { 1812 2871 hResInfo = FindResourceA(lppd->hInstance, 1813 2872 lppd->lpPageSetupTemplateName, RT_DIALOGA); … … 1815 2874 } else { 1816 2875 hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA); 2876 hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo); 2877 } 2878 return hDlgTmpl; 2879 } 2880 2881 static HGLOBAL PRINTDLG_GetPGSTemplateW(PAGESETUPDLGW *lppd) 2882 { 2883 HRSRC hResInfo; 2884 HGLOBAL hDlgTmpl; 2885 2886 if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATEHANDLE) { 2887 hDlgTmpl = lppd->hPageSetupTemplate; 2888 } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) { 2889 hResInfo = FindResourceW(lppd->hInstance, 2890 lppd->lpPageSetupTemplateName, RT_DIALOGW); 2891 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 2892 } else { 2893 hResInfo = FindResourceW(COMDLG32_hInstance,(LPCWSTR)PAGESETUPDLGORD,RT_DIALOGW); 1817 2894 hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo); 1818 2895 } … … 1828 2905 */ 1829 2906 dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; 1830 FIXME("returning %ld/100 mm \n",size);1831 2907 return 10*size; 1832 2908 } … … 1847 2923 1848 2924 static void 1849 _c_size2str (PageSetupData*pda,DWORD size,LPSTR strout) {2925 _c_size2strA(PageSetupDataA *pda,DWORD size,LPSTR strout) { 1850 2926 strcpy(strout,"<undef>"); 1851 2927 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) { … … 1861 2937 return; 1862 2938 } 2939 static void 2940 _c_size2strW(PageSetupDataW *pda,DWORD size,LPSTR strout) { 2941 strcpy(strout,"<undef>"); 2942 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) { 2943 sprintf(strout,"%.2fmm",(size*1.0)/100.0); 2944 return; 2945 } 2946 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) { 2947 sprintf(strout,"%.2fin",(size*1.0)/1000.0); 2948 return; 2949 } 2950 pda->dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; 2951 sprintf(strout,"%.2fmm",(size*1.0)/100.0); 2952 return; 2953 } 1863 2954 1864 2955 static DWORD 1865 _c_str2size(P ageSetupData *pda,LPCSTR strin) {2956 _c_str2size(PAGESETUPDLGA *dlga,LPCSTR strin) { 1866 2957 float val; 1867 2958 char rest[200]; … … 1872 2963 1873 2964 if (!strcmp(rest,"in") || !strcmp(rest,"inch")) { 1874 if ( pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)2965 if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) 1875 2966 return 1000*val; 1876 2967 else … … 1881 2972 1882 2973 if (!strcmp(rest,"mm")) { 1883 if ( pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)2974 if (dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) 1884 2975 return 100*val; 1885 2976 else … … 1888 2979 if (rest[0]=='\0') { 1889 2980 /* use application supplied default */ 1890 if ( pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {2981 if (dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) { 1891 2982 /* 100*mm */ 1892 2983 return 100.0*val; 1893 2984 } 1894 if ( pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {2985 if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) { 1895 2986 /* 1000*inch */ 1896 2987 return 1000.0*val; … … 1907 2998 */ 1908 2999 static BOOL 1909 PRINTDLG_PS_UpdateDlgStruct (HWND hDlg, PageSetupData*pda) {3000 PRINTDLG_PS_UpdateDlgStructA(HWND hDlg, PageSetupDataA *pda) { 1910 3001 DEVNAMES *dn; 1911 3002 DEVMODEA *dm; … … 1913 3004 char papername[64]; 1914 3005 char buf[200]; 1915 3006 1916 3007 dn = GlobalLock(pda->pdlg.hDevNames); 1917 3008 dm = GlobalLock(pda->pdlg.hDevMode); 1918 3009 devname = ((char*)dn)+dn->wDeviceOffset; 1919 3010 portname = ((char*)dn)+dn->wOutputOffset; 1920 PRINTDLG_SetUpPaperComboBox (hDlg,cmb2,devname,portname,dm);1921 PRINTDLG_SetUpPaperComboBox (hDlg,cmb3,devname,portname,dm);3011 PRINTDLG_SetUpPaperComboBoxA(hDlg,cmb2,devname,portname,dm); 3012 PRINTDLG_SetUpPaperComboBoxA(hDlg,cmb3,devname,portname,dm); 1922 3013 1923 3014 if (GetDlgItemTextA(hDlg,cmb2,papername,sizeof(papername))>0) { 1924 PRINTDLG_PaperSize (&(pda->pdlg),papername,&(pda->dlga->ptPaperSize));3015 PRINTDLG_PaperSizeA(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize)); 1925 3016 pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x); 1926 3017 pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y); 1927 3018 } else 1928 3019 FIXME("could not get dialog text for papersize cmbbox?\n"); 1929 #define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size(pda ,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); }3020 #define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size(pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); } 1930 3021 GETVAL(edt4,pda->dlga->rtMargin.left); 1931 3022 GETVAL(edt5,pda->dlga->rtMargin.top); … … 1946 3037 } 1947 3038 3039 static BOOL 3040 PRINTDLG_PS_UpdateDlgStructW(HWND hDlg, PageSetupDataW *pda) { 3041 DEVNAMES *dn; 3042 DEVMODEW *dm; 3043 LPWSTR devname,portname; 3044 WCHAR papername[64]; 3045 3046 char buf[200]; 3047 3048 dn = GlobalLock(pda->pdlg.hDevNames); 3049 dm = GlobalLock(pda->pdlg.hDevMode); 3050 devname = ((WCHAR*)dn)+dn->wDeviceOffset; 3051 portname = ((WCHAR*)dn)+dn->wOutputOffset; 3052 PRINTDLG_SetUpPaperComboBoxW(hDlg,cmb2,devname,portname,dm); 3053 PRINTDLG_SetUpPaperComboBoxW(hDlg,cmb3,devname,portname,dm); 3054 3055 if (GetDlgItemTextW(hDlg,cmb2,papername,sizeof(papername))>0) { 3056 PRINTDLG_PaperSizeW(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize)); 3057 pda->dlga->ptPaperSize.x = _c_10mm2size((LPPAGESETUPDLGA)pda->dlga,pda->dlga->ptPaperSize.x); 3058 pda->dlga->ptPaperSize.y = _c_10mm2size((LPPAGESETUPDLGA)pda->dlga,pda->dlga->ptPaperSize.y); 3059 } else 3060 FIXME("could not get dialog text for papersize cmbbox?\n"); 3061 #define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2size((LPPAGESETUPDLGA)pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); } 3062 GETVAL(edt4,pda->dlga->rtMargin.left); 3063 GETVAL(edt5,pda->dlga->rtMargin.top); 3064 GETVAL(edt6,pda->dlga->rtMargin.right); 3065 GETVAL(edt7,pda->dlga->rtMargin.bottom); 3066 #undef GETVAL 3067 3068 /* If we are in landscape, swap x and y of page size */ 3069 if (IsDlgButtonChecked(hDlg, rad2)) { 3070 DWORD tmp; 3071 tmp = pda->dlga->ptPaperSize.x; 3072 pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y; 3073 pda->dlga->ptPaperSize.y = tmp; 3074 } 3075 GlobalUnlock(pda->pdlg.hDevNames); 3076 GlobalUnlock(pda->pdlg.hDevMode); 3077 return TRUE; 3078 } 3079 1948 3080 /* 1949 3081 * This is called after returning from PrintDlg(). 1950 3082 */ 1951 3083 static BOOL 1952 PRINTDLG_PS_ChangePrinter (HWND hDlg, PageSetupData*pda) {3084 PRINTDLG_PS_ChangePrinterA(HWND hDlg, PageSetupDataA *pda) { 1953 3085 DEVNAMES *dn; 1954 3086 DEVMODEA *dm; 1955 3087 LPSTR devname,portname; 1956 3088 1957 3089 dn = GlobalLock(pda->pdlg.hDevNames); 1958 3090 dm = GlobalLock(pda->pdlg.hDevMode); 1959 3091 devname = ((char*)dn)+dn->wDeviceOffset; 1960 3092 portname = ((char*)dn)+dn->wOutputOffset; 1961 PRINTDLG_SetUpPaperComboBox (hDlg,cmb2,devname,portname,dm);1962 PRINTDLG_SetUpPaperComboBox (hDlg,cmb3,devname,portname,dm);3093 PRINTDLG_SetUpPaperComboBoxA(hDlg,cmb2,devname,portname,dm); 3094 PRINTDLG_SetUpPaperComboBoxA(hDlg,cmb3,devname,portname,dm); 1963 3095 GlobalUnlock(pda->pdlg.hDevNames); 1964 3096 GlobalUnlock(pda->pdlg.hDevMode); … … 1967 3099 1968 3100 static BOOL 1969 PRINTDLG_PS_WMCommand( 1970 HWND hDlg, WPARAM wParam, LPARAM lParam, PageSetupData *pda 3101 PRINTDLG_PS_ChangePrinterW(HWND hDlg, PageSetupDataW *pda) { 3102 DEVNAMES *dn; 3103 DEVMODEW *dm; 3104 LPWSTR devname,portname; 3105 3106 dn = GlobalLock(pda->pdlg.hDevNames); 3107 dm = GlobalLock(pda->pdlg.hDevMode); 3108 devname = ((WCHAR*)dn)+dn->wDeviceOffset; 3109 portname = ((WCHAR*)dn)+dn->wOutputOffset; 3110 PRINTDLG_SetUpPaperComboBoxW(hDlg,cmb2,devname,portname,dm); 3111 PRINTDLG_SetUpPaperComboBoxW(hDlg,cmb3,devname,portname,dm); 3112 GlobalUnlock(pda->pdlg.hDevNames); 3113 GlobalUnlock(pda->pdlg.hDevMode); 3114 return TRUE; 3115 } 3116 3117 static BOOL 3118 PRINTDLG_PS_WMCommandA( 3119 HWND hDlg, WPARAM wParam, LPARAM lParam, PageSetupDataA *pda 1971 3120 ) { 1972 3121 switch (LOWORD(wParam)) { 1973 3122 case IDOK: 1974 if (!PRINTDLG_PS_UpdateDlgStruct (hDlg, pda))3123 if (!PRINTDLG_PS_UpdateDlgStructA(hDlg, pda)) 1975 3124 return(FALSE); 1976 3125 EndDialog(hDlg, TRUE); … … 1985 3134 pda->pdlg.hwndOwner = hDlg; 1986 3135 if (PrintDlgA(&(pda->pdlg))) 1987 PRINTDLG_PS_ChangePrinter (hDlg,pda);3136 PRINTDLG_PS_ChangePrinterA(hDlg,pda); 1988 3137 return TRUE; 1989 3138 } … … 1995 3144 } 1996 3145 3146 static BOOL 3147 PRINTDLG_PS_WMCommandW( 3148 HWND hDlg, WPARAM wParam, LPARAM lParam, PageSetupDataW *pda 3149 ) { 3150 switch (LOWORD(wParam)) { 3151 case IDOK: 3152 if (!PRINTDLG_PS_UpdateDlgStructW(hDlg, pda)) 3153 return(FALSE); 3154 EndDialog(hDlg, TRUE); 3155 return TRUE ; 3156 3157 case IDCANCEL: 3158 EndDialog(hDlg, FALSE); 3159 return FALSE ; 3160 3161 case psh3: { 3162 pda->pdlg.Flags = 0; 3163 pda->pdlg.hwndOwner = hDlg; 3164 if (PrintDlgW(&(pda->pdlg))) 3165 PRINTDLG_PS_ChangePrinterW(hDlg,pda); 3166 return TRUE; 3167 } 3168 } 3169 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n", 3170 LOWORD(lParam),wParam,lParam 3171 ); 3172 return FALSE; 3173 } 3174 1997 3175 1998 3176 static BOOL WINAPI 1999 3177 PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 2000 3178 { 2001 PageSetupData *pda;3179 PageSetupDataA *pda; 2002 3180 BOOL res = FALSE; 2003 3181 2004 3182 if (uMsg==WM_INITDIALOG) { 2005 3183 res = TRUE; 2006 pda = (PageSetupData *)lParam;3184 pda = (PageSetupDataA*)lParam; 2007 3185 SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam); 2008 3186 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { … … 2017 3195 } 2018 3196 if (pda->dlga->Flags & PSD_DISABLEPRINTER) 2019 EnableWindow(GetDlgItem(hDlg, psh3), FALSE); 3197 EnableWindow(GetDlgItem(hDlg, psh3), FALSE); 2020 3198 if (pda->dlga->Flags & PSD_DISABLEMARGINS) { 2021 EnableWindow(GetDlgItem(hDlg, edt4), FALSE); 2022 EnableWindow(GetDlgItem(hDlg, edt5), FALSE); 2023 EnableWindow(GetDlgItem(hDlg, edt6), FALSE); 2024 EnableWindow(GetDlgItem(hDlg, edt7), FALSE); 3199 EnableWindow(GetDlgItem(hDlg, edt4), FALSE); 3200 EnableWindow(GetDlgItem(hDlg, edt5), FALSE); 3201 EnableWindow(GetDlgItem(hDlg, edt6), FALSE); 3202 EnableWindow(GetDlgItem(hDlg, edt7), FALSE); 2025 3203 } 2026 3204 /* width larger as height -> landscape */ … … 2036 3214 if (pda->dlga->Flags & PSD_MARGINS) { 2037 3215 char str[100]; 2038 _c_size2str (pda,pda->dlga->rtMargin.left,str);3216 _c_size2strA(pda,pda->dlga->rtMargin.left,str); 2039 3217 SetDlgItemTextA(hDlg,edt4,str); 2040 _c_size2str (pda,pda->dlga->rtMargin.top,str);3218 _c_size2strA(pda,pda->dlga->rtMargin.top,str); 2041 3219 SetDlgItemTextA(hDlg,edt5,str); 2042 _c_size2str (pda,pda->dlga->rtMargin.right,str);3220 _c_size2strA(pda,pda->dlga->rtMargin.right,str); 2043 3221 SetDlgItemTextA(hDlg,edt6,str); 2044 _c_size2str (pda,pda->dlga->rtMargin.bottom,str);3222 _c_size2strA(pda,pda->dlga->rtMargin.bottom,str); 2045 3223 SetDlgItemTextA(hDlg,edt7,str); 2046 3224 } else { … … 2048 3226 DWORD size = _c_inch2size(pda->dlga,1000); 2049 3227 char str[20]; 2050 _c_size2str (pda,size,str);3228 _c_size2strA(pda,size,str); 2051 3229 SetDlgItemTextA(hDlg,edt4,str); 2052 3230 SetDlgItemTextA(hDlg,edt5,str); … … 2054 3232 SetDlgItemTextA(hDlg,edt7,str); 2055 3233 } 2056 PRINTDLG_PS_ChangePrinter (hDlg,pda);3234 PRINTDLG_PS_ChangePrinterA(hDlg,pda); 2057 3235 if (pda->dlga->Flags & PSD_DISABLEPAPER) { 2058 3236 EnableWindow(GetDlgItem(hDlg,cmb2),FALSE); … … 2061 3239 return TRUE; 2062 3240 } else { 2063 pda = (PageSetupData *)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA");3241 pda = (PageSetupDataA*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA"); 2064 3242 if (!pda) { 2065 3243 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n"); … … 2073 3251 switch (uMsg) { 2074 3252 case WM_COMMAND: 2075 return PRINTDLG_PS_WMCommand(hDlg, wParam, lParam, pda); 3253 return PRINTDLG_PS_WMCommandA(hDlg, wParam, lParam, pda); 3254 } 3255 return FALSE; 3256 } 3257 3258 static BOOL WINAPI 3259 PageDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 3260 { 3261 PageSetupDataW *pda; 3262 BOOL res = FALSE; 3263 3264 if (uMsg==WM_INITDIALOG) { 3265 res = TRUE; 3266 pda = (PageSetupDataW*)lParam; 3267 SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam); 3268 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { 3269 res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam); 3270 if (!res) { 3271 FIXME("Setup page hook failed?\n"); 3272 res = TRUE; 3273 } 3274 } 3275 if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) { 3276 FIXME("PagePaintHook not yet implemented!\n"); 3277 } 3278 if (pda->dlga->Flags & PSD_DISABLEPRINTER) 3279 EnableWindow(GetDlgItem(hDlg, psh3), FALSE); 3280 if (pda->dlga->Flags & PSD_DISABLEMARGINS) { 3281 EnableWindow(GetDlgItem(hDlg, edt4), FALSE); 3282 EnableWindow(GetDlgItem(hDlg, edt5), FALSE); 3283 EnableWindow(GetDlgItem(hDlg, edt6), FALSE); 3284 EnableWindow(GetDlgItem(hDlg, edt7), FALSE); 3285 } 3286 /* width larger as height -> landscape */ 3287 if (pda->dlga->ptPaperSize.x > pda->dlga->ptPaperSize.y) 3288 CheckRadioButton(hDlg, rad1, rad2, rad2); 3289 else /* this is default if papersize is not set */ 3290 CheckRadioButton(hDlg, rad1, rad2, rad1); 3291 if (pda->dlga->Flags & PSD_DISABLEORIENTATION) { 3292 EnableWindow(GetDlgItem(hDlg,rad1),FALSE); 3293 EnableWindow(GetDlgItem(hDlg,rad2),FALSE); 3294 } 3295 /* We fill them out enabled or not */ 3296 if (pda->dlga->Flags & PSD_MARGINS) { 3297 char str[100]; 3298 _c_size2strW(pda,pda->dlga->rtMargin.left,str); 3299 SetDlgItemTextA(hDlg,edt4,str); 3300 _c_size2strW(pda,pda->dlga->rtMargin.top,str); 3301 SetDlgItemTextA(hDlg,edt5,str); 3302 _c_size2strW(pda,pda->dlga->rtMargin.right,str); 3303 SetDlgItemTextA(hDlg,edt6,str); 3304 _c_size2strW(pda,pda->dlga->rtMargin.bottom,str); 3305 SetDlgItemTextA(hDlg,edt7,str); 3306 } else { 3307 /* default is 1 inch */ 3308 DWORD size = _c_inch2size((LPPAGESETUPDLGA)pda->dlga,1000); 3309 char str[20]; 3310 _c_size2strW(pda,size,str); 3311 SetDlgItemTextA(hDlg,edt4,str); 3312 SetDlgItemTextA(hDlg,edt5,str); 3313 SetDlgItemTextA(hDlg,edt6,str); 3314 SetDlgItemTextA(hDlg,edt7,str); 3315 } 3316 PRINTDLG_PS_ChangePrinterW(hDlg,pda); 3317 if (pda->dlga->Flags & PSD_DISABLEPAPER) { 3318 EnableWindow(GetDlgItem(hDlg,cmb2),FALSE); 3319 EnableWindow(GetDlgItem(hDlg,cmb3),FALSE); 3320 } 3321 return TRUE; 3322 } else { 3323 pda = (PageSetupDataW*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA"); 3324 if (!pda) { 3325 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n"); 3326 return FALSE; 3327 } 3328 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { 3329 res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam); 3330 if (res) return res; 3331 } 3332 } 3333 switch (uMsg) { 3334 case WM_COMMAND: 3335 return PRINTDLG_PS_WMCommandW(hDlg, wParam, lParam, pda); 2076 3336 } 2077 3337 return FALSE; … … 2085 3345 LPVOID ptr; 2086 3346 BOOL bRet; 2087 PageSetupData *pda;3347 PageSetupDataA *pda; 2088 3348 PRINTDLGA pdlg; 2089 2090 #ifdef __WIN32OS2__2091 dprintf(("PageSetupDlgA %x", setupdlg));2092 #endif2093 3349 2094 3350 if(TRACE_ON(commdlg)) { … … 2104 3360 "hinst %08x, flags %08lx (%s)\n", 2105 3361 setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode, 2106 setupdlg->hDevNames, 3362 setupdlg->hDevNames, 2107 3363 setupdlg->hInstance, setupdlg->Flags, flagstr); 2108 3364 } … … 2120 3376 setupdlg->hDevNames = pdlg.hDevNames; 2121 3377 /* FIXME: Just return "A4" for now. */ 2122 PRINTDLG_PaperSize (&pdlg,"A4",&setupdlg->ptPaperSize);3378 PRINTDLG_PaperSizeA(&pdlg,"A4",&setupdlg->ptPaperSize); 2123 3379 setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x); 2124 3380 setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y); 2125 3381 return TRUE; 2126 3382 } 2127 hDlgTmpl = PRINTDLG_GetPGSTemplate (setupdlg);3383 hDlgTmpl = PRINTDLG_GetPGSTemplateA(setupdlg); 2128 3384 if (!hDlgTmpl) { 2129 3385 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); … … 2152 3408 */ 2153 3409 BOOL WINAPI PageSetupDlgW(LPPAGESETUPDLGW setupdlg) { 2154 #ifdef __WIN32OS2__ 2155 dprintf(("PageSetupDlgA %x NOT IMPLEMENTED", setupdlg)); 2156 #endif 2157 FIXME("(%p), stub!\n",setupdlg); 3410 HGLOBAL hDlgTmpl; 3411 LPVOID ptr; 3412 BOOL bRet; 3413 PageSetupDataW *pdw; 3414 PRINTDLGW pdlg; 3415 3416 if(TRACE_ON(commdlg)) { 3417 char flagstr[1000] = ""; 3418 struct pd_flags *pflag = psd_flags; 3419 for( ; pflag->name; pflag++) { 3420 if(setupdlg->Flags & pflag->flag) { 3421 strcat(flagstr, pflag->name); 3422 strcat(flagstr, "|"); 3423 } 3424 } 3425 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n" 3426 "hinst %08x, flags %08lx (%s)\n", 3427 setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode, 3428 setupdlg->hDevNames, 3429 setupdlg->hInstance, setupdlg->Flags, flagstr); 3430 } 3431 3432 /* First get default printer data, we need it right after that. */ 3433 memset(&pdlg,0,sizeof(pdlg)); 3434 pdlg.lStructSize = sizeof(pdlg); 3435 pdlg.Flags = PD_RETURNDEFAULT; 3436 bRet = PrintDlgW(&pdlg); 3437 if (!bRet) return FALSE; 3438 3439 /* short cut exit, just return default values */ 3440 if (setupdlg->Flags & PSD_RETURNDEFAULT) { 3441 const WCHAR a4[] = {'A','4',0}; 3442 setupdlg->hDevMode = pdlg.hDevMode; 3443 setupdlg->hDevNames = pdlg.hDevNames; 3444 /* FIXME: Just return "A4" for now. */ 3445 PRINTDLG_PaperSizeW(&pdlg,a4,&setupdlg->ptPaperSize); 3446 setupdlg->ptPaperSize.x=_c_10mm2size((LPPAGESETUPDLGA)setupdlg,setupdlg->ptPaperSize.x); 3447 setupdlg->ptPaperSize.y=_c_10mm2size((LPPAGESETUPDLGA)setupdlg,setupdlg->ptPaperSize.y); 3448 return TRUE; 3449 } 3450 hDlgTmpl = PRINTDLG_GetPGSTemplateW(setupdlg); 3451 if (!hDlgTmpl) { 3452 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 2158 3453 return FALSE; 3454 } 3455 ptr = LockResource( hDlgTmpl ); 3456 if (!ptr) { 3457 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 3458 return FALSE; 3459 } 3460 pdw = HeapAlloc(GetProcessHeap(),0,sizeof(*pdw)); 3461 pdw->dlga = setupdlg; 3462 memcpy(&pdw->pdlg,&pdlg,sizeof(pdlg)); 3463 3464 bRet = (0<DialogBoxIndirectParamW( 3465 setupdlg->hInstance, 3466 ptr, 3467 setupdlg->hwndOwner, 3468 PageDlgProcW, 3469 (LPARAM)pdw) 3470 ); 3471 return bRet; 2159 3472 } 2160 3473 … … 2168 3481 * PrintDlgProc (COMMDLG.21) 2169 3482 */ 2170 LRESULT WINAPI PrintDlgProc16(HWND16 hDlg , UINT16 uMsg, WPARAM16 wParam,3483 LRESULT WINAPI PrintDlgProc16(HWND16 hDlg16, UINT16 uMsg, WPARAM16 wParam, 2171 3484 LPARAM lParam) 2172 3485 { 3486 HWND hDlg = HWND_32(hDlg16); 2173 3487 PRINT_PTRA* PrintStructures; 2174 3488 LRESULT res=FALSE; 2175 3489 2176 3490 if (uMsg!=WM_INITDIALOG) { 2177 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER);3491 PrintStructures = (PRINT_PTRA*)GetPropA(hDlg,"__WINE_PRINTDLGDATA"); 2178 3492 if (!PrintStructures) 2179 3493 return FALSE; 2180 3494 } else { 2181 3495 PrintStructures = (PRINT_PTRA*) lParam; 2182 Set WindowLongA(hDlg, DWL_USER, lParam);3496 SetPropA(hDlg,"__WINE_PRINTDLGDATA",lParam); 2183 3497 res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures); 2184 3498 … … 2186 3500 res = CallWindowProc16( 2187 3501 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2188 hDlg , uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg163502 hDlg16, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16 2189 3503 ); 2190 3504 } 2191 3505 return res; 2192 3506 } 2193 3507 2194 3508 if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { 2195 3509 res = CallWindowProc16( 2196 3510 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2197 hDlg ,uMsg, wParam, lParam3511 hDlg16,uMsg, wParam, lParam 2198 3512 ); 2199 3513 if(LOWORD(res)) return res; … … 2205 3519 * with 32Ato16 mapper in winproc.c 2206 3520 */ 2207 return PRINTDLG_WMCommand (3521 return PRINTDLG_WMCommandA( 2208 3522 hDlg, 2209 3523 MAKEWPARAM(wParam,HIWORD(lParam)), … … 2218 3532 2219 3533 return FALSE; 2220 } 3534 } 2221 3535 return res; 2222 3536 } … … 2226 3540 * PrintSetupDlgProc (COMMDLG.22) 2227 3541 */ 2228 LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd , UINT16 wMsg, WPARAM16 wParam,3542 LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam, 2229 3543 LPARAM lParam) 2230 3544 { 3545 HWND hWnd = HWND_32(hWnd16); 2231 3546 switch (wMsg) 2232 3547 {
Note:
See TracChangeset
for help on using the changeset viewer.