Changeset 6645 for trunk/src/comdlg32/printdlg.c
- Timestamp:
- Sep 5, 2001, 2:14:25 PM (24 years ago)
- File:
-
- 1 edited
-
trunk/src/comdlg32/printdlg.c (modified) (82 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comdlg32/printdlg.c
r6335 r6645 1 /* $Id: printdlg.c,v 1.2 2001-09-05 12:12:02 bird Exp $ */ 1 2 /* 2 3 * COMMDLG - Print Dialog … … 30 31 /* This PRINTDLGA internal structure stores 31 32 * pointers to several throughout useful structures. 32 * 33 */ 34 typedef struct 33 * 34 */ 35 typedef struct 35 36 { 36 37 LPDEVMODEA lpDevMode; 37 38 struct { 38 39 LPPRINTDLGA lpPrintDlg; 39 LPPRINTDLG16 lpPrintDlg16;40 LPPRINTDLG16 lpPrintDlg16; 40 41 } dlg; 41 42 LPPRINTER_INFO_2A lpPrinterInfo; … … 108 109 * 109 110 * Returns the default printer name in buf. 110 * Even under WinNT/2000 default printer is retrieved via GetProfileString - 111 * Even under WinNT/2000 default printer is retrieved via GetProfileString - 111 112 * these entries are mapped somewhere in the registry rather than win.ini. 112 113 * … … 118 119 119 120 if(!GetProfileStringA("windows", "device", "", buf, len)) { 120 TRACE("No profile entry for default printer found.\n");121 return FALSE;121 TRACE("No profile entry for default printer found.\n"); 122 return FALSE; 122 123 } 123 124 if((ptr = strchr(buf, ',')) == NULL) { 124 FIXME("bad format for default printer (%s)!\n",buf);125 return FALSE;125 FIXME("bad format for default printer (%s)!\n",buf); 126 return FALSE; 126 127 } 127 128 *ptr = '\0'; … … 145 146 res = OpenPrinterA(buf, hprn, NULL); 146 147 if (!res) 147 FIXME("Could not open printer %s?!\n",buf);148 FIXME("Could not open printer %s?!\n",buf); 148 149 return res; 149 150 } … … 169 170 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num); 170 171 pi = HeapAlloc(GetProcessHeap(), 0, needed); 171 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 172 &num);172 EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, 173 &num); 173 174 174 175 for(i = 0; i < num; i++) { 175 176 SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0, 176 (LPARAM)pi[i].pPrinterName );177 (LPARAM)pi[i].pPrinterName ); 177 178 } 178 179 HeapFree(GetProcessHeap(), 0, pi); 179 180 if(!name || 180 181 (i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, 181 (LPARAM)name)) == CB_ERR) {182 (LPARAM)name)) == CB_ERR) { 182 183 183 184 char buf[260]; 184 185 FIXME("Can't find '%s' in printer list so trying to find default\n", 185 name);186 if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf)))187 return num;188 i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);189 if(i == CB_ERR)190 FIXME("Can't find default printer in printer list\n");186 name); 187 if(!PRINTDLG_GetDefaultPrinterName(buf, sizeof(buf))) 188 return num; 189 i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf); 190 if(i == CB_ERR) 191 FIXME("Can't find default printer in printer list\n"); 191 192 } 192 193 SendDlgItemMessageA(hDlg, id, CB_SETCURSEL, i, 0); … … 202 203 * (NB. when we handle unicode the offsets will be in wchars). 203 204 */ 204 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 205 char* DeviceName, char* OutputPort)205 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 206 char* DeviceName, char* OutputPort) 206 207 { 207 208 long size; … … 215 216 + strlen(OutputPort) + 1 216 217 + sizeof(DEVNAMES); 217 218 218 219 if(*hmem) 219 220 *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE); … … 233 234 strcpy(pTempPtr, DeviceName); 234 235 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace; 235 236 236 237 pTempPtr += strlen(DeviceName) + 1; 237 238 strcpy(pTempPtr, OutputPort); … … 244 245 } 245 246 #ifndef __WIN32OS2__ 246 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 247 char* DeviceName, char* OutputPort)247 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 248 char* DeviceName, char* OutputPort) 248 249 { 249 250 long size; … … 257 258 + strlen(OutputPort) + 1 258 259 + sizeof(DEVNAMES); 259 260 260 261 if(*hmem) 261 262 *hmem = GlobalReAlloc16(*hmem, size, GMEM_MOVEABLE); … … 275 276 strcpy(pTempPtr, DeviceName); 276 277 lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace; 277 278 278 279 pTempPtr += strlen(DeviceName) + 1; 279 280 strcpy(pTempPtr, OutputPort); … … 292 293 * 293 294 * updates the PrintDlg structure for returnvalues. 294 * 295 * 295 296 * RETURNS 296 297 * FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values) 297 298 * TRUE if succesful. 298 299 */ 299 static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg, 300 PRINT_PTRA* PrintStructures)300 static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg, 301 PRINT_PTRA* PrintStructures) 301 302 { 302 303 LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; … … 306 307 307 308 if(!lpdm) { 308 FIXME("No lpdm ptr?\n");309 return FALSE;309 FIXME("No lpdm ptr?\n"); 310 return FALSE; 310 311 } 311 312 … … 313 314 if(!(lppd->Flags & PD_PRINTSETUP)) { 314 315 /* check whether nFromPage and nToPage are within range defined by 315 * nMinPage and nMaxPage316 */316 * nMinPage and nMaxPage 317 */ 317 318 if (IsDlgButtonChecked(hDlg, rad3) == BST_CHECKED) { /* Pages */ 318 WORD nToPage;319 WORD nFromPage;320 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);321 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE);322 if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage ||323 nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) {324 char resourcestr[256];325 char resultstr[256];326 LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, 327 resourcestr, 255);328 sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage);329 LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE, 330 resourcestr, 255);331 MessageBoxA(hDlg, resultstr, resourcestr,332 MB_OK | MB_ICONWARNING);333 return FALSE;334 }335 lppd->nFromPage = nFromPage;336 lppd->nToPage = nToPage;337 }338 339 if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */340 lppd->Flags |= PD_PRINTTOFILE;341 pi->pPortName = "FILE:";342 }343 344 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */345 FIXME("Collate lppd not yet implemented as output\n");346 }347 348 /* set PD_Collate and nCopies */349 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {350 /* The application doesn't support multiple copies or collate...351 */352 lppd->Flags &= ~PD_COLLATE;353 lppd->nCopies = 1;354 /* if the printer driver supports it... store info there355 * otherwise no collate & multiple copies !356 */357 if (lpdm->dmFields & DM_COLLATE)358 lpdm->dmCollate = 359 (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED);360 if (lpdm->dmFields & DM_COPIES)361 lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);362 } else {363 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)364 lppd->Flags |= PD_COLLATE;319 WORD nToPage; 320 WORD nFromPage; 321 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE); 322 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE); 323 if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage || 324 nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) { 325 char resourcestr[256]; 326 char resultstr[256]; 327 LoadStringA(COMDLG32_hInstance, PD32_INVALID_PAGE_RANGE, 328 resourcestr, 255); 329 sprintf(resultstr,resourcestr, lppd->nMinPage, lppd->nMaxPage); 330 LoadStringA(COMDLG32_hInstance, PD32_PRINT_TITLE, 331 resourcestr, 255); 332 MessageBoxA(hDlg, resultstr, resourcestr, 333 MB_OK | MB_ICONWARNING); 334 return FALSE; 335 } 336 lppd->nFromPage = nFromPage; 337 lppd->nToPage = nToPage; 338 } 339 340 if (IsDlgButtonChecked(hDlg, chx1) == BST_CHECKED) {/* Print to file */ 341 lppd->Flags |= PD_PRINTTOFILE; 342 pi->pPortName = "FILE:"; 343 } 344 345 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) { /* Collate */ 346 FIXME("Collate lppd not yet implemented as output\n"); 347 } 348 349 /* set PD_Collate and nCopies */ 350 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 351 /* The application doesn't support multiple copies or collate... 352 */ 353 lppd->Flags &= ~PD_COLLATE; 354 lppd->nCopies = 1; 355 /* if the printer driver supports it... store info there 356 * otherwise no collate & multiple copies ! 357 */ 358 if (lpdm->dmFields & DM_COLLATE) 359 lpdm->dmCollate = 360 (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED); 361 if (lpdm->dmFields & DM_COPIES) 362 lpdm->dmCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 363 } else { 364 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) 365 lppd->Flags |= PD_COLLATE; 365 366 else 366 367 lppd->Flags &= ~PD_COLLATE; 367 368 lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 368 }369 } 369 370 } 370 371 return TRUE; … … 372 373 373 374 static BOOL PRINTDLG_PaperSize( 374 PRINTDLGA*pdlga,const char *PaperSize,LPPOINT size375 PRINTDLGA *pdlga,const char *PaperSize,LPPOINT size 375 376 ) { 376 DEVNAMES *dn;377 DEVMODEA *dm;378 LPSTR devname,portname;379 int i;380 DWORD NrOfEntries,ret;381 char *Names = NULL;382 POINT *points = NULL;383 BOOL retval = FALSE;384 377 DEVNAMES *dn; 378 DEVMODEA *dm; 379 LPSTR devname,portname; 380 int i; 381 DWORD NrOfEntries,ret; 382 char *Names = NULL; 383 POINT *points = NULL; 384 BOOL retval = FALSE; 385 385 386 dn = GlobalLock(pdlga->hDevNames); 386 387 dm = GlobalLock(pdlga->hDevMode); 387 devname = ((char*)dn)+dn->wDeviceOffset;388 portname = ((char*)dn)+dn->wOutputOffset;388 devname = ((char*)dn)+dn->wDeviceOffset; 389 portname = ((char*)dn)+dn->wOutputOffset; 389 390 390 391 391 392 NrOfEntries = DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,NULL,dm); 392 393 if (!NrOfEntries) { 393 FIXME("No papernames found for %s/%s\n",devname,portname);394 goto out;394 FIXME("No papernames found for %s/%s\n",devname,portname); 395 goto out; 395 396 } 396 397 Names = (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries*64); 397 398 if (NrOfEntries != (ret=DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,Names,dm))) { 398 FIXME("Number of returned vals %ld is not %ld\n",NrOfEntries,ret);399 goto out;399 FIXME("Number of returned vals %ld is not %ld\n",NrOfEntries,ret); 400 goto out; 400 401 } 401 402 for (i=0;i<NrOfEntries;i++) 402 if (!strcmp(PaperSize,Names+(64*i)))403 break;403 if (!strcmp(PaperSize,Names+(64*i))) 404 break; 404 405 HeapFree(GetProcessHeap(),0,Names); 405 406 if (i==NrOfEntries) { 406 FIXME("Papersize %s not found in list?\n",PaperSize);407 goto out;407 FIXME("Papersize %s not found in list?\n",PaperSize); 408 goto out; 408 409 } 409 410 points = HeapAlloc(GetProcessHeap(),0,sizeof(points[0])*NrOfEntries); 410 411 if (NrOfEntries!=(ret=DeviceCapabilitiesA(devname,portname,DC_PAPERSIZE,(LPBYTE)points,dm))) { 411 FIXME("Number of returned sizes %ld is not %ld?\n",NrOfEntries,ret);412 goto out;412 FIXME("Number of returned sizes %ld is not %ld?\n",NrOfEntries,ret); 413 goto out; 413 414 } 414 415 /* this is _10ths_ of a millimeter */ … … 434 435 */ 435 436 static BOOL PRINTDLG_SetUpPaperComboBox(HWND hDlg, 436 int nIDComboBox,437 char* PrinterName, 438 char* PortName,439 LPDEVMODEA dm)437 int nIDComboBox, 438 char* PrinterName, 439 char* PortName, 440 LPDEVMODEA dm) 440 441 { 441 442 int i; … … 448 449 int fwCapability_Names; 449 450 int fwCapability_Words; 450 451 451 452 TRACE(" Printer: %s, ComboID: %d\n",PrinterName,nIDComboBox); 452 453 453 454 /* query the dialog box for the current selected value */ 454 455 Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0); … … 498 499 fwCapability_Words = DC_BINS; 499 500 } 500 501 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 501 502 /* for some printer drivers, DeviceCapabilities calls a VXD to obtain the 502 503 * paper settings. As Wine doesn't allow VXDs, this results in a crash. 503 504 */ … … 511 512 != NrOfEntries) { 512 513 ERR("Number of caps is different\n"); 513 NrOfEntries = 0;514 NrOfEntries = 0; 514 515 } 515 516 … … 519 520 fwCapability_Names, Names, dm); 520 521 NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName, 521 fwCapability_Words, (LPSTR)Words, dm);522 fwCapability_Words, (LPSTR)Words, dm); 522 523 523 524 /* reset any current content in the combobox */ 524 525 SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0); 525 526 526 527 /* store new content */ 527 528 for (i = 0; i < NrOfEntries; i++) { 528 529 DWORD pos = SendDlgItemMessageA(hDlg, nIDComboBox, CB_ADDSTRING, 0, 529 (LPARAM)(&Names[i*NamesSize]) );530 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos, 531 Words[i]);530 (LPARAM)(&Names[i*NamesSize]) ); 531 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETITEMDATA, pos, 532 Words[i]); 532 533 } 533 534 … … 537 538 for (i = 0; i < NrOfEntries; i++) { 538 539 if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) == 539 oldWord) {540 Sel = i;541 break;542 }540 oldWord) { 541 Sel = i; 542 break; 543 } 543 544 } 544 545 SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0); … … 564 565 for (i = 0; i < 25; i++) { 565 566 if (pi->Status & (1<<i)) { 566 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 567 ResourceString, 255);568 strcat(StatusMsg,ResourceString);567 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_PAUSED+i, 568 ResourceString, 255); 569 strcat(StatusMsg,ResourceString); 569 570 } 570 571 } 571 572 /* append "ready" */ 572 /* FIXME: status==ready must only be appended if really so. 573 /* FIXME: status==ready must only be appended if really so. 573 574 but how to detect? */ 574 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 575 ResourceString, 255);575 LoadStringA(COMDLG32_hInstance, PD32_PRINTER_STATUS_READY, 576 ResourceString, 255); 576 577 strcat(StatusMsg,ResourceString); 577 578 578 579 SendDlgItemMessageA(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg); 579 580 … … 585 586 SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pPortName); 586 587 SendDlgItemMessageA(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)(pi->pComment ? 587 pi->pComment : ""));588 pi->pComment : "")); 588 589 return; 589 590 } … … 596 597 */ 597 598 static BOOL PRINTDLG_ChangePrinter(HWND hDlg, char *name, 598 PRINT_PTRA *PrintStructures)599 PRINT_PTRA *PrintStructures) 599 600 { 600 601 LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; … … 610 611 if(!OpenPrinterA(name, &hprn, NULL)) { 611 612 ERR("Can't open printer %s\n", name); 612 return FALSE;613 return FALSE; 613 614 } 614 615 GetPrinterA(hprn, 2, NULL, 0, &needed); 615 616 PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed); 616 617 GetPrinterA(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed, 617 &needed);618 &needed); 618 619 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed); 619 620 PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed); 620 621 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo, 621 needed, &needed)) {622 ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName);623 return FALSE;622 needed, &needed)) { 623 ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName); 624 return FALSE; 624 625 } 625 626 ClosePrinter(hprn); … … 629 630 if(PrintStructures->lpDevMode) { 630 631 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode); 631 PrintStructures->lpDevMode = NULL;632 PrintStructures->lpDevMode = NULL; 632 633 } 633 634 … … 635 636 if(dmSize == -1) { 636 637 ERR("DocumentProperties fails on %s\n", debugstr_a(name)); 637 return FALSE;638 return FALSE; 638 639 } 639 640 PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize); 640 641 dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL, 641 DM_OUT_BUFFER);642 DM_OUT_BUFFER); 642 643 if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) && 643 !strcmp(lpdm->dmDeviceName,644 PrintStructures->lpDevMode->dmDeviceName)) {644 !strcmp(lpdm->dmDeviceName, 645 PrintStructures->lpDevMode->dmDeviceName)) { 645 646 /* Supplied devicemode matches current printer so try to use it */ 646 647 DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm, 647 DM_OUT_BUFFER | DM_IN_BUFFER);648 DM_OUT_BUFFER | DM_IN_BUFFER); 648 649 } 649 650 if(lpdm) … … 655 656 /* Print range (All/Range/Selection) */ 656 657 SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE); 657 SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);658 CheckRadioButton(hDlg, rad1, rad3, rad1);/* default */659 if (lppd->Flags & PD_NOSELECTION)660 EnableWindow(GetDlgItem(hDlg, rad2), FALSE);661 else662 if (lppd->Flags & PD_SELECTION)663 CheckRadioButton(hDlg, rad1, rad3, rad2);664 if (lppd->Flags & PD_NOPAGENUMS) {665 EnableWindow(GetDlgItem(hDlg, rad3), FALSE);666 EnableWindow(GetDlgItem(hDlg, stc2),FALSE);667 EnableWindow(GetDlgItem(hDlg, edt1), FALSE);668 EnableWindow(GetDlgItem(hDlg, stc3),FALSE);669 EnableWindow(GetDlgItem(hDlg, edt2), FALSE);670 } else {671 if (lppd->Flags & PD_PAGENUMS)672 CheckRadioButton(hDlg, rad1, rad3, rad3);673 }674 /* "All xxx pages"... */675 {676 char resourcestr[64];677 char result[64];678 LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES, 679 resourcestr, 49);680 sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1);681 SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result);682 }683 684 /* Collate pages 685 *686 * FIXME: The ico3 is not displayed for some reason. I don't know why.687 */688 if (lppd->Flags & PD_COLLATE) {689 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 690 (LPARAM)PrintStructures->hCollateIcon);691 CheckDlgButton(hDlg, chx2, 1);692 } else {693 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 694 (LPARAM)PrintStructures->hNoCollateIcon);695 CheckDlgButton(hDlg, chx2, 0);696 }697 698 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {699 /* if printer doesn't support it: no Collate */700 if (!(lpdm->dmFields & DM_COLLATE)) {701 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 702 EnableWindow(GetDlgItem(hDlg, ico3), FALSE); 703 }704 }705 706 /* nCopies */707 {708 INT copies;709 if (lppd->hDevMode == 0)710 copies = lppd->nCopies;711 else712 copies = lpdm->dmCopies;713 if(copies == 0) copies = 1;714 else if(copies < 0) copies = MAX_COPIES;715 SetDlgItemInt(hDlg, edt3, copies, FALSE);716 }717 718 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {719 /* if printer doesn't support it: no nCopies */720 if (!(lpdm->dmFields & DM_COPIES)) {721 EnableWindow(GetDlgItem(hDlg, edt3), FALSE); 722 EnableWindow(GetDlgItem(hDlg, stc5), FALSE); 723 }724 }725 726 /* print to file */727 CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);728 if (lppd->Flags & PD_DISABLEPRINTTOFILE)729 EnableWindow(GetDlgItem(hDlg, chx1), FALSE); 730 if (lppd->Flags & PD_HIDEPRINTTOFILE)658 SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE); 659 CheckRadioButton(hDlg, rad1, rad3, rad1); /* default */ 660 if (lppd->Flags & PD_NOSELECTION) 661 EnableWindow(GetDlgItem(hDlg, rad2), FALSE); 662 else 663 if (lppd->Flags & PD_SELECTION) 664 CheckRadioButton(hDlg, rad1, rad3, rad2); 665 if (lppd->Flags & PD_NOPAGENUMS) { 666 EnableWindow(GetDlgItem(hDlg, rad3), FALSE); 667 EnableWindow(GetDlgItem(hDlg, stc2),FALSE); 668 EnableWindow(GetDlgItem(hDlg, edt1), FALSE); 669 EnableWindow(GetDlgItem(hDlg, stc3),FALSE); 670 EnableWindow(GetDlgItem(hDlg, edt2), FALSE); 671 } else { 672 if (lppd->Flags & PD_PAGENUMS) 673 CheckRadioButton(hDlg, rad1, rad3, rad3); 674 } 675 /* "All xxx pages"... */ 676 { 677 char resourcestr[64]; 678 char result[64]; 679 LoadStringA(COMDLG32_hInstance, PD32_PRINT_ALL_X_PAGES, 680 resourcestr, 49); 681 sprintf(result,resourcestr,lppd->nMaxPage - lppd->nMinPage + 1); 682 SendDlgItemMessageA(hDlg, rad1, WM_SETTEXT, 0, (LPARAM) result); 683 } 684 685 /* Collate pages 686 * 687 * FIXME: The ico3 is not displayed for some reason. I don't know why. 688 */ 689 if (lppd->Flags & PD_COLLATE) { 690 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 691 (LPARAM)PrintStructures->hCollateIcon); 692 CheckDlgButton(hDlg, chx2, 1); 693 } else { 694 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 695 (LPARAM)PrintStructures->hNoCollateIcon); 696 CheckDlgButton(hDlg, chx2, 0); 697 } 698 699 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 700 /* if printer doesn't support it: no Collate */ 701 if (!(lpdm->dmFields & DM_COLLATE)) { 702 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 703 EnableWindow(GetDlgItem(hDlg, ico3), FALSE); 704 } 705 } 706 707 /* nCopies */ 708 { 709 INT copies; 710 if (lppd->hDevMode == 0) 711 copies = lppd->nCopies; 712 else 713 copies = lpdm->dmCopies; 714 if(copies == 0) copies = 1; 715 else if(copies < 0) copies = MAX_COPIES; 716 SetDlgItemInt(hDlg, edt3, copies, FALSE); 717 } 718 719 if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) { 720 /* if printer doesn't support it: no nCopies */ 721 if (!(lpdm->dmFields & DM_COPIES)) { 722 EnableWindow(GetDlgItem(hDlg, edt3), FALSE); 723 EnableWindow(GetDlgItem(hDlg, stc5), FALSE); 724 } 725 } 726 727 /* print to file */ 728 CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0); 729 if (lppd->Flags & PD_DISABLEPRINTTOFILE) 730 EnableWindow(GetDlgItem(hDlg, chx1), FALSE); 731 if (lppd->Flags & PD_HIDEPRINTTOFILE) 731 732 ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE); 732 733 … … 739 740 740 741 PRINTDLG_SetUpPaperComboBox(hDlg, cmb2, 741 PrintStructures->lpPrinterInfo->pPrinterName,742 PrintStructures->lpPrinterInfo->pPortName,743 lpdm);742 PrintStructures->lpPrinterInfo->pPrinterName, 743 PrintStructures->lpPrinterInfo->pPortName, 744 lpdm); 744 745 PRINTDLG_SetUpPaperComboBox(hDlg, cmb3, 745 PrintStructures->lpPrinterInfo->pPrinterName,746 PrintStructures->lpPrinterInfo->pPortName,747 lpdm);746 PrintStructures->lpPrinterInfo->pPrinterName, 747 PrintStructures->lpPrinterInfo->pPortName, 748 lpdm); 748 749 CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2); 749 750 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 750 751 (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon : 751 752 PrintStructures->hLandscapeIcon)); 752 753 753 754 } 754 755 … … 756 757 if ((lppd->Flags & PD_SHOWHELP)==0) { 757 758 /* hide if PD_SHOWHELP not specified */ 758 ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE); 759 ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE); 759 760 } 760 761 return TRUE; … … 765 766 */ 766 767 static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam, 767 PRINT_PTRA* PrintStructures)768 PRINT_PTRA* PrintStructures) 768 769 { 769 770 LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; … … 778 779 PrintStructures->hCollateIcon = 779 780 LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0); 780 PrintStructures->hNoCollateIcon = 781 PrintStructures->hNoCollateIcon = 781 782 LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0); 782 783 … … 792 793 PrintStructures->hLandscapeIcon == 0) { 793 794 ERR("no icon in resourcefile\n"); 794 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);795 EndDialog(hDlg, FALSE);795 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 796 EndDialog(hDlg, FALSE); 796 797 } 797 798 … … 801 802 */ 802 803 if (lppd->Flags & PD_SHOWHELP) { 803 if((PrintStructures->HelpMessageID = 804 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {805 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);806 return FALSE;807 }804 if((PrintStructures->HelpMessageID = 805 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { 806 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); 807 return FALSE; 808 } 808 809 } else 809 810 PrintStructures->HelpMessageID = 0; … … 811 812 if(!(lppd->Flags &PD_PRINTSETUP)) { 812 813 PrintStructures->hwndUpDown = 813 CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER |814 UDS_NOTHOUSANDS | UDS_ARROWKEYS |815 UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0,816 hDlg, UPDOWN_ID, COMDLG32_hInstance,817 GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1);814 CreateUpDownControl(WS_CHILD | WS_VISIBLE | WS_BORDER | 815 UDS_NOTHOUSANDS | UDS_ARROWKEYS | 816 UDS_ALIGNRIGHT | UDS_SETBUDDYINT, 0, 0, 0, 0, 817 hDlg, UPDOWN_ID, COMDLG32_hInstance, 818 GetDlgItem(hDlg, edt3), MAX_COPIES, 1, 1); 818 819 } 819 820 … … 823 824 */ 824 825 if (lppd->nMaxPage < lppd->nMinPage) 825 lppd->nMaxPage = lppd->nMinPage;826 if (lppd->nMinPage == lppd->nMaxPage) 827 lppd->Flags |= PD_NOPAGENUMS;826 lppd->nMaxPage = lppd->nMinPage; 827 if (lppd->nMinPage == lppd->nMaxPage) 828 lppd->Flags |= PD_NOPAGENUMS; 828 829 if (lppd->nToPage < lppd->nMinPage) 829 830 lppd->nToPage = lppd->nMinPage; … … 837 838 /* if we have the combo box, fill it */ 838 839 if (GetDlgItem(hDlg,comboID)) { 839 /* Fill Combobox 840 */841 pdn = GlobalLock(lppd->hDevNames);842 pdm = GlobalLock(lppd->hDevMode);843 if(pdn)844 name = (char*)pdn + pdn->wDeviceOffset;845 else if(pdm)846 name = pdm->dmDeviceName;847 PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);848 if(pdm) GlobalUnlock(lppd->hDevMode);849 if(pdn) GlobalUnlock(lppd->hDevNames);850 851 /* Now find selected printer and update rest of dlg */852 name = HeapAlloc(GetProcessHeap(),0,256);853 if (GetDlgItemTextA(hDlg, comboID, name, 255))854 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);855 HeapFree(GetProcessHeap(),0,name);840 /* Fill Combobox 841 */ 842 pdn = GlobalLock(lppd->hDevNames); 843 pdm = GlobalLock(lppd->hDevMode); 844 if(pdn) 845 name = (char*)pdn + pdn->wDeviceOffset; 846 else if(pdm) 847 name = pdm->dmDeviceName; 848 PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name); 849 if(pdm) GlobalUnlock(lppd->hDevMode); 850 if(pdn) GlobalUnlock(lppd->hDevNames); 851 852 /* Now find selected printer and update rest of dlg */ 853 name = HeapAlloc(GetProcessHeap(),0,256); 854 if (GetDlgItemTextA(hDlg, comboID, name, 255)) 855 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 856 HeapFree(GetProcessHeap(),0,name); 856 857 } else { 857 /* else use default printer */858 char name[200];859 BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));860 861 if (ret)862 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);863 else864 FIXME("No default printer found, expect problems!\n");858 /* else use default printer */ 859 char name[200]; 860 BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name)); 861 862 if (ret) 863 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 864 else 865 FIXME("No default printer found, expect problems!\n"); 865 866 } 866 867 return TRUE; … … 872 873 */ 873 874 static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam, 874 PRINT_PTRA* PrintStructures)875 PRINT_PTRA* PrintStructures) 875 876 { 876 877 LPPRINTDLG16 lppd = PrintStructures->dlg.lpPrintDlg16; … … 883 884 PrintStructures->hCollateIcon = 884 885 LoadIconA(COMDLG32_hInstance, "PD32_COLLATE"); 885 PrintStructures->hNoCollateIcon = 886 PrintStructures->hNoCollateIcon = 886 887 LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE"); 887 888 if(PrintStructures->hCollateIcon == 0 || 888 889 PrintStructures->hNoCollateIcon == 0) { 889 890 ERR("no icon in resourcefile\n"); 890 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);891 EndDialog(hDlg, FALSE);891 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 892 EndDialog(hDlg, FALSE); 892 893 } 893 894 … … 900 901 */ 901 902 if (lppd->Flags & PD_SHOWHELP) { 902 if((PrintStructures->HelpMessageID = 903 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) {904 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);905 return FALSE;906 }903 if((PrintStructures->HelpMessageID = 904 RegisterWindowMessageA(HELPMSGSTRINGA)) == 0) { 905 COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL); 906 return FALSE; 907 } 907 908 } else 908 909 PrintStructures->HelpMessageID = 0; 909 910 910 911 if (!(lppd->Flags & PD_PRINTSETUP)) { 911 /* We have a print quality combo box. What shall we do? */912 if (GetDlgItem(hDlg,cmb1)) {913 char buf [20];914 915 FIXME("Print quality only displaying currently.\n");916 917 pdm = GlobalLock16(lppd->hDevMode);918 if(pdm) {919 switch (pdm->dmPrintQuality) {920 case DMRES_HIGH: strcpy(buf,"High");break;921 case DMRES_MEDIUM: strcpy(buf,"Medium");break;922 case DMRES_LOW: strcpy(buf,"Low");break;923 case DMRES_DRAFT: strcpy(buf,"Draft");break;924 case 0: strcpy(buf,"Default");break;925 default: sprintf(buf,"%ddpi",pdm->dmPrintQuality);break;926 }927 GlobalUnlock16(lppd->hDevMode);928 } else 929 strcpy(buf,"Default");930 SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf);931 SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);932 EnableWindow(GetDlgItem(hDlg,cmb1),FALSE);933 }912 /* We have a print quality combo box. What shall we do? */ 913 if (GetDlgItem(hDlg,cmb1)) { 914 char buf [20]; 915 916 FIXME("Print quality only displaying currently.\n"); 917 918 pdm = GlobalLock16(lppd->hDevMode); 919 if(pdm) { 920 switch (pdm->dmPrintQuality) { 921 case DMRES_HIGH : strcpy(buf,"High");break; 922 case DMRES_MEDIUM : strcpy(buf,"Medium");break; 923 case DMRES_LOW : strcpy(buf,"Low");break; 924 case DMRES_DRAFT : strcpy(buf,"Draft");break; 925 case 0 : strcpy(buf,"Default");break; 926 default : sprintf(buf,"%ddpi",pdm->dmPrintQuality);break; 927 } 928 GlobalUnlock16(lppd->hDevMode); 929 } else 930 strcpy(buf,"Default"); 931 SendDlgItemMessageA(hDlg,cmb1,CB_ADDSTRING,0,(LPARAM)buf); 932 SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0); 933 EnableWindow(GetDlgItem(hDlg,cmb1),FALSE); 934 } 934 935 } 935 936 … … 939 940 */ 940 941 if (lppd->nMaxPage < lppd->nMinPage) 941 lppd->nMaxPage = lppd->nMinPage;942 if (lppd->nMinPage == lppd->nMaxPage) 943 lppd->Flags |= PD_NOPAGENUMS;942 lppd->nMaxPage = lppd->nMinPage; 943 if (lppd->nMinPage == lppd->nMaxPage) 944 lppd->Flags |= PD_NOPAGENUMS; 944 945 if (lppd->nToPage < lppd->nMinPage) 945 946 lppd->nToPage = lppd->nMinPage; … … 953 954 /* If the printer combo box is in the dialog, fill it */ 954 955 if (GetDlgItem(hDlg,comboID)) { 955 /* Fill Combobox 956 */957 pdn = GlobalLock16(lppd->hDevNames);958 pdm = GlobalLock16(lppd->hDevMode);959 if(pdn)960 name = (char*)pdn + pdn->wDeviceOffset;961 else if(pdm)962 name = pdm->dmDeviceName;963 PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name);964 if(pdm) GlobalUnlock16(lppd->hDevMode);965 if(pdn) GlobalUnlock16(lppd->hDevNames);966 967 /* Now find selected printer and update rest of dlg */968 name = HeapAlloc(GetProcessHeap(),0,256);969 if (GetDlgItemTextA(hDlg, comboID, name, 255))970 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);956 /* Fill Combobox 957 */ 958 pdn = GlobalLock16(lppd->hDevNames); 959 pdm = GlobalLock16(lppd->hDevMode); 960 if(pdn) 961 name = (char*)pdn + pdn->wDeviceOffset; 962 else if(pdm) 963 name = pdm->dmDeviceName; 964 PRINTDLG_SetUpPrinterListCombo(hDlg, comboID, name); 965 if(pdm) GlobalUnlock16(lppd->hDevMode); 966 if(pdn) GlobalUnlock16(lppd->hDevNames); 967 968 /* Now find selected printer and update rest of dlg */ 969 name = HeapAlloc(GetProcessHeap(),0,256); 970 if (GetDlgItemTextA(hDlg, comboID, name, 255)) 971 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 971 972 } else { 972 /* else just use default printer */973 char name[200];974 BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name));975 976 if (ret)977 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures);978 else979 FIXME("No default printer found, expect problems!\n");973 /* else just use default printer */ 974 char name[200]; 975 BOOL ret = PRINTDLG_GetDefaultPrinterName(name, sizeof(name)); 976 977 if (ret) 978 PRINTDLG_ChangePrinter(hDlg, name, PrintStructures); 979 else 980 FIXME("No default printer found, expect problems!\n"); 980 981 } 981 982 HeapFree(GetProcessHeap(),0,name); … … 988 989 * PRINTDLG_WMCommand [internal] 989 990 */ 990 static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 991 LPARAM lParam, PRINT_PTRA* PrintStructures)991 static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 992 LPARAM lParam, PRINT_PTRA* PrintStructures) 992 993 { 993 994 LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg; … … 999 1000 TRACE(" OK button was hit\n"); 1000 1001 if (PRINTDLG_UpdatePrintDlg(hDlg, PrintStructures)!=TRUE) { 1001 FIXME("Update printdlg was not successful!\n");1002 return(FALSE);1003 }1004 EndDialog(hDlg, TRUE);1005 return(TRUE);1002 FIXME("Update printdlg was not successful!\n"); 1003 return(FALSE); 1004 } 1005 EndDialog(hDlg, TRUE); 1006 return(TRUE); 1006 1007 1007 1008 case IDCANCEL: 1008 1009 TRACE(" CANCEL button was hit\n"); 1009 1010 EndDialog(hDlg, FALSE); 1010 return(FALSE);1011 return(FALSE); 1011 1012 1012 1013 case pshHelp: 1013 1014 TRACE(" HELP button was hit\n"); 1014 SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 1015 (WPARAM) hDlg, (LPARAM) lppd);1015 SendMessageA(lppd->hwndOwner, PrintStructures->HelpMessageID, 1016 (WPARAM) hDlg, (LPARAM) lppd); 1016 1017 break; 1017 1018 1018 1019 case chx2: /* collate pages checkbox */ 1019 1020 if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED) 1020 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1021 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1021 1022 (LPARAM)PrintStructures->hCollateIcon); 1022 1023 else 1023 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1024 SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 1024 1025 (LPARAM)PrintStructures->hNoCollateIcon); 1025 break; 1026 break; 1026 1027 case edt1: /* from page nr editbox */ 1027 1028 case edt2: /* to page nr editbox */ 1028 1029 if (HIWORD(wParam)==EN_CHANGE) { 1029 WORD nToPage;1030 WORD nFromPage;1031 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE);1032 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE);1030 WORD nToPage; 1031 WORD nFromPage; 1032 nFromPage = GetDlgItemInt(hDlg, edt1, NULL, FALSE); 1033 nToPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE); 1033 1034 if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage) 1034 CheckRadioButton(hDlg, rad1, rad3, rad3);1035 }1035 CheckRadioButton(hDlg, rad1, rad3, rad3); 1036 } 1036 1037 break; 1037 1038 1038 1039 case edt3: 1039 1040 if(HIWORD(wParam) == EN_CHANGE) { 1040 INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);1041 if(copies <= 1)1042 EnableWindow(GetDlgItem(hDlg, chx2), FALSE);1043 else1044 EnableWindow(GetDlgItem(hDlg, chx2), TRUE);1045 }1046 break;1041 INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE); 1042 if(copies <= 1) 1043 EnableWindow(GetDlgItem(hDlg, chx2), FALSE); 1044 else 1045 EnableWindow(GetDlgItem(hDlg, chx2), TRUE); 1046 } 1047 break; 1047 1048 1048 1049 #ifndef __WIN32OS2__ 1049 1050 case psh1: /* Print Setup */ 1050 {1051 PRINTDLG16pdlg;1052 1053 if (!PrintStructures->dlg.lpPrintDlg16) {1054 FIXME("The 32bit print dialog does not have this button!?\n");1055 break;1056 }1057 1058 memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg));1059 pdlg.Flags |= PD_PRINTSETUP;1060 pdlg.hwndOwner = hDlg;1061 if (!PrintDlg16(&pdlg))1062 break;1063 }1064 break;1051 { 1052 PRINTDLG16 pdlg; 1053 1054 if (!PrintStructures->dlg.lpPrintDlg16) { 1055 FIXME("The 32bit print dialog does not have this button!?\n"); 1056 break; 1057 } 1058 1059 memcpy(&pdlg,PrintStructures->dlg.lpPrintDlg16,sizeof(pdlg)); 1060 pdlg.Flags |= PD_PRINTSETUP; 1061 pdlg.hwndOwner = hDlg; 1062 if (!PrintDlg16(&pdlg)) 1063 break; 1064 } 1065 break; 1065 1066 #endif 1066 1067 … … 1072 1073 GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255); 1073 1074 if (!OpenPrinterA(PrinterName, &hPrinter, NULL)) { 1074 FIXME(" Call to OpenPrinter did not succeed!\n");1075 break;1076 }1077 DocumentPropertiesA(hDlg, hPrinter, PrinterName, 1078 PrintStructures->lpDevMode,1079 PrintStructures->lpDevMode,1080 DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);1081 ClosePrinter(hPrinter);1075 FIXME(" Call to OpenPrinter did not succeed!\n"); 1076 break; 1077 } 1078 DocumentPropertiesA(hDlg, hPrinter, PrinterName, 1079 PrintStructures->lpDevMode, 1080 PrintStructures->lpDevMode, 1081 DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT); 1082 ClosePrinter(hPrinter); 1082 1083 break; 1083 1084 } … … 1095 1096 } 1096 1097 break; 1097 1098 1098 1099 case rad2: /* Paperorientation */ 1099 1100 if (lppd->Flags & PD_PRINTSETUP) … … 1108 1109 } 1109 1110 break; 1110 1111 1111 1112 case cmb1: /* Printer Combobox in PRINT SETUP, quality combobox in PRINT */ 1112 if (PrinterComboID != wParam) {1113 FIXME("No handling for print quality combo box yet.\n");1114 break;1115 }1116 /* FALLTHROUGH */1113 if (PrinterComboID != wParam) { 1114 FIXME("No handling for print quality combo box yet.\n"); 1115 break; 1116 } 1117 /* FALLTHROUGH */ 1117 1118 case cmb4: /* Printer combobox */ 1118 1119 if (HIWORD(wParam)==CBN_SELCHANGE) { 1119 char PrinterName[256];1120 GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255);1121 PRINTDLG_ChangePrinter(hDlg, PrinterName, PrintStructures);1122 }1123 break;1120 char PrinterName[256]; 1121 GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255); 1122 PRINTDLG_ChangePrinter(hDlg, PrinterName, PrintStructures); 1123 } 1124 break; 1124 1125 1125 1126 case cmb2: /* Papersize */ 1126 1127 { 1127 DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);1128 if(Sel != CB_ERR)1128 DWORD Sel = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0); 1129 if(Sel != CB_ERR) 1129 1130 #ifdef __WIN32OS2__ 1130 lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,1131 lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2, 1131 1132 #else 1132 lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,1133 lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2, 1133 1134 #endif 1134 CB_GETITEMDATA,1135 Sel, 0);1135 CB_GETITEMDATA, 1136 Sel, 0); 1136 1137 } 1137 1138 break; … … 1139 1140 case cmb3: /* Bin */ 1140 1141 { 1141 DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);1142 if(Sel != CB_ERR)1143 lpdm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3,1144 CB_GETITEMDATA, Sel,1145 0);1142 DWORD Sel = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0); 1143 if(Sel != CB_ERR) 1144 lpdm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3, 1145 CB_GETITEMDATA, Sel, 1146 0); 1146 1147 } 1147 break; 1148 break; 1148 1149 } 1149 1150 if(lppd->Flags & PD_PRINTSETUP) { 1150 1151 switch (LOWORD(wParam)) { 1151 case rad1: /* orientation */1152 case rad2:1153 if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) {1152 case rad1: /* orientation */ 1153 case rad2: 1154 if (IsDlgButtonChecked(hDlg, rad1) == BST_CHECKED) { 1154 1155 #ifdef __WIN32OS2__ 1155 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {1156 lpdm->dmOrientation = DMORIENT_PORTRAIT;1156 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) { 1157 lpdm->dmOrientation = DMORIENT_PORTRAIT; 1157 1158 #else 1158 if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) {1159 lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT;1159 if(lpdm->u1.s1.dmOrientation != DMORIENT_PORTRAIT) { 1160 lpdm->u1.s1.dmOrientation = DMORIENT_PORTRAIT; 1160 1161 #endif 1161 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,1162 (WPARAM)IMAGE_ICON,1163 (LPARAM)PrintStructures->hPortraitIcon);1164 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,1165 (WPARAM)IMAGE_ICON,1166 (LPARAM)PrintStructures->hPortraitIcon);1167 }1168 } else {1162 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE, 1163 (WPARAM)IMAGE_ICON, 1164 (LPARAM)PrintStructures->hPortraitIcon); 1165 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, 1166 (WPARAM)IMAGE_ICON, 1167 (LPARAM)PrintStructures->hPortraitIcon); 1168 } 1169 } else { 1169 1170 #ifdef __WIN32OS2__ 1170 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {1171 lpdm->dmOrientation = DMORIENT_LANDSCAPE;1171 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) { 1172 lpdm->dmOrientation = DMORIENT_LANDSCAPE; 1172 1173 #else 1173 if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) {1174 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE;1174 if(lpdm->u1.s1.dmOrientation != DMORIENT_LANDSCAPE) { 1175 lpdm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE; 1175 1176 #endif 1176 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE,1177 (WPARAM)IMAGE_ICON,1178 (LPARAM)PrintStructures->hLandscapeIcon);1179 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE,1180 (WPARAM)IMAGE_ICON,1181 (LPARAM)PrintStructures->hLandscapeIcon);1182 }1183 }1184 break;1185 }1177 SendDlgItemMessageA(hDlg, stc10, STM_SETIMAGE, 1178 (WPARAM)IMAGE_ICON, 1179 (LPARAM)PrintStructures->hLandscapeIcon); 1180 SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, 1181 (WPARAM)IMAGE_ICON, 1182 (LPARAM)PrintStructures->hLandscapeIcon); 1183 } 1184 } 1185 break; 1186 } 1186 1187 } 1187 1188 return FALSE; 1188 } 1189 } 1189 1190 1190 1191 /*********************************************************************** 1191 * PrintDlgProcA [internal]1192 * PrintDlgProcA [internal] 1192 1193 */ 1193 1194 #ifdef __WIN32OS2__ 1194 1195 LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, 1195 LPARAM lParam)1196 LPARAM lParam) 1196 1197 #else 1197 1198 BOOL WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, 1198 LPARAM lParam)1199 LPARAM lParam) 1199 1200 #endif 1200 1201 { … … 1203 1204 1204 1205 if (uMsg!=WM_INITDIALOG) { 1205 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER); 1206 if (!PrintStructures)1207 return FALSE;1206 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER); 1207 if (!PrintStructures) 1208 return FALSE; 1208 1209 } else { 1209 1210 PrintStructures = (PRINT_PTRA*) lParam; 1210 SetWindowLongA(hDlg, DWL_USER, lParam); 1211 res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures);1212 1213 if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK)1214 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(1215 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg1216 ); 1217 return res;1218 } 1219 1211 SetWindowLongA(hDlg, DWL_USER, lParam); 1212 res = PRINTDLG_WMInitDialog(hDlg, wParam, PrintStructures); 1213 1214 if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) 1215 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook( 1216 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg 1217 ); 1218 return res; 1219 } 1220 1220 1221 if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) { 1221 1222 res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam, 1222 lParam);1223 if(res) return res;1223 lParam); 1224 if(res) return res; 1224 1225 } 1225 1226 … … 1229 1230 1230 1231 case WM_DESTROY: 1231 DestroyIcon(PrintStructures->hCollateIcon);1232 DestroyIcon(PrintStructures->hNoCollateIcon);1232 DestroyIcon(PrintStructures->hCollateIcon); 1233 DestroyIcon(PrintStructures->hNoCollateIcon); 1233 1234 DestroyIcon(PrintStructures->hPortraitIcon); 1234 1235 DestroyIcon(PrintStructures->hLandscapeIcon); 1235 if(PrintStructures->hwndUpDown)1236 DestroyWindow(PrintStructures->hwndUpDown);1236 if(PrintStructures->hwndUpDown) 1237 DestroyWindow(PrintStructures->hwndUpDown); 1237 1238 return FALSE; 1238 } 1239 } 1239 1240 return res; 1240 1241 } … … 1255 1256 HGLOBAL16 hGlobal16; 1256 1257 LPVOID template; 1257 1258 1258 1259 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, 1259 1260 PrintResourceName, RT_DIALOGA))) … … 1300 1301 1301 1302 if (lppd->Flags & PD_PRINTSETUP) { 1302 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 1303 hDlgTmpl = lppd->hSetupTemplate; 1304 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 1305 hResInfo = FindResourceA(lppd->hInstance, 1306 lppd->lpSetupTemplateName, RT_DIALOGA); 1307 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 1308 } else { 1309 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP", 1310 RT_DIALOGA); 1311 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 1312 } 1303 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 1304 hDlgTmpl = lppd->hSetupTemplate; 1305 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 1306 hResInfo = FindResourceA(lppd->hInstance, 1307 lppd->lpSetupTemplateName, RT_DIALOGA); 1308 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 1313 1309 } else { 1314 if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) { 1315 hDlgTmpl = lppd->hPrintTemplate; 1316 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) { 1317 hResInfo = FindResourceA(lppd->hInstance, 1318 lppd->lpPrintTemplateName, 1319 RT_DIALOGA); 1320 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 1321 } else { 1322 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32", 1323 RT_DIALOGA); 1324 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 1325 } 1310 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP", 1311 RT_DIALOGA); 1312 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 1313 } 1314 } else { 1315 if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) { 1316 hDlgTmpl = lppd->hPrintTemplate; 1317 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) { 1318 hResInfo = FindResourceA(lppd->hInstance, 1319 lppd->lpPrintTemplateName, 1320 RT_DIALOGA); 1321 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 1322 } else { 1323 hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32", 1324 RT_DIALOGA); 1325 hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo); 1326 } 1326 1327 } 1327 1328 return hDlgTmpl; … … 1340 1341 1341 1342 if (lppd->Flags & PD_PRINTSETUP) { 1342 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 1343 hDlgTmpl = lppd->hSetupTemplate; 1344 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 1345 hResInfo = FindResource16(lppd->hInstance, 1346 MapSL(lppd->lpSetupTemplateName), RT_DIALOGA); 1347 hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo); 1348 } else { 1349 hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP"); 1350 } 1343 if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) { 1344 hDlgTmpl = lppd->hSetupTemplate; 1345 } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) { 1346 hResInfo = FindResource16(lppd->hInstance, 1347 MapSL(lppd->lpSetupTemplateName), RT_DIALOGA); 1348 hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo); 1351 1349 } else { 1352 if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) { 1353 hDlgTmpl = lppd->hPrintTemplate; 1354 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) { 1355 hResInfo = FindResource16(lppd->hInstance, 1356 MapSL(lppd->lpPrintTemplateName), 1357 RT_DIALOGA); 1358 hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo); 1359 } else { 1360 hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32"); 1361 } 1350 hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32_SETUP"); 1351 } 1352 } else { 1353 if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) { 1354 hDlgTmpl = lppd->hPrintTemplate; 1355 } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) { 1356 hResInfo = FindResource16(lppd->hInstance, 1357 MapSL(lppd->lpPrintTemplateName), 1358 RT_DIALOGA); 1359 hDlgTmpl = LoadResource16(lppd->hInstance, hResInfo); 1360 } else { 1361 hDlgTmpl = PRINTDLG_Get16TemplateFrom32("PRINT32"); 1362 } 1362 1363 } 1363 1364 return hDlgTmpl; … … 1377 1378 if(lppd->Flags & PD_RETURNDC) { 1378 1379 lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset, 1379 (char*)pdn + pdn->wDeviceOffset,1380 (char*)pdn + pdn->wOutputOffset,1381 pdm );1380 (char*)pdn + pdn->wDeviceOffset, 1381 (char*)pdn + pdn->wOutputOffset, 1382 pdm ); 1382 1383 } else if(lppd->Flags & PD_RETURNIC) { 1383 1384 lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset, 1384 (char*)pdn + pdn->wDeviceOffset,1385 (char*)pdn + pdn->wOutputOffset,1386 pdm );1385 (char*)pdn + pdn->wDeviceOffset, 1386 (char*)pdn + pdn->wOutputOffset, 1387 pdm ); 1387 1388 } 1388 1389 GlobalUnlock(lppd->hDevNames); … … 1399 1400 if(lppd->Flags & PD_RETURNDC) { 1400 1401 lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset, 1401 (char*)pdn + pdn->wDeviceOffset,1402 (char*)pdn + pdn->wOutputOffset,1403 pdm );1402 (char*)pdn + pdn->wDeviceOffset, 1403 (char*)pdn + pdn->wOutputOffset, 1404 pdm ); 1404 1405 } else if(lppd->Flags & PD_RETURNIC) { 1405 1406 lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset, 1406 (char*)pdn + pdn->wDeviceOffset,1407 (char*)pdn + pdn->wOutputOffset,1408 pdm );1407 (char*)pdn + pdn->wDeviceOffset, 1408 (char*)pdn + pdn->wOutputOffset, 1409 pdm ); 1409 1410 } 1410 1411 GlobalUnlock16(lppd->hDevNames); … … 1431 1432 * * The Paper Orientation Icons are not implemented yet. 1432 1433 * * The Properties Button(s) should call DocumentPropertiesA(). 1433 * * Settings are not yet taken from a provided DevMode or 1434 * * Settings are not yet taken from a provided DevMode or 1434 1435 * default printer settings. 1435 1436 */ 1436 1437 BOOL WINAPI PrintDlgA( 1437 LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */1438 )1438 LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */ 1439 ) 1439 1440 { 1440 1441 BOOL bRet = FALSE; … … 1448 1449 if(TRACE_ON(commdlg)) { 1449 1450 char flagstr[1000] = ""; 1450 struct pd_flags *pflag = pd_flags;1451 for( ; pflag->name; pflag++) {1452 if(lppd->Flags & pflag->flag)1453 strcat(flagstr, pflag->name);1454 }1455 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"1456 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"1457 "flags %08lx (%s)\n",1458 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,1459 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,1460 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);1451 struct pd_flags *pflag = pd_flags; 1452 for( ; pflag->name; pflag++) { 1453 if(lppd->Flags & pflag->flag) 1454 strcat(flagstr, pflag->name); 1455 } 1456 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n" 1457 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n" 1458 "flags %08lx (%s)\n", 1459 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames, 1460 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage, 1461 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr); 1461 1462 } 1462 1463 1463 1464 if(lppd->lStructSize != sizeof(PRINTDLGA)) { 1464 1465 WARN("structure size failure !!!\n"); 1465 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);1466 return FALSE; 1466 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); 1467 return FALSE; 1467 1468 } 1468 1469 1469 1470 if(lppd->Flags & PD_RETURNDEFAULT) { 1470 1471 PRINTER_INFO_2A *pbuf; 1471 DRIVER_INFO_3A*dbuf;1472 HANDLE hprn;1473 DWORD needed;1474 1475 if(lppd->hDevMode || lppd->hDevNames) {1476 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");1477 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1478 return FALSE;1479 }1472 DRIVER_INFO_3A *dbuf; 1473 HANDLE hprn; 1474 DWORD needed; 1475 1476 if(lppd->hDevMode || lppd->hDevNames) { 1477 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n"); 1478 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1479 return FALSE; 1480 } 1480 1481 if(!PRINTDLG_OpenDefaultPrinter(&hprn)) { 1481 WARN("Can't find default printer\n");1482 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 1483 return FALSE;1484 }1485 1486 GetPrinterA(hprn, 2, NULL, 0, &needed);1487 pbuf = HeapAlloc(GetProcessHeap(), 0, needed);1488 GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);1489 1490 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);1491 dbuf = HeapAlloc(GetProcessHeap(),0,needed);1492 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {1493 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName);1494 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1495 return FALSE;1496 }1497 ClosePrinter(hprn);1498 1499 PRINTDLG_CreateDevNames(&(lppd->hDevNames),1500 dbuf->pDriverPath,1501 pbuf->pPrinterName,1502 pbuf->pPortName);1503 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize +1504 pbuf->pDevMode->dmDriverExtra);1505 ptr = GlobalLock(lppd->hDevMode);1506 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +1507 pbuf->pDevMode->dmDriverExtra);1508 GlobalUnlock(lppd->hDevMode);1509 HeapFree(GetProcessHeap(), 0, pbuf);1510 HeapFree(GetProcessHeap(), 0, dbuf);1511 bRet = TRUE;1482 WARN("Can't find default printer\n"); 1483 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 1484 return FALSE; 1485 } 1486 1487 GetPrinterA(hprn, 2, NULL, 0, &needed); 1488 pbuf = HeapAlloc(GetProcessHeap(), 0, needed); 1489 GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed); 1490 1491 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed); 1492 dbuf = HeapAlloc(GetProcessHeap(),0,needed); 1493 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) { 1494 ERR("GetPrinterDriverA failed, le %ld, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName); 1495 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1496 return FALSE; 1497 } 1498 ClosePrinter(hprn); 1499 1500 PRINTDLG_CreateDevNames(&(lppd->hDevNames), 1501 dbuf->pDriverPath, 1502 pbuf->pPrinterName, 1503 pbuf->pPortName); 1504 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, pbuf->pDevMode->dmSize + 1505 pbuf->pDevMode->dmDriverExtra); 1506 ptr = GlobalLock(lppd->hDevMode); 1507 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize + 1508 pbuf->pDevMode->dmDriverExtra); 1509 GlobalUnlock(lppd->hDevMode); 1510 HeapFree(GetProcessHeap(), 0, pbuf); 1511 HeapFree(GetProcessHeap(), 0, dbuf); 1512 bRet = TRUE; 1512 1513 } else { 1513 HGLOBAL hDlgTmpl;1514 PRINT_PTRA *PrintStructures;1515 1516 /* load Dialog resources, 1517 * depending on Flags indicates Print32 or Print32_setup dialog 1514 HGLOBAL hDlgTmpl; 1515 PRINT_PTRA *PrintStructures; 1516 1517 /* load Dialog resources, 1518 * depending on Flags indicates Print32 or Print32_setup dialog 1518 1519 */ 1519 hDlgTmpl = PRINTDLG_GetDlgTemplate(lppd);1520 if (!hDlgTmpl) {1521 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);1522 return FALSE;1523 }1524 ptr = LockResource( hDlgTmpl );1525 if (!ptr) {1526 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);1527 return FALSE;1528 }1520 hDlgTmpl = PRINTDLG_GetDlgTemplate(lppd); 1521 if (!hDlgTmpl) { 1522 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1523 return FALSE; 1524 } 1525 ptr = LockResource( hDlgTmpl ); 1526 if (!ptr) { 1527 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1528 return FALSE; 1529 } 1529 1530 1530 1531 PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 1531 sizeof(PRINT_PTRA));1532 PrintStructures->dlg.lpPrintDlg = lppd;1533 1534 /* and create & process the dialog .1535 * -1 is failure, 0 is broken hwnd, everything else is ok.1536 */1537 bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner,1538 PrintDlgProcA,1539 (LPARAM)PrintStructures));1540 1541 if(bRet) {1542 DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;1543 PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;1544 DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;1545 1546 if (lppd->hDevMode == 0) {1547 TRACE(" No hDevMode yet... Need to create my own\n");1548 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE,1549 lpdm->dmSize + lpdm->dmDriverExtra);1550 } else {1551 WORD locks;1552 if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) {1553 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);1554 while(locks--) {1555 GlobalUnlock(lppd->hDevMode);1556 TRACE("Now got %d locks\n", locks);1557 }1558 }1559 lppd->hDevMode = GlobalReAlloc(lppd->hDevMode,1560 lpdm->dmSize + lpdm->dmDriverExtra,1561 GMEM_MOVEABLE);1562 }1563 lpdmReturn = GlobalLock(lppd->hDevMode);1564 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);1565 1566 if (lppd->hDevNames != 0) {1567 WORD locks;1568 if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) {1569 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);1570 while(locks--)1571 GlobalUnlock(lppd->hDevNames);1572 }1573 }1574 PRINTDLG_CreateDevNames(&(lppd->hDevNames),1575 di->pDriverPath,1576 pi->pPrinterName,1577 pi->pPortName1578 );1579 GlobalUnlock(lppd->hDevMode);1580 }1581 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);1582 HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);1583 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);1584 HeapFree(GetProcessHeap(), 0, PrintStructures);1532 sizeof(PRINT_PTRA)); 1533 PrintStructures->dlg.lpPrintDlg = lppd; 1534 1535 /* and create & process the dialog . 1536 * -1 is failure, 0 is broken hwnd, everything else is ok. 1537 */ 1538 bRet = (0<DialogBoxIndirectParamA(hInst, ptr, lppd->hwndOwner, 1539 PrintDlgProcA, 1540 (LPARAM)PrintStructures)); 1541 1542 if(bRet) { 1543 DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn; 1544 PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo; 1545 DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo; 1546 1547 if (lppd->hDevMode == 0) { 1548 TRACE(" No hDevMode yet... Need to create my own\n"); 1549 lppd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, 1550 lpdm->dmSize + lpdm->dmDriverExtra); 1551 } else { 1552 WORD locks; 1553 if((locks = (GlobalFlags(lppd->hDevMode) & GMEM_LOCKCOUNT))) { 1554 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks); 1555 while(locks--) { 1556 GlobalUnlock(lppd->hDevMode); 1557 TRACE("Now got %d locks\n", locks); 1558 } 1559 } 1560 lppd->hDevMode = GlobalReAlloc(lppd->hDevMode, 1561 lpdm->dmSize + lpdm->dmDriverExtra, 1562 GMEM_MOVEABLE); 1563 } 1564 lpdmReturn = GlobalLock(lppd->hDevMode); 1565 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra); 1566 1567 if (lppd->hDevNames != 0) { 1568 WORD locks; 1569 if((locks = (GlobalFlags(lppd->hDevNames) & GMEM_LOCKCOUNT))) { 1570 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks); 1571 while(locks--) 1572 GlobalUnlock(lppd->hDevNames); 1573 } 1574 } 1575 PRINTDLG_CreateDevNames(&(lppd->hDevNames), 1576 di->pDriverPath, 1577 pi->pPrinterName, 1578 pi->pPortName 1579 ); 1580 GlobalUnlock(lppd->hDevMode); 1581 } 1582 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode); 1583 HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo); 1584 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo); 1585 HeapFree(GetProcessHeap(), 0, PrintStructures); 1585 1586 } 1586 1587 if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC)) 1587 1588 bRet = PRINTDLG_CreateDC(lppd); 1588 1589 1589 TRACE("exit! (%d)\n", bRet); 1590 return bRet; 1590 TRACE("exit! (%d)\n", bRet); 1591 return bRet; 1591 1592 } 1592 1593 … … 1594 1595 /*********************************************************************** 1595 1596 * PrintDlg (COMMDLG.20) 1596 * 1597 * 1597 1598 * Displays the the PRINT dialog box, which enables the user to specify 1598 1599 * specific properties of the print job. … … 1608 1609 1609 1610 BOOL16 WINAPI PrintDlg16( 1610 LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */1611 LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */ 1611 1612 ) { 1612 1613 BOOL bRet = FALSE; … … 1616 1617 if(TRACE_ON(commdlg)) { 1617 1618 char flagstr[1000] = ""; 1618 struct pd_flags *pflag = pd_flags;1619 for( ; pflag->name; pflag++) {1620 if(lppd->Flags & pflag->flag)1621 strcat(flagstr, pflag->name);1622 }1623 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"1624 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n"1625 "flags %08lx (%s)\n",1626 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames,1627 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage,1628 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr);1619 struct pd_flags *pflag = pd_flags; 1620 for( ; pflag->name; pflag++) { 1621 if(lppd->Flags & pflag->flag) 1622 strcat(flagstr, pflag->name); 1623 } 1624 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n" 1625 "pp. %d-%d, min p %d, max p %d, copies %d, hinst %08x\n" 1626 "flags %08lx (%s)\n", 1627 lppd, lppd->hwndOwner, lppd->hDevMode, lppd->hDevNames, 1628 lppd->nFromPage, lppd->nToPage, lppd->nMinPage, lppd->nMaxPage, 1629 lppd->nCopies, lppd->hInstance, lppd->Flags, flagstr); 1629 1630 } 1630 1631 1631 1632 if(lppd->lStructSize != sizeof(PRINTDLG16)) { 1632 1633 ERR("structure size (%ld/%d)\n",lppd->lStructSize,sizeof(PRINTDLG16)); 1633 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);1634 return FALSE;1634 COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); 1635 return FALSE; 1635 1636 } 1636 1637 1637 1638 if(lppd->Flags & PD_RETURNDEFAULT) { 1638 1639 PRINTER_INFO_2A *pbuf; 1639 DRIVER_INFO_3A*dbuf;1640 HANDLE hprn;1641 DWORD needed;1642 1643 if(lppd->hDevMode || lppd->hDevNames) {1644 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n");1645 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1646 return FALSE;1647 }1640 DRIVER_INFO_3A *dbuf; 1641 HANDLE hprn; 1642 DWORD needed; 1643 1644 if(lppd->hDevMode || lppd->hDevNames) { 1645 WARN("hDevMode or hDevNames non-zero for PD_RETURNDEFAULT\n"); 1646 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1647 return FALSE; 1648 } 1648 1649 if(!PRINTDLG_OpenDefaultPrinter(&hprn)) { 1649 WARN("Can't find default printer\n");1650 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 1651 return FALSE;1652 }1653 1654 GetPrinterA(hprn, 2, NULL, 0, &needed);1655 pbuf = HeapAlloc(GetProcessHeap(), 0, needed);1656 GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed);1657 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);1658 dbuf = HeapAlloc(GetProcessHeap(),0,needed);1659 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {1660 ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n",1661 pbuf->pPrinterName,GetLastError());1662 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1663 return FALSE;1664 }1665 ClosePrinter(hprn);1666 PRINTDLG_CreateDevNames16(&(lppd->hDevNames),1667 dbuf->pDriverPath,1668 pbuf->pPrinterName,1669 pbuf->pPortName);1670 lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,pbuf->pDevMode->dmSize+1671 pbuf->pDevMode->dmDriverExtra);1672 ptr = GlobalLock16(lppd->hDevMode);1673 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize +1674 pbuf->pDevMode->dmDriverExtra);1675 GlobalUnlock16(lppd->hDevMode);1676 HeapFree(GetProcessHeap(), 0, pbuf);1677 HeapFree(GetProcessHeap(), 0, dbuf);1678 bRet = TRUE;1650 WARN("Can't find default printer\n"); 1651 COMDLG32_SetCommDlgExtendedError(PDERR_NODEFAULTPRN); 1652 return FALSE; 1653 } 1654 1655 GetPrinterA(hprn, 2, NULL, 0, &needed); 1656 pbuf = HeapAlloc(GetProcessHeap(), 0, needed); 1657 GetPrinterA(hprn, 2, (LPBYTE)pbuf, needed, &needed); 1658 GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed); 1659 dbuf = HeapAlloc(GetProcessHeap(),0,needed); 1660 if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) { 1661 ERR("GetPrinterDriverA failed for %s, le %ld, fix your config!\n", 1662 pbuf->pPrinterName,GetLastError()); 1663 COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE); 1664 return FALSE; 1665 } 1666 ClosePrinter(hprn); 1667 PRINTDLG_CreateDevNames16(&(lppd->hDevNames), 1668 dbuf->pDriverPath, 1669 pbuf->pPrinterName, 1670 pbuf->pPortName); 1671 lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,pbuf->pDevMode->dmSize+ 1672 pbuf->pDevMode->dmDriverExtra); 1673 ptr = GlobalLock16(lppd->hDevMode); 1674 memcpy(ptr, pbuf->pDevMode, pbuf->pDevMode->dmSize + 1675 pbuf->pDevMode->dmDriverExtra); 1676 GlobalUnlock16(lppd->hDevMode); 1677 HeapFree(GetProcessHeap(), 0, pbuf); 1678 HeapFree(GetProcessHeap(), 0, dbuf); 1679 bRet = TRUE; 1679 1680 } else { 1680 HGLOBAL hDlgTmpl;1681 PRINT_PTRA *PrintStructures;1682 1683 /* load Dialog resources, 1684 * depending on Flags indicates Print32 or Print32_setup dialog 1681 HGLOBAL hDlgTmpl; 1682 PRINT_PTRA *PrintStructures; 1683 1684 /* load Dialog resources, 1685 * depending on Flags indicates Print32 or Print32_setup dialog 1685 1686 */ 1686 hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd);1687 if (!hDlgTmpl) {1688 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);1689 return FALSE;1690 }1687 hDlgTmpl = PRINTDLG_GetDlgTemplate16(lppd); 1688 if (!hDlgTmpl) { 1689 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 1690 return FALSE; 1691 } 1691 1692 PrintStructures = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 1692 sizeof(PRINT_PTRA));1693 PrintStructures->dlg.lpPrintDlg16 = lppd;1694 PrintStructures->dlg.lpPrintDlg = (LPPRINTDLGA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA));1695 #define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x;1696 #define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x);1697 CVAL(Flags);CVAL(hwndOwner);CVAL(hDC);1698 CVAL(nFromPage);CVAL(nToPage);CVAL(nMinPage);CVAL(nMaxPage);1699 CVAL(nCopies);CVAL(hInstance);CVAL(lCustData);1700 MVAL(lpPrintTemplateName);MVAL(lpSetupTemplateName);1701 /* Don't copy rest, it is 16 bit specific */1693 sizeof(PRINT_PTRA)); 1694 PrintStructures->dlg.lpPrintDlg16 = lppd; 1695 PrintStructures->dlg.lpPrintDlg = (LPPRINTDLGA)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(PRINTDLGA)); 1696 #define CVAL(x) PrintStructures->dlg.lpPrintDlg->x = lppd->x; 1697 #define MVAL(x) PrintStructures->dlg.lpPrintDlg->x = MapSL(lppd->x); 1698 CVAL(Flags);CVAL(hwndOwner);CVAL(hDC); 1699 CVAL(nFromPage);CVAL(nToPage);CVAL(nMinPage);CVAL(nMaxPage); 1700 CVAL(nCopies);CVAL(hInstance);CVAL(lCustData); 1701 MVAL(lpPrintTemplateName);MVAL(lpSetupTemplateName); 1702 /* Don't copy rest, it is 16 bit specific */ 1702 1703 #undef MVAL 1703 1704 #undef CVAL 1704 1705 1705 PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(),0,sizeof(DEVMODEA));1706 1707 /* and create & process the dialog .1708 * -1 is failure, 0 is broken hwnd, everything else is ok.1709 */1710 bRet =(0<DialogBoxIndirectParam16(1711 hInst, hDlgTmpl, lppd->hwndOwner,1712 (DLGPROC16)GetProcAddress16(GetModuleHandle16("COMMDLG"),(LPCSTR)21),1713 (LPARAM)PrintStructures1714 )1715 );1716 if (!PrintStructures->lpPrinterInfo) bRet = FALSE;1717 if(bRet) {1718 DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn;1719 PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo;1720 DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo;1721 1722 if (lppd->hDevMode == 0) {1723 TRACE(" No hDevMode yet... Need to create my own\n");1724 lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE,1725 lpdm->dmSize + lpdm->dmDriverExtra);1726 } else {1727 WORD locks;1728 if((locks = (GlobalFlags16(lppd->hDevMode)&GMEM_LOCKCOUNT))) {1729 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks);1730 while(locks--) {1731 GlobalUnlock16(lppd->hDevMode);1732 TRACE("Now got %d locks\n", locks);1733 }1734 }1735 lppd->hDevMode = GlobalReAlloc16(lppd->hDevMode,1736 lpdm->dmSize + lpdm->dmDriverExtra,1737 GMEM_MOVEABLE);1738 }1739 lpdmReturn = GlobalLock16(lppd->hDevMode);1740 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra);1741 1742 if (lppd->hDevNames != 0) {1743 WORD locks;1744 if((locks = (GlobalFlags16(lppd->hDevNames)&GMEM_LOCKCOUNT))) {1745 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks);1746 while(locks--)1747 GlobalUnlock16(lppd->hDevNames);1748 }1749 }1750 PRINTDLG_CreateDevNames16(&(lppd->hDevNames),1751 di->pDriverPath,1752 pi->pPrinterName,1753 pi->pPortName1754 );1755 GlobalUnlock16(lppd->hDevMode);1756 }1757 if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE)))1706 PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(),0,sizeof(DEVMODEA)); 1707 1708 /* and create & process the dialog . 1709 * -1 is failure, 0 is broken hwnd, everything else is ok. 1710 */ 1711 bRet = (0<DialogBoxIndirectParam16( 1712 hInst, hDlgTmpl, lppd->hwndOwner, 1713 (DLGPROC16)GetProcAddress16(GetModuleHandle16("COMMDLG"),(LPCSTR)21), 1714 (LPARAM)PrintStructures 1715 ) 1716 ); 1717 if (!PrintStructures->lpPrinterInfo) bRet = FALSE; 1718 if(bRet) { 1719 DEVMODEA *lpdm = PrintStructures->lpDevMode, *lpdmReturn; 1720 PRINTER_INFO_2A *pi = PrintStructures->lpPrinterInfo; 1721 DRIVER_INFO_3A *di = PrintStructures->lpDriverInfo; 1722 1723 if (lppd->hDevMode == 0) { 1724 TRACE(" No hDevMode yet... Need to create my own\n"); 1725 lppd->hDevMode = GlobalAlloc16(GMEM_MOVEABLE, 1726 lpdm->dmSize + lpdm->dmDriverExtra); 1727 } else { 1728 WORD locks; 1729 if((locks = (GlobalFlags16(lppd->hDevMode)&GMEM_LOCKCOUNT))) { 1730 WARN("hDevMode has %d locks on it. Unlocking it now\n", locks); 1731 while(locks--) { 1732 GlobalUnlock16(lppd->hDevMode); 1733 TRACE("Now got %d locks\n", locks); 1734 } 1735 } 1736 lppd->hDevMode = GlobalReAlloc16(lppd->hDevMode, 1737 lpdm->dmSize + lpdm->dmDriverExtra, 1738 GMEM_MOVEABLE); 1739 } 1740 lpdmReturn = GlobalLock16(lppd->hDevMode); 1741 memcpy(lpdmReturn, lpdm, lpdm->dmSize + lpdm->dmDriverExtra); 1742 1743 if (lppd->hDevNames != 0) { 1744 WORD locks; 1745 if((locks = (GlobalFlags16(lppd->hDevNames)&GMEM_LOCKCOUNT))) { 1746 WARN("hDevNames has %d locks on it. Unlocking it now\n", locks); 1747 while(locks--) 1748 GlobalUnlock16(lppd->hDevNames); 1749 } 1750 } 1751 PRINTDLG_CreateDevNames16(&(lppd->hDevNames), 1752 di->pDriverPath, 1753 pi->pPrinterName, 1754 pi->pPortName 1755 ); 1756 GlobalUnlock16(lppd->hDevMode); 1757 } 1758 if (!(lppd->Flags & (PD_ENABLESETUPTEMPLATEHANDLE | PD_ENABLESETUPTEMPLATE))) 1758 1759 GlobalFree16(hDlgTmpl); /* created from the 32 bits resource */ 1759 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);1760 HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);1761 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);1762 HeapFree(GetProcessHeap(), 0, PrintStructures);1760 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode); 1761 HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo); 1762 HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo); 1763 HeapFree(GetProcessHeap(), 0, PrintStructures); 1763 1764 } 1764 1765 if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC)) 1765 1766 bRet = PRINTDLG_CreateDC16(lppd); 1766 1767 1767 TRACE("exit! (%d)\n", bRet); 1768 return bRet; 1768 TRACE("exit! (%d)\n", bRet); 1769 return bRet; 1769 1770 } 1770 1771 #endif … … 1798 1799 1799 1800 typedef struct { 1800 LPPAGESETUPDLGA dlga;1801 1802 PRINTDLGA pdlg;1801 LPPAGESETUPDLGA dlga; 1802 1803 PRINTDLGA pdlg; 1803 1804 } PageSetupData; 1804 1805 … … 1808 1809 1809 1810 if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATEHANDLE) { 1810 hDlgTmpl = lppd->hPageSetupTemplate;1811 } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) { 1812 hResInfo = FindResourceA(lppd->hInstance,1813 lppd->lpPageSetupTemplateName, RT_DIALOGA);1814 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);1811 hDlgTmpl = lppd->hPageSetupTemplate; 1812 } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) { 1813 hResInfo = FindResourceA(lppd->hInstance, 1814 lppd->lpPageSetupTemplateName, RT_DIALOGA); 1815 hDlgTmpl = LoadResource(lppd->hInstance, hResInfo); 1815 1816 } else { 1816 hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA);1817 hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo);1817 hResInfo = FindResourceA(COMDLG32_hInstance,(LPCSTR)PAGESETUPDLGORD,RT_DIALOGA); 1818 hDlgTmpl = LoadResource(COMDLG32_hInstance,hResInfo); 1818 1819 } 1819 1820 return hDlgTmpl; … … 1823 1824 _c_10mm2size(PAGESETUPDLGA *dlga,DWORD size) { 1824 1825 if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) 1825 return 10*size*10/25.4;1826 return 10*size*10/25.4; 1826 1827 /* If we don't have a flag, we can choose one. Use millimeters 1827 1828 * to avoid confusing me … … 1836 1837 _c_inch2size(PAGESETUPDLGA *dlga,DWORD size) { 1837 1838 if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) 1838 return size;1839 return size; 1839 1840 if (dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) 1840 return (size*254)/10;1841 return (size*254)/10; 1841 1842 /* if we don't have a flag, we can choose one. Use millimeters 1842 1843 * to avoid confusing me … … 1850 1851 strcpy(strout,"<undef>"); 1851 1852 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) { 1852 sprintf(strout,"%.2fmm",(size*1.0)/100.0);1853 return;1853 sprintf(strout,"%.2fmm",(size*1.0)/100.0); 1854 return; 1854 1855 } 1855 1856 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) { 1856 sprintf(strout,"%.2fin",(size*1.0)/1000.0);1857 return;1857 sprintf(strout,"%.2fin",(size*1.0)/1000.0); 1858 return; 1858 1859 } 1859 1860 pda->dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; … … 1864 1865 static DWORD 1865 1866 _c_str2size(PageSetupData *pda,LPCSTR strin) { 1866 float val;1867 char rest[200];1867 float val; 1868 char rest[200]; 1868 1869 1869 1870 rest[0]='\0'; 1870 1871 if (!sscanf(strin,"%f%s",&val,rest)) 1871 return 0;1872 return 0; 1872 1873 1873 1874 if (!strcmp(rest,"in") || !strcmp(rest,"inch")) { 1874 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)1875 return 1000*val;1876 else1877 return val*25.4*100;1875 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) 1876 return 1000*val; 1877 else 1878 return val*25.4*100; 1878 1879 } 1879 1880 if (!strcmp(rest,"cm")) { rest[0]='m'; val = val*10.0; } … … 1881 1882 1882 1883 if (!strcmp(rest,"mm")) { 1883 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)1884 return 100*val;1885 else1886 return 1000.0*val/25.4;1884 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) 1885 return 100*val; 1886 else 1887 return 1000.0*val/25.4; 1887 1888 } 1888 1889 if (rest[0]=='\0') { 1889 /* use application supplied default */1890 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) {1891 /* 100*mm */1892 return 100.0*val;1893 }1894 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) {1895 /* 1000*inch */1896 return 1000.0*val;1897 }1890 /* use application supplied default */ 1891 if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) { 1892 /* 100*mm */ 1893 return 100.0*val; 1894 } 1895 if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) { 1896 /* 1000*inch */ 1897 return 1000.0*val; 1898 } 1898 1899 } 1899 1900 ERR("Did not find a conversion for type '%s'!\n",rest); … … 1908 1909 static BOOL 1909 1910 PRINTDLG_PS_UpdateDlgStruct(HWND hDlg, PageSetupData *pda) { 1910 DEVNAMES *dn;1911 DEVMODEA *dm;1912 LPSTR devname,portname;1913 char papername[64];1914 char buf[200];1915 1911 DEVNAMES *dn; 1912 DEVMODEA *dm; 1913 LPSTR devname,portname; 1914 char papername[64]; 1915 char buf[200]; 1916 1916 1917 dn = GlobalLock(pda->pdlg.hDevNames); 1917 1918 dm = GlobalLock(pda->pdlg.hDevMode); 1918 devname = ((char*)dn)+dn->wDeviceOffset;1919 portname = ((char*)dn)+dn->wOutputOffset;1919 devname = ((char*)dn)+dn->wDeviceOffset; 1920 portname = ((char*)dn)+dn->wOutputOffset; 1920 1921 PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm); 1921 1922 PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm); 1922 1923 1923 1924 if (GetDlgItemTextA(hDlg,cmb2,papername,sizeof(papername))>0) { 1924 PRINTDLG_PaperSize(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize));1925 pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x);1926 pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y);1925 PRINTDLG_PaperSize(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize)); 1926 pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x); 1927 pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y); 1927 1928 } else 1928 FIXME("could not get dialog text for papersize cmbbox?\n");1929 FIXME("could not get dialog text for papersize cmbbox?\n"); 1929 1930 #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); } 1930 1931 GETVAL(edt4,pda->dlga->rtMargin.left); … … 1936 1937 /* If we are in landscape, swap x and y of page size */ 1937 1938 if (IsDlgButtonChecked(hDlg, rad2)) { 1938 DWORD tmp;1939 tmp = pda->dlga->ptPaperSize.x;1940 pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y;1941 pda->dlga->ptPaperSize.y = tmp;1939 DWORD tmp; 1940 tmp = pda->dlga->ptPaperSize.x; 1941 pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y; 1942 pda->dlga->ptPaperSize.y = tmp; 1942 1943 } 1943 1944 GlobalUnlock(pda->pdlg.hDevNames); … … 1951 1952 static BOOL 1952 1953 PRINTDLG_PS_ChangePrinter(HWND hDlg, PageSetupData *pda) { 1953 DEVNAMES *dn;1954 DEVMODEA *dm;1955 LPSTR devname,portname;1956 1954 DEVNAMES *dn; 1955 DEVMODEA *dm; 1956 LPSTR devname,portname; 1957 1957 1958 dn = GlobalLock(pda->pdlg.hDevNames); 1958 1959 dm = GlobalLock(pda->pdlg.hDevMode); 1959 devname = ((char*)dn)+dn->wDeviceOffset;1960 portname = ((char*)dn)+dn->wOutputOffset;1960 devname = ((char*)dn)+dn->wDeviceOffset; 1961 portname = ((char*)dn)+dn->wOutputOffset; 1961 1962 PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm); 1962 1963 PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm); … … 1973 1974 case IDOK: 1974 1975 if (!PRINTDLG_PS_UpdateDlgStruct(hDlg, pda)) 1975 return(FALSE);1976 EndDialog(hDlg, TRUE);1977 return TRUE ;1976 return(FALSE); 1977 EndDialog(hDlg, TRUE); 1978 return TRUE ; 1978 1979 1979 1980 case IDCANCEL: 1980 1981 EndDialog(hDlg, FALSE); 1981 return FALSE ;1982 return FALSE ; 1982 1983 1983 1984 case psh3: { 1984 pda->pdlg.Flags= 0;1985 pda->pdlg.hwndOwner= hDlg;1986 if (PrintDlgA(&(pda->pdlg)))1987 PRINTDLG_PS_ChangePrinter(hDlg,pda);1988 return TRUE;1985 pda->pdlg.Flags = 0; 1986 pda->pdlg.hwndOwner = hDlg; 1987 if (PrintDlgA(&(pda->pdlg))) 1988 PRINTDLG_PS_ChangePrinter(hDlg,pda); 1989 return TRUE; 1989 1990 } 1990 1991 } 1991 1992 FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n", 1992 LOWORD(lParam),wParam,lParam1993 LOWORD(lParam),wParam,lParam 1993 1994 ); 1994 1995 return FALSE; … … 1999 2000 PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 2000 2001 { 2001 PageSetupData *pda;2002 BOOL res = FALSE;2002 PageSetupData *pda; 2003 BOOL res = FALSE; 2003 2004 2004 2005 if (uMsg==WM_INITDIALOG) { 2005 res = TRUE;2006 res = TRUE; 2006 2007 pda = (PageSetupData*)lParam; 2007 SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam);2008 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {2009 res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam);2010 if (!res) {2011 FIXME("Setup page hook failed?\n");2012 res = TRUE;2013 }2014 }2015 if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) {2016 FIXME("PagePaintHook not yet implemented!\n");2017 }2018 if (pda->dlga->Flags & PSD_DISABLEPRINTER)2019 EnableWindow(GetDlgItem(hDlg, psh3), FALSE); 2020 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); 2025 }2026 /* width larger as height -> landscape */2027 if (pda->dlga->ptPaperSize.x > pda->dlga->ptPaperSize.y)2008 SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",lParam); 2009 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { 2010 res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam); 2011 if (!res) { 2012 FIXME("Setup page hook failed?\n"); 2013 res = TRUE; 2014 } 2015 } 2016 if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) { 2017 FIXME("PagePaintHook not yet implemented!\n"); 2018 } 2019 if (pda->dlga->Flags & PSD_DISABLEPRINTER) 2020 EnableWindow(GetDlgItem(hDlg, psh3), FALSE); 2021 if (pda->dlga->Flags & PSD_DISABLEMARGINS) { 2022 EnableWindow(GetDlgItem(hDlg, edt4), FALSE); 2023 EnableWindow(GetDlgItem(hDlg, edt5), FALSE); 2024 EnableWindow(GetDlgItem(hDlg, edt6), FALSE); 2025 EnableWindow(GetDlgItem(hDlg, edt7), FALSE); 2026 } 2027 /* width larger as height -> landscape */ 2028 if (pda->dlga->ptPaperSize.x > pda->dlga->ptPaperSize.y) 2028 2029 CheckRadioButton(hDlg, rad1, rad2, rad2); 2029 else /* this is default if papersize is not set */2030 else /* this is default if papersize is not set */ 2030 2031 CheckRadioButton(hDlg, rad1, rad2, rad1); 2031 if (pda->dlga->Flags & PSD_DISABLEORIENTATION) { 2032 EnableWindow(GetDlgItem(hDlg,rad1),FALSE); 2033 EnableWindow(GetDlgItem(hDlg,rad2),FALSE); 2034 } 2035 /* We fill them out enabled or not */ 2036 if (pda->dlga->Flags & PSD_MARGINS) { 2037 char str[100]; 2038 _c_size2str(pda,pda->dlga->rtMargin.left,str); 2039 SetDlgItemTextA(hDlg,edt4,str); 2040 _c_size2str(pda,pda->dlga->rtMargin.top,str); 2041 SetDlgItemTextA(hDlg,edt5,str); 2042 _c_size2str(pda,pda->dlga->rtMargin.right,str); 2043 SetDlgItemTextA(hDlg,edt6,str); 2044 _c_size2str(pda,pda->dlga->rtMargin.bottom,str); 2045 SetDlgItemTextA(hDlg,edt7,str); 2046 } else { 2047 /* default is 1 inch */ 2048 DWORD size = _c_inch2size(pda->dlga,1000); 2049 char str[20]; 2050 _c_size2str(pda,size,str); 2051 SetDlgItemTextA(hDlg,edt4,str); 2052 SetDlgItemTextA(hDlg,edt5,str); 2053 SetDlgItemTextA(hDlg,edt6,str); 2054 SetDlgItemTextA(hDlg,edt7,str); 2055 } 2056 PRINTDLG_PS_ChangePrinter(hDlg,pda); 2057 if (pda->dlga->Flags & PSD_DISABLEPAPER) { 2058 EnableWindow(GetDlgItem(hDlg,cmb2),FALSE); 2059 EnableWindow(GetDlgItem(hDlg,cmb3),FALSE); 2060 } 2061 return TRUE; 2032 if (pda->dlga->Flags & PSD_DISABLEORIENTATION) { 2033 EnableWindow(GetDlgItem(hDlg,rad1),FALSE); 2034 EnableWindow(GetDlgItem(hDlg,rad2),FALSE); 2035 } 2036 /* We fill them out enabled or not */ 2037 if (pda->dlga->Flags & PSD_MARGINS) { 2038 char str[100]; 2039 _c_size2str(pda,pda->dlga->rtMargin.left,str); 2040 SetDlgItemTextA(hDlg,edt4,str); 2041 _c_size2str(pda,pda->dlga->rtMargin.top,str); 2042 SetDlgItemTextA(hDlg,edt5,str); 2043 _c_size2str(pda,pda->dlga->rtMargin.right,str); 2044 SetDlgItemTextA(hDlg,edt6,str); 2045 _c_size2str(pda,pda->dlga->rtMargin.bottom,str); 2046 SetDlgItemTextA(hDlg,edt7,str); 2062 2047 } else { 2063 pda = (PageSetupData*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA"); 2064 if (!pda) { 2065 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n"); 2066 return FALSE; 2067 } 2068 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { 2069 res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam); 2070 if (res) return res; 2071 } 2048 /* default is 1 inch */ 2049 DWORD size = _c_inch2size(pda->dlga,1000); 2050 char str[20]; 2051 _c_size2str(pda,size,str); 2052 SetDlgItemTextA(hDlg,edt4,str); 2053 SetDlgItemTextA(hDlg,edt5,str); 2054 SetDlgItemTextA(hDlg,edt6,str); 2055 SetDlgItemTextA(hDlg,edt7,str); 2056 } 2057 PRINTDLG_PS_ChangePrinter(hDlg,pda); 2058 if (pda->dlga->Flags & PSD_DISABLEPAPER) { 2059 EnableWindow(GetDlgItem(hDlg,cmb2),FALSE); 2060 EnableWindow(GetDlgItem(hDlg,cmb3),FALSE); 2061 } 2062 return TRUE; 2063 } else { 2064 pda = (PageSetupData*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA"); 2065 if (!pda) { 2066 WARN("__WINE_PAGESETUPDLGDATA prop not set?\n"); 2067 return FALSE; 2068 } 2069 if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { 2070 res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,lParam); 2071 if (res) return res; 2072 } 2072 2073 } 2073 2074 switch (uMsg) { … … 2082 2083 */ 2083 2084 BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) { 2084 HGLOBAL hDlgTmpl;2085 LPVOID ptr;2086 BOOL bRet;2087 PageSetupData *pda;2088 PRINTDLGA pdlg;2085 HGLOBAL hDlgTmpl; 2086 LPVOID ptr; 2087 BOOL bRet; 2088 PageSetupData *pda; 2089 PRINTDLGA pdlg; 2089 2090 2090 2091 #ifdef __WIN32OS2__ … … 2094 2095 if(TRACE_ON(commdlg)) { 2095 2096 char flagstr[1000] = ""; 2096 struct pd_flags *pflag = psd_flags;2097 for( ; pflag->name; pflag++) {2098 if(setupdlg->Flags & pflag->flag) {2099 strcat(flagstr, pflag->name);2100 strcat(flagstr, "|");2101 }2102 }2103 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n"2104 "hinst %08x, flags %08lx (%s)\n",2105 setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode,2106 setupdlg->hDevNames, 2107 setupdlg->hInstance, setupdlg->Flags, flagstr);2097 struct pd_flags *pflag = psd_flags; 2098 for( ; pflag->name; pflag++) { 2099 if(setupdlg->Flags & pflag->flag) { 2100 strcat(flagstr, pflag->name); 2101 strcat(flagstr, "|"); 2102 } 2103 } 2104 TRACE("(%p): hwndOwner = %08x, hDevMode = %08x, hDevNames = %08x\n" 2105 "hinst %08x, flags %08lx (%s)\n", 2106 setupdlg, setupdlg->hwndOwner, setupdlg->hDevMode, 2107 setupdlg->hDevNames, 2108 setupdlg->hInstance, setupdlg->Flags, flagstr); 2108 2109 } 2109 2110 2110 2111 /* First get default printer data, we need it right after that. */ 2111 2112 memset(&pdlg,0,sizeof(pdlg)); 2112 pdlg.lStructSize = sizeof(pdlg);2113 pdlg.Flags = PD_RETURNDEFAULT;2113 pdlg.lStructSize = sizeof(pdlg); 2114 pdlg.Flags = PD_RETURNDEFAULT; 2114 2115 bRet = PrintDlgA(&pdlg); 2115 2116 if (!bRet) return FALSE; … … 2117 2118 /* short cut exit, just return default values */ 2118 2119 if (setupdlg->Flags & PSD_RETURNDEFAULT) { 2119 setupdlg->hDevMode= pdlg.hDevMode;2120 setupdlg->hDevNames= pdlg.hDevNames;2121 /* FIXME: Just return "A4" for now. */2122 PRINTDLG_PaperSize(&pdlg,"A4",&setupdlg->ptPaperSize);2123 setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x);2124 setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y);2125 return TRUE;2120 setupdlg->hDevMode = pdlg.hDevMode; 2121 setupdlg->hDevNames = pdlg.hDevNames; 2122 /* FIXME: Just return "A4" for now. */ 2123 PRINTDLG_PaperSize(&pdlg,"A4",&setupdlg->ptPaperSize); 2124 setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x); 2125 setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y); 2126 return TRUE; 2126 2127 } 2127 2128 hDlgTmpl = PRINTDLG_GetPGSTemplate(setupdlg); 2128 2129 if (!hDlgTmpl) { 2129 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);2130 return FALSE;2130 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 2131 return FALSE; 2131 2132 } 2132 2133 ptr = LockResource( hDlgTmpl ); 2133 2134 if (!ptr) { 2134 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);2135 return FALSE;2135 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); 2136 return FALSE; 2136 2137 } 2137 2138 pda = HeapAlloc(GetProcessHeap(),0,sizeof(*pda)); … … 2140 2141 2141 2142 bRet = (0<DialogBoxIndirectParamA( 2142 setupdlg->hInstance,2143 ptr,2144 setupdlg->hwndOwner,2145 PageDlgProcA,2146 (LPARAM)pda)2143 setupdlg->hInstance, 2144 ptr, 2145 setupdlg->hwndOwner, 2146 PageDlgProcA, 2147 (LPARAM)pda) 2147 2148 ); 2148 2149 return bRet; … … 2155 2156 dprintf(("PageSetupDlgA %x NOT IMPLEMENTED", setupdlg)); 2156 2157 #endif 2157 FIXME("(%p), stub!\n",setupdlg);2158 return FALSE;2158 FIXME("(%p), stub!\n",setupdlg); 2159 return FALSE; 2159 2160 } 2160 2161 … … 2175 2176 2176 2177 if (uMsg!=WM_INITDIALOG) { 2177 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER); 2178 if (!PrintStructures)2179 return FALSE;2178 PrintStructures = (PRINT_PTRA*) GetWindowLongA(hDlg, DWL_USER); 2179 if (!PrintStructures) 2180 return FALSE; 2180 2181 } else { 2181 2182 PrintStructures = (PRINT_PTRA*) lParam; 2182 SetWindowLongA(hDlg, DWL_USER, lParam); 2183 res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures); 2184 2185 if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { 2186 res = CallWindowProc16( 2187 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2188 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16 2189 ); 2190 } 2191 return res; 2192 } 2193 2183 SetWindowLongA(hDlg, DWL_USER, lParam); 2184 res = PRINTDLG_WMInitDialog16(hDlg, wParam, PrintStructures); 2185 2194 2186 if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { 2195 2187 res = CallWindowProc16( 2196 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2197 hDlg,uMsg, wParam, lParam 2198 ); 2199 if(LOWORD(res)) return res; 2188 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2189 hDlg, uMsg, wParam, (LPARAM)PrintStructures->dlg.lpPrintDlg16 2190 ); 2191 } 2192 return res; 2193 } 2194 2195 if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) { 2196 res = CallWindowProc16( 2197 (WNDPROC16)PrintStructures->dlg.lpPrintDlg16->lpfnPrintHook, 2198 hDlg,uMsg, wParam, lParam 2199 ); 2200 if(LOWORD(res)) return res; 2200 2201 } 2201 2202 2202 2203 switch (uMsg) { 2203 2204 case WM_COMMAND: { 2204 /* We need to map those for the 32bit window procedure, compare2205 * with 32Ato16 mapper in winproc.c2206 */2205 /* We need to map those for the 32bit window procedure, compare 2206 * with 32Ato16 mapper in winproc.c 2207 */ 2207 2208 return PRINTDLG_WMCommand( 2208 hDlg,2209 MAKEWPARAM(wParam,HIWORD(lParam)),2210 LOWORD(lParam),2211 PrintStructures2212 );2209 hDlg, 2210 MAKEWPARAM(wParam,HIWORD(lParam)), 2211 LOWORD(lParam), 2212 PrintStructures 2213 ); 2213 2214 } 2214 2215 case WM_DESTROY: 2215 DestroyIcon(PrintStructures->hCollateIcon);2216 DestroyIcon(PrintStructures->hNoCollateIcon);2216 DestroyIcon(PrintStructures->hCollateIcon); 2217 DestroyIcon(PrintStructures->hNoCollateIcon); 2217 2218 /* FIXME: don't forget to delete the paper orientation icons here! */ 2218 2219 2219 2220 return FALSE; 2220 } 2221 } 2221 2222 return res; 2222 2223 } … … 2227 2228 */ 2228 2229 LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, 2229 LPARAM lParam)2230 LPARAM lParam) 2230 2231 { 2231 2232 switch (wMsg) … … 2238 2239 switch (wParam) { 2239 2240 case IDOK: 2240 EndDialog(hWnd, TRUE);2241 return(TRUE);2241 EndDialog(hWnd, TRUE); 2242 return(TRUE); 2242 2243 case IDCANCEL: 2243 EndDialog(hWnd, FALSE);2244 return(TRUE);2244 EndDialog(hWnd, FALSE); 2245 return(TRUE); 2245 2246 } 2246 2247 return(FALSE); … … 2251 2252 2252 2253 /*********************************************************************** 2253 * PrintDlgExA (COMDLG32.@)2254 * PrintDlgExA (COMDLG32.@) 2254 2255 */ 2255 2256 HRESULT WINAPI PrintDlgExA(LPVOID lpPrintDlgExA) /* [???] FIXME: LPPRINTDLGEXA */ 2256 2257 { 2257 FIXME("stub\n");2258 return E_NOTIMPL;2258 FIXME("stub\n"); 2259 return E_NOTIMPL; 2259 2260 } 2260 2261 /*********************************************************************** 2261 * PrintDlgExW (COMDLG32.@)2262 * PrintDlgExW (COMDLG32.@) 2262 2263 */ 2263 2264 HRESULT WINAPI PrintDlgExW(LPVOID lpPrintDlgExW) /* [???] FIXME: LPPRINTDLGEXW */ 2264 2265 { 2265 FIXME("stub\n");2266 return E_NOTIMPL;2267 } 2266 FIXME("stub\n"); 2267 return E_NOTIMPL; 2268 }
Note:
See TracChangeset
for help on using the changeset viewer.
