Ignore:
Timestamp:
Sep 5, 2001, 2:14:25 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

File:
1 edited

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 $ */
    12/*
    23 * COMMDLG - Print Dialog
     
    3031/* This PRINTDLGA internal structure stores
    3132 * pointers to several throughout useful structures.
    32  * 
    33  */
    34 typedef struct 
     33 *
     34 */
     35typedef struct
    3536{
    3637  LPDEVMODEA        lpDevMode;
    3738  struct {
    3839      LPPRINTDLGA       lpPrintDlg;
    39       LPPRINTDLG16      lpPrintDlg16;
     40      LPPRINTDLG16  lpPrintDlg16;
    4041  } dlg;
    4142  LPPRINTER_INFO_2A lpPrinterInfo;
     
    108109 *
    109110 * 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 -
    111112 * these entries are mapped somewhere in the registry rather than win.ini.
    112113 *
     
    118119
    119120    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;
    122123    }
    123124    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;
    126127    }
    127128    *ptr = '\0';
     
    145146    res = OpenPrinterA(buf, hprn, NULL);
    146147    if (!res)
    147         FIXME("Could not open printer %s?!\n",buf);
     148    FIXME("Could not open printer %s?!\n",buf);
    148149    return res;
    149150}
     
    169170    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
    170171    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);
    173174
    174175    for(i = 0; i < num; i++) {
    175176        SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0,
    176                             (LPARAM)pi[i].pPrinterName );
     177                (LPARAM)pi[i].pPrinterName );
    177178    }
    178179    HeapFree(GetProcessHeap(), 0, pi);
    179180    if(!name ||
    180181       (i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1,
    181                                 (LPARAM)name)) == CB_ERR) {
     182                (LPARAM)name)) == CB_ERR) {
    182183
    183184        char buf[260];
    184185        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");
    191192    }
    192193    SendDlgItemMessageA(hDlg, id, CB_SETCURSEL, i, 0);
     
    202203 *  (NB. when we handle unicode the offsets will be in wchars).
    203204 */
    204 static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName, 
    205                                     char* DeviceName, char* OutputPort)
     205static BOOL PRINTDLG_CreateDevNames(HGLOBAL *hmem, char* DeviceDriverName,
     206                    char* DeviceName, char* OutputPort)
    206207{
    207208    long size;
     
    215216            + strlen(OutputPort) + 1
    216217            + sizeof(DEVNAMES);
    217            
     218
    218219    if(*hmem)
    219220        *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
     
    233234    strcpy(pTempPtr, DeviceName);
    234235    lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
    235        
     236
    236237    pTempPtr += strlen(DeviceName) + 1;
    237238    strcpy(pTempPtr, OutputPort);
     
    244245}
    245246#ifndef __WIN32OS2__
    246 static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName, 
    247                                       char* DeviceName, char* OutputPort)
     247static BOOL PRINTDLG_CreateDevNames16(HGLOBAL16 *hmem, char* DeviceDriverName,
     248                      char* DeviceName, char* OutputPort)
    248249{
    249250    long size;
     
    257258            + strlen(OutputPort) + 1
    258259            + sizeof(DEVNAMES);
    259            
     260
    260261    if(*hmem)
    261262        *hmem = GlobalReAlloc16(*hmem, size, GMEM_MOVEABLE);
     
    275276    strcpy(pTempPtr, DeviceName);
    276277    lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
    277        
     278
    278279    pTempPtr += strlen(DeviceName) + 1;
    279280    strcpy(pTempPtr, OutputPort);
     
    292293 *
    293294 *   updates the PrintDlg structure for returnvalues.
    294  *     
     295 *
    295296 * RETURNS
    296297 *   FALSE if user is not allowed to close (i.e. wrong nTo or nFrom values)
    297298 *   TRUE  if succesful.
    298299 */
    299 static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg, 
    300                                     PRINT_PTRA* PrintStructures)
     300static BOOL PRINTDLG_UpdatePrintDlg(HWND hDlg,
     301                    PRINT_PTRA* PrintStructures)
    301302{
    302303    LPPRINTDLGA       lppd = PrintStructures->dlg.lpPrintDlg;
     
    306307
    307308    if(!lpdm) {
    308         FIXME("No lpdm ptr?\n");
    309         return FALSE;
     309    FIXME("No lpdm ptr?\n");
     310    return FALSE;
    310311    }
    311312
     
    313314    if(!(lppd->Flags & PD_PRINTSETUP)) {
    314315        /* check whether nFromPage and nToPage are within range defined by
    315         * nMinPage and nMaxPage
    316         */
     316    * nMinPage and nMaxPage
     317    */
    317318        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 there
    355            * 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;
    365366            else
    366367               lppd->Flags &= ~PD_COLLATE;
    367368            lppd->nCopies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
    368         }
     369    }
    369370    }
    370371    return TRUE;
     
    372373
    373374static BOOL PRINTDLG_PaperSize(
    374         PRINTDLGA       *pdlga,const char *PaperSize,LPPOINT size
     375    PRINTDLGA   *pdlga,const char *PaperSize,LPPOINT size
    375376) {
    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
    385386    dn = GlobalLock(pdlga->hDevNames);
    386387    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;
    389390
    390391
    391392    NrOfEntries = DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,NULL,dm);
    392393    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;
    395396    }
    396397    Names = (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries*64);
    397398    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;
    400401    }
    401402    for (i=0;i<NrOfEntries;i++)
    402         if (!strcmp(PaperSize,Names+(64*i)))
    403             break;
     403    if (!strcmp(PaperSize,Names+(64*i)))
     404        break;
    404405    HeapFree(GetProcessHeap(),0,Names);
    405406    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;
    408409    }
    409410    points = HeapAlloc(GetProcessHeap(),0,sizeof(points[0])*NrOfEntries);
    410411    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;
    413414    }
    414415    /* this is _10ths_ of a millimeter */
     
    434435 */
    435436static 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)
    440441{
    441442    int     i;
     
    448449    int     fwCapability_Names;
    449450    int     fwCapability_Words;
    450    
     451
    451452    TRACE(" Printer: %s, ComboID: %d\n",PrinterName,nIDComboBox);
    452    
     453
    453454    /* query the dialog box for the current selected value */
    454455    Sel = SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETCURSEL, 0, 0);
     
    498499         fwCapability_Words = DC_BINS;
    499500    }
    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
    502503     * paper settings. As Wine doesn't allow VXDs, this results in a crash.
    503504     */
     
    511512       != NrOfEntries) {
    512513        ERR("Number of caps is different\n");
    513         NrOfEntries = 0;
     514    NrOfEntries = 0;
    514515    }
    515516
     
    519520                                      fwCapability_Names, Names, dm);
    520521    NrOfEntries = DeviceCapabilitiesA(PrinterName, PortName,
    521                                       fwCapability_Words, (LPSTR)Words, dm);
     522                      fwCapability_Words, (LPSTR)Words, dm);
    522523
    523524    /* reset any current content in the combobox */
    524525    SendDlgItemMessageA(hDlg, nIDComboBox, CB_RESETCONTENT, 0, 0);
    525    
     526
    526527    /* store new content */
    527528    for (i = 0; i < NrOfEntries; i++) {
    528529        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]);
    532533    }
    533534
     
    537538    for (i = 0; i < NrOfEntries; i++) {
    538539        if(SendDlgItemMessageA(hDlg, nIDComboBox, CB_GETITEMDATA, i, 0) ==
    539            oldWord) {
    540             Sel = i;
    541             break;
    542         }
     540       oldWord) {
     541        Sel = i;
     542        break;
     543    }
    543544    }
    544545    SendDlgItemMessageA(hDlg, nIDComboBox, CB_SETCURSEL, Sel, 0);
     
    564565    for (i = 0; i < 25; i++) {
    565566        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);
    569570        }
    570571    }
    571572    /* append "ready" */
    572     /* FIXME: status==ready must only be appended if really so. 
     573    /* FIXME: status==ready must only be appended if really so.
    573574              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);
    576577    strcat(StatusMsg,ResourceString);
    577  
     578
    578579    SendDlgItemMessageA(hDlg, stc12, WM_SETTEXT, 0, (LPARAM)StatusMsg);
    579580
     
    585586        SendDlgItemMessageA(hDlg, stc14, WM_SETTEXT, 0,(LPARAM)pi->pPortName);
    586587    SendDlgItemMessageA(hDlg, stc13, WM_SETTEXT, 0, (LPARAM)(pi->pComment ?
    587                         pi->pComment : ""));
     588            pi->pComment : ""));
    588589    return;
    589590}
     
    596597 */
    597598static BOOL PRINTDLG_ChangePrinter(HWND hDlg, char *name,
    598                                    PRINT_PTRA *PrintStructures)
     599                   PRINT_PTRA *PrintStructures)
    599600{
    600601    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    610611    if(!OpenPrinterA(name, &hprn, NULL)) {
    611612        ERR("Can't open printer %s\n", name);
    612         return FALSE;
     613    return FALSE;
    613614    }
    614615    GetPrinterA(hprn, 2, NULL, 0, &needed);
    615616    PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed);
    616617    GetPrinterA(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
    617                 &needed);
     618        &needed);
    618619    GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
    619620    PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed);
    620621    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;
    624625    }
    625626    ClosePrinter(hprn);
     
    629630    if(PrintStructures->lpDevMode) {
    630631        HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
    631         PrintStructures->lpDevMode = NULL;
     632    PrintStructures->lpDevMode = NULL;
    632633    }
    633634
     
    635636    if(dmSize == -1) {
    636637        ERR("DocumentProperties fails on %s\n", debugstr_a(name));
    637         return FALSE;
     638    return FALSE;
    638639    }
    639640    PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
    640641    dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL,
    641                                 DM_OUT_BUFFER);
     642                DM_OUT_BUFFER);
    642643    if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
    643                           !strcmp(lpdm->dmDeviceName,
    644                                   PrintStructures->lpDevMode->dmDeviceName)) {
     644              !strcmp(lpdm->dmDeviceName,
     645                  PrintStructures->lpDevMode->dmDeviceName)) {
    645646      /* Supplied devicemode matches current printer so try to use it */
    646647        DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm,
    647                             DM_OUT_BUFFER | DM_IN_BUFFER);
     648                DM_OUT_BUFFER | DM_IN_BUFFER);
    648649    }
    649650    if(lpdm)
     
    655656      /* Print range (All/Range/Selection) */
    656657        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         else
    662             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           else
    712               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)
    731732            ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
    732733
     
    739740
    740741      PRINTDLG_SetUpPaperComboBox(hDlg, cmb2,
    741                                   PrintStructures->lpPrinterInfo->pPrinterName,
    742                                   PrintStructures->lpPrinterInfo->pPortName,
    743                                   lpdm);
     742                  PrintStructures->lpPrinterInfo->pPrinterName,
     743                  PrintStructures->lpPrinterInfo->pPortName,
     744                  lpdm);
    744745      PRINTDLG_SetUpPaperComboBox(hDlg, cmb3,
    745                                   PrintStructures->lpPrinterInfo->pPrinterName,
    746                                   PrintStructures->lpPrinterInfo->pPortName,
    747                                   lpdm);
     746                  PrintStructures->lpPrinterInfo->pPrinterName,
     747                  PrintStructures->lpPrinterInfo->pPortName,
     748                  lpdm);
    748749      CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
    749750      SendDlgItemMessageA(hDlg, ico1, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    750751                          (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
    751752                                   PrintStructures->hLandscapeIcon));
    752      
     753
    753754    }
    754755
     
    756757    if ((lppd->Flags & PD_SHOWHELP)==0) {
    757758        /* hide if PD_SHOWHELP not specified */
    758         ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);         
     759        ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);
    759760    }
    760761    return TRUE;
     
    765766 */
    766767static LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam,
    767                                      PRINT_PTRA* PrintStructures)
     768                     PRINT_PTRA* PrintStructures)
    768769{
    769770    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    778779    PrintStructures->hCollateIcon =
    779780      LoadImageA(COMDLG32_hInstance, "PD32_COLLATE", IMAGE_ICON, 0, 0, 0);
    780     PrintStructures->hNoCollateIcon = 
     781    PrintStructures->hNoCollateIcon =
    781782      LoadImageA(COMDLG32_hInstance, "PD32_NOCOLLATE", IMAGE_ICON, 0, 0, 0);
    782783
     
    792793       PrintStructures->hLandscapeIcon == 0) {
    793794        ERR("no icon in resourcefile\n");
    794         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    795         EndDialog(hDlg, FALSE);
     795    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     796    EndDialog(hDlg, FALSE);
    796797    }
    797798
     
    801802     */
    802803    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    }
    808809    } else
    809810        PrintStructures->HelpMessageID = 0;
     
    811812    if(!(lppd->Flags &PD_PRINTSETUP)) {
    812813        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);
    818819    }
    819820
     
    823824     */
    824825    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;
    828829    if (lppd->nToPage < lppd->nMinPage)
    829830        lppd->nToPage = lppd->nMinPage;
     
    837838    /* if we have the combo box, fill it */
    838839    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);
    856857    } 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         else
    864             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");
    865866    }
    866867    return TRUE;
     
    872873 */
    873874static LRESULT PRINTDLG_WMInitDialog16(HWND hDlg, WPARAM wParam,
    874                                      PRINT_PTRA* PrintStructures)
     875                     PRINT_PTRA* PrintStructures)
    875876{
    876877    LPPRINTDLG16 lppd = PrintStructures->dlg.lpPrintDlg16;
     
    883884    PrintStructures->hCollateIcon =
    884885      LoadIconA(COMDLG32_hInstance, "PD32_COLLATE");
    885     PrintStructures->hNoCollateIcon = 
     886    PrintStructures->hNoCollateIcon =
    886887      LoadIconA(COMDLG32_hInstance, "PD32_NOCOLLATE");
    887888    if(PrintStructures->hCollateIcon == 0 ||
    888889       PrintStructures->hNoCollateIcon == 0) {
    889890        ERR("no icon in resourcefile\n");
    890         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    891         EndDialog(hDlg, FALSE);
     891    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     892    EndDialog(hDlg, FALSE);
    892893    }
    893894
     
    900901     */
    901902    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    }
    907908    } else
    908909        PrintStructures->HelpMessageID = 0;
    909910
    910911    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    }
    934935    }
    935936
     
    939940     */
    940941    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;
    944945    if (lppd->nToPage < lppd->nMinPage)
    945946        lppd->nToPage = lppd->nMinPage;
     
    953954    /* If the printer combo box is in the dialog, fill it */
    954955    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);
    971972    } 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         else
    979             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");
    980981    }
    981982    HeapFree(GetProcessHeap(),0,name);
     
    988989 *                              PRINTDLG_WMCommand               [internal]
    989990 */
    990 static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, 
    991                         LPARAM lParam, PRINT_PTRA* PrintStructures)
     991static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam,
     992            LPARAM lParam, PRINT_PTRA* PrintStructures)
    992993{
    993994    LPPRINTDLGA lppd = PrintStructures->dlg.lpPrintDlg;
     
    9991000        TRACE(" OK button was hit\n");
    10001001        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);
    10061007
    10071008    case IDCANCEL:
    10081009        TRACE(" CANCEL button was hit\n");
    10091010        EndDialog(hDlg, FALSE);
    1010         return(FALSE);
     1011    return(FALSE);
    10111012
    10121013     case pshHelp:
    10131014        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);
    10161017        break;
    10171018
    10181019     case chx2:                         /* collate pages checkbox */
    10191020        if (IsDlgButtonChecked(hDlg, chx2) == BST_CHECKED)
    1020             SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
     1021            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    10211022                                    (LPARAM)PrintStructures->hCollateIcon);
    10221023        else
    1023             SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON, 
     1024            SendDlgItemMessageA(hDlg, ico3, STM_SETIMAGE, (WPARAM) IMAGE_ICON,
    10241025                                    (LPARAM)PrintStructures->hNoCollateIcon);
    1025         break;       
     1026        break;
    10261027     case edt1:                         /* from page nr editbox */
    10271028     case edt2:                         /* to page nr editbox */
    10281029        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);
    10331034            if (nFromPage != lppd->nFromPage || nToPage != lppd->nToPage)
    1034                 CheckRadioButton(hDlg, rad1, rad3, rad3);
    1035         }
     1035            CheckRadioButton(hDlg, rad1, rad3, rad3);
     1036    }
    10361037        break;
    10371038
    10381039    case edt3:
    10391040        if(HIWORD(wParam) == EN_CHANGE) {
    1040             INT copies = GetDlgItemInt(hDlg, edt3, NULL, FALSE);
    1041             if(copies <= 1)
    1042                 EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
    1043             else
    1044                 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;
    10471048
    10481049#ifndef __WIN32OS2__
    10491050     case psh1:                       /* Print Setup */
    1050         {
    1051             PRINTDLG16  pdlg;
    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;
    10651066#endif
    10661067
     
    10721073         GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255);
    10731074         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);
    10821083         break;
    10831084       }
     
    10951096        }
    10961097        break;
    1097            
     1098
    10981099    case rad2: /* Paperorientation */
    10991100        if (lppd->Flags & PD_PRINTSETUP)
     
    11081109        }
    11091110        break;
    1110            
     1111
    11111112    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 */
    11171118    case cmb4:                         /* Printer combobox */
    11181119         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;
    11241125
    11251126    case cmb2: /* Papersize */
    11261127      {
    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)
    11291130#ifdef __WIN32OS2__
    1130               lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
     1131          lpdm->dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
    11311132#else
    1132               lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
     1133          lpdm->u1.s1.dmPaperSize = SendDlgItemMessageA(hDlg, cmb2,
    11331134#endif
    1134                                                             CB_GETITEMDATA,
    1135                                                             Sel, 0);
     1135                                CB_GETITEMDATA,
     1136                                Sel, 0);
    11361137      }
    11371138      break;
     
    11391140    case cmb3: /* Bin */
    11401141      {
    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);
    11461147      }
    1147       break; 
     1148      break;
    11481149    }
    11491150    if(lppd->Flags & PD_PRINTSETUP) {
    11501151        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) {
    11541155#ifdef __WIN32OS2__
    1155                 if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {
    1156                     lpdm->dmOrientation = DMORIENT_PORTRAIT;
     1156            if(lpdm->dmOrientation != DMORIENT_PORTRAIT) {
     1157            lpdm->dmOrientation = DMORIENT_PORTRAIT;
    11571158#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;
    11601161#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 {
    11691170#ifdef __WIN32OS2__
    1170                 if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {
    1171                     lpdm->dmOrientation = DMORIENT_LANDSCAPE;
     1171            if(lpdm->dmOrientation != DMORIENT_LANDSCAPE) {
     1172            lpdm->dmOrientation = DMORIENT_LANDSCAPE;
    11721173#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;
    11751176#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    }
    11861187    }
    11871188    return FALSE;
    1188 }   
     1189}
    11891190
    11901191/***********************************************************************
    1191  *           PrintDlgProcA                      [internal]
     1192 *           PrintDlgProcA          [internal]
    11921193 */
    11931194#ifdef __WIN32OS2__
    11941195LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
    1195                              LPARAM lParam)
     1196                 LPARAM lParam)
    11961197#else
    11971198BOOL WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
    1198                           LPARAM lParam)
     1199              LPARAM lParam)
    11991200#endif
    12001201{
     
    12031204
    12041205    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;
    12081209    } else {
    12091210        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.lpPrintDlg
    1216             );
    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
    12201221    if(PrintStructures->dlg.lpPrintDlg->Flags & PD_ENABLEPRINTHOOK) {
    12211222        res = PrintStructures->dlg.lpPrintDlg->lpfnPrintHook(hDlg,uMsg,wParam,
    1222                                                         lParam);
    1223         if(res) return res;
     1223                            lParam);
     1224    if(res) return res;
    12241225    }
    12251226
     
    12291230
    12301231    case WM_DESTROY:
    1231         DestroyIcon(PrintStructures->hCollateIcon);
    1232         DestroyIcon(PrintStructures->hNoCollateIcon);
     1232    DestroyIcon(PrintStructures->hCollateIcon);
     1233    DestroyIcon(PrintStructures->hNoCollateIcon);
    12331234        DestroyIcon(PrintStructures->hPortraitIcon);
    12341235        DestroyIcon(PrintStructures->hLandscapeIcon);
    1235         if(PrintStructures->hwndUpDown)
    1236             DestroyWindow(PrintStructures->hwndUpDown);
     1236    if(PrintStructures->hwndUpDown)
     1237        DestroyWindow(PrintStructures->hwndUpDown);
    12371238        return FALSE;
    1238     }   
     1239    }
    12391240    return res;
    12401241}
     
    12551256        HGLOBAL16 hGlobal16;
    12561257        LPVOID template;
    1257  
     1258
    12581259        if (!(hResInfo = FindResourceA(COMMDLG_hInstance32,
    12591260               PrintResourceName, RT_DIALOGA)))
     
    13001301
    13011302    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);
    13131309    } 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    }
    13261327    }
    13271328    return hDlgTmpl;
     
    13401341
    13411342    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);
    13511349    } 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    }
    13621363    }
    13631364    return hDlgTmpl;
     
    13771378    if(lppd->Flags & PD_RETURNDC) {
    13781379        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 );
    13821383    } else if(lppd->Flags & PD_RETURNIC) {
    13831384        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 );
    13871388    }
    13881389    GlobalUnlock(lppd->hDevNames);
     
    13991400    if(lppd->Flags & PD_RETURNDC) {
    14001401        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 );
    14041405    } else if(lppd->Flags & PD_RETURNIC) {
    14051406        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 );
    14091410    }
    14101411    GlobalUnlock16(lppd->hDevNames);
     
    14311432 *  * The Paper Orientation Icons are not implemented yet.
    14321433 *  * 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
    14341435 *    default printer settings.
    14351436 */
    14361437BOOL WINAPI PrintDlgA(
    1437                       LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */
    1438                       )
     1438              LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */
     1439              )
    14391440{
    14401441    BOOL      bRet = FALSE;
     
    14481449    if(TRACE_ON(commdlg)) {
    14491450        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);
    14611462    }
    14621463
    14631464    if(lppd->lStructSize != sizeof(PRINTDLGA)) {
    14641465        WARN("structure size failure !!!\n");
    1465         COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
    1466         return FALSE;
     1466    COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
     1467    return FALSE;
    14671468    }
    14681469
    14691470    if(lppd->Flags & PD_RETURNDEFAULT) {
    14701471        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    }
    14801481        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;
    15121513    } 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
    15181519     */
    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    }
    15291530
    15301531        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->pPortName
    1578             );
    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);
    15851586    }
    15861587    if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
    15871588        bRet = PRINTDLG_CreateDC(lppd);
    15881589
    1589     TRACE("exit! (%d)\n", bRet);       
    1590     return bRet;   
     1590    TRACE("exit! (%d)\n", bRet);
     1591    return bRet;
    15911592}
    15921593
     
    15941595/***********************************************************************
    15951596 *           PrintDlg   (COMMDLG.20)
    1596  * 
     1597 *
    15971598 *  Displays the the PRINT dialog box, which enables the user to specify
    15981599 *  specific properties of the print job.
     
    16081609
    16091610BOOL16 WINAPI PrintDlg16(
    1610               LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */
     1611          LPPRINTDLG16 lppd /* [in/out] ptr to PRINTDLG struct */
    16111612) {
    16121613    BOOL      bRet = FALSE;
     
    16161617    if(TRACE_ON(commdlg)) {
    16171618        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);
    16291630    }
    16301631
    16311632    if(lppd->lStructSize != sizeof(PRINTDLG16)) {
    16321633        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;
    16351636    }
    16361637
    16371638    if(lppd->Flags & PD_RETURNDEFAULT) {
    16381639        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    }
    16481649        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;
    16791680    } 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
    16851686     */
    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    }
    16911692        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 */
    17021703#undef MVAL
    17031704#undef CVAL
    17041705
    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)PrintStructures
    1714                 )
    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->pPortName
    1754             );
    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)))
    17581759            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);
    17631764    }
    17641765    if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
    17651766        bRet = PRINTDLG_CreateDC16(lppd);
    17661767
    1767     TRACE("exit! (%d)\n", bRet);       
    1768     return bRet;   
     1768    TRACE("exit! (%d)\n", bRet);
     1769    return bRet;
    17691770}
    17701771#endif
     
    17981799
    17991800typedef struct {
    1800     LPPAGESETUPDLGA     dlga;
    1801 
    1802     PRINTDLGA           pdlg;
     1801    LPPAGESETUPDLGA dlga;
     1802
     1803    PRINTDLGA       pdlg;
    18031804} PageSetupData;
    18041805
     
    18081809
    18091810    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);
    18151816    } 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);
    18181819    }
    18191820    return hDlgTmpl;
     
    18231824_c_10mm2size(PAGESETUPDLGA *dlga,DWORD size) {
    18241825    if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1825         return 10*size*10/25.4;
     1826    return 10*size*10/25.4;
    18261827    /* If we don't have a flag, we can choose one. Use millimeters
    18271828     * to avoid confusing me
     
    18361837_c_inch2size(PAGESETUPDLGA *dlga,DWORD size) {
    18371838    if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1838         return size;
     1839    return size;
    18391840    if (dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
    1840         return (size*254)/10;
     1841    return (size*254)/10;
    18411842    /* if we don't have a flag, we can choose one. Use millimeters
    18421843     * to avoid confusing me
     
    18501851    strcpy(strout,"<undef>");
    18511852    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;
    18541855    }
    18551856    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;
    18581859    }
    18591860    pda->dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
     
    18641865static DWORD
    18651866_c_str2size(PageSetupData *pda,LPCSTR strin) {
    1866     float       val;
    1867     char        rest[200];
     1867    float   val;
     1868    char    rest[200];
    18681869
    18691870    rest[0]='\0';
    18701871    if (!sscanf(strin,"%f%s",&val,rest))
    1871         return 0;
     1872    return 0;
    18721873
    18731874    if (!strcmp(rest,"in") || !strcmp(rest,"inch")) {
    1874         if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
    1875             return 1000*val;
    1876         else
    1877             return val*25.4*100;
     1875    if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES)
     1876        return 1000*val;
     1877    else
     1878        return val*25.4*100;
    18781879    }
    18791880    if (!strcmp(rest,"cm")) { rest[0]='m'; val = val*10.0; }
     
    18811882
    18821883    if (!strcmp(rest,"mm")) {
    1883         if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
    1884             return 100*val;
    1885         else
    1886             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;
    18871888    }
    18881889    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    }
    18981899    }
    18991900    ERR("Did not find a conversion for type '%s'!\n",rest);
     
    19081909static BOOL
    19091910PRINTDLG_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
    19161917    dn = GlobalLock(pda->pdlg.hDevNames);
    19171918    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;
    19201921    PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm);
    19211922    PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm);
    19221923
    19231924    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);
    19271928    } else
    1928         FIXME("could not get dialog text for papersize cmbbox?\n");
     1929    FIXME("could not get dialog text for papersize cmbbox?\n");
    19291930#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); }
    19301931    GETVAL(edt4,pda->dlga->rtMargin.left);
     
    19361937    /* If we are in landscape, swap x and y of page size */
    19371938    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;
    19421943    }
    19431944    GlobalUnlock(pda->pdlg.hDevNames);
     
    19511952static BOOL
    19521953PRINTDLG_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
    19571958    dn = GlobalLock(pda->pdlg.hDevNames);
    19581959    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;
    19611962    PRINTDLG_SetUpPaperComboBox(hDlg,cmb2,devname,portname,dm);
    19621963    PRINTDLG_SetUpPaperComboBox(hDlg,cmb3,devname,portname,dm);
     
    19731974    case IDOK:
    19741975        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 ;
    19781979
    19791980    case IDCANCEL:
    19801981        EndDialog(hDlg, FALSE);
    1981         return FALSE ;
     1982    return FALSE ;
    19821983
    19831984    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;
    19891990    }
    19901991    }
    19911992    FIXME("loword (lparam) %d, wparam 0x%x, lparam %08lx, STUB mostly.\n",
    1992             LOWORD(lParam),wParam,lParam
     1993        LOWORD(lParam),wParam,lParam
    19931994    );
    19941995    return FALSE;
     
    19992000PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    20002001{
    2001     PageSetupData       *pda;
    2002     BOOL                res = FALSE;
     2002    PageSetupData   *pda;
     2003    BOOL        res = FALSE;
    20032004
    20042005    if (uMsg==WM_INITDIALOG) {
    2005         res = TRUE;
     2006    res = TRUE;
    20062007        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)
    20282029            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 */
    20302031            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);
    20622047    } 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    }
    20722073    }
    20732074    switch (uMsg) {
     
    20822083 */
    20832084BOOL 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;
    20892090
    20902091#ifdef __WIN32OS2__
     
    20942095    if(TRACE_ON(commdlg)) {
    20952096        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);
    21082109    }
    21092110
    21102111    /* First get default printer data, we need it right after that. */
    21112112    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;
    21142115    bRet = PrintDlgA(&pdlg);
    21152116    if (!bRet) return FALSE;
     
    21172118    /* short cut exit, just return default values */
    21182119    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;
    21262127    }
    21272128    hDlgTmpl = PRINTDLG_GetPGSTemplate(setupdlg);
    21282129    if (!hDlgTmpl) {
    2129         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    2130         return FALSE;
     2130    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     2131    return FALSE;
    21312132    }
    21322133    ptr = LockResource( hDlgTmpl );
    21332134    if (!ptr) {
    2134         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
    2135         return FALSE;
     2135    COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
     2136    return FALSE;
    21362137    }
    21372138    pda = HeapAlloc(GetProcessHeap(),0,sizeof(*pda));
     
    21402141
    21412142    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)
    21472148    );
    21482149    return bRet;
     
    21552156    dprintf(("PageSetupDlgA %x NOT IMPLEMENTED", setupdlg));
    21562157#endif
    2157         FIXME("(%p), stub!\n",setupdlg);
    2158         return FALSE;
     2158    FIXME("(%p), stub!\n",setupdlg);
     2159    return FALSE;
    21592160}
    21602161
     
    21752176
    21762177    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;
    21802181    } else {
    21812182        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
    21942186    if(PrintStructures->dlg.lpPrintDlg16->Flags & PD_ENABLEPRINTHOOK) {
    21952187        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;
    22002201    }
    22012202
    22022203    switch (uMsg) {
    22032204    case WM_COMMAND: {
    2204         /* We need to map those for the 32bit window procedure, compare
    2205           * with 32Ato16 mapper in winproc.c
    2206           */
     2205    /* We need to map those for the 32bit window procedure, compare
     2206      * with 32Ato16 mapper in winproc.c
     2207      */
    22072208        return PRINTDLG_WMCommand(
    2208                 hDlg,
    2209                 MAKEWPARAM(wParam,HIWORD(lParam)),
    2210                 LOWORD(lParam),
    2211                 PrintStructures
    2212         );
     2209        hDlg,
     2210        MAKEWPARAM(wParam,HIWORD(lParam)),
     2211        LOWORD(lParam),
     2212        PrintStructures
     2213    );
    22132214    }
    22142215    case WM_DESTROY:
    2215         DestroyIcon(PrintStructures->hCollateIcon);
    2216         DestroyIcon(PrintStructures->hNoCollateIcon);
     2216    DestroyIcon(PrintStructures->hCollateIcon);
     2217    DestroyIcon(PrintStructures->hNoCollateIcon);
    22172218    /* FIXME: don't forget to delete the paper orientation icons here! */
    22182219
    22192220        return FALSE;
    2220     }   
     2221    }
    22212222    return res;
    22222223}
     
    22272228 */
    22282229LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
    2229                                    LPARAM lParam)
     2230                   LPARAM lParam)
    22302231{
    22312232  switch (wMsg)
     
    22382239      switch (wParam) {
    22392240      case IDOK:
    2240         EndDialog(hWnd, TRUE);
    2241         return(TRUE);
     2241    EndDialog(hWnd, TRUE);
     2242    return(TRUE);
    22422243      case IDCANCEL:
    2243         EndDialog(hWnd, FALSE);
    2244         return(TRUE);
     2244    EndDialog(hWnd, FALSE);
     2245    return(TRUE);
    22452246      }
    22462247      return(FALSE);
     
    22512252
    22522253/***********************************************************************
    2253  *      PrintDlgExA (COMDLG32.@)
     2254 *  PrintDlgExA (COMDLG32.@)
    22542255 */
    22552256HRESULT WINAPI PrintDlgExA(LPVOID lpPrintDlgExA) /* [???] FIXME: LPPRINTDLGEXA */
    22562257{
    2257         FIXME("stub\n");
    2258         return E_NOTIMPL;
     2258    FIXME("stub\n");
     2259    return E_NOTIMPL;
    22592260}
    22602261/***********************************************************************
    2261  *      PrintDlgExW (COMDLG32.@)
     2262 *  PrintDlgExW (COMDLG32.@)
    22622263 */
    22632264HRESULT WINAPI PrintDlgExW(LPVOID lpPrintDlgExW) /* [???] FIXME: LPPRINTDLGEXW */
    22642265{
    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.