Changeset 9570 for trunk/src


Ignore:
Timestamp:
Dec 30, 2002, 8:04:54 PM (23 years ago)
Author:
sandervl
Message:

AH: Added string check to PRINTDLG_SetUpPrinterListComboA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comdlg32/printdlg.c

    r9364 r9570  
    134134#define MAX_COPIES 9999
    135135
     136
     137#ifdef __WIN32OS2__
     138/***********************************************************************
     139 *   PrnNameToQueue
     140 *
     141 * Odin helper function that gets Queue Name from Printer Name
     142 *
     143 * Returns TRUE on success else FALSE
     144 */
     145
     146BOOL PrnNameToQueue(char* PrnName, char* QueueName)
     147{
     148 BOOL rc = FALSE;
     149
     150  if (PrnName && QueueName)
     151  {
     152    LPPRINTER_INFO_2A pi;
     153    DWORD needed, num;
     154    INT i;
     155
     156    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
     157    pi = HeapAlloc(GetProcessHeap(), 0, needed);
     158    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed,
     159                  &num);
     160
     161    for(i = 0; i < num; i++)
     162       if (!strcmp(pi[i].pComment, PrnName))
     163       {
     164         strcpy(QueueName, pi[i].pPrinterName);
     165         rc = TRUE;
     166       }
     167    HeapFree(GetProcessHeap(), 0, pi);
     168  }
     169  return rc;
     170}
     171#endif
     172
    136173/***********************************************************************
    137174 *    PRINTDLG_GetDefaultPrinterName
     
    218255    INT i;
    219256    LPPRINTER_INFO_2A pi;
     257#ifdef __WIN32OS2__
     258    char substName[260];
     259#endif
     260
    220261    EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
    221262    pi = HeapAlloc(GetProcessHeap(), 0, needed);
     
    223264                  &num);
    224265
     266#ifndef __WIN32OS2__
    225267    for(i = 0; i < num; i++) {
    226268        SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0,
     
    228270    }
    229271    HeapFree(GetProcessHeap(), 0, pi);
     272#else
     273    substName[0] = 0;
     274
     275    for(i = 0; i < num; i++)
     276    {
     277        SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0,
     278                            (LPARAM)pi[i].pComment );
     279        if (!name || !strcmp(pi[i].pPrinterName, name))
     280           strcpy(substName, pi[i].pComment);
     281    }
     282#endif
     283
    230284    if(!name ||
    231285       (i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1,
     286#ifndef __WIN32OS2__
    232287                                (LPARAM)name)) == CB_ERR) {
    233 
     288#else
     289                                (LPARAM)substName)) == CB_ERR) {
     290#endif
    234291        char buf[260];
    235292        FIXME("Can't find '%s' in printer list so trying to find default\n",
     
    237294        if(!PRINTDLG_GetDefaultPrinterNameA(buf, sizeof(buf)))
    238295            return num;
     296#ifndef __WIN32OS2__
    239297        i = SendDlgItemMessageA(hDlg, id, CB_FINDSTRINGEXACT, -1, (LPARAM)buf);
     298#else
     299        for(i = 0; i < num; i++)
     300           if (!strcmp(pi[i].pComment, buf))
     301              break;
     302        HeapFree(GetProcessHeap(), 0, pi);
     303#endif
     304
    240305        if(i == CB_ERR)
    241306            FIXME("Can't find default printer in printer list\n");
     
    10351100        return FALSE;
    10361101    }
     1102#ifndef __WIN32OS2__
    10371103    ClosePrinter(hprn);
     1104#endif
    10381105
    10391106    PRINTDLG_UpdatePrinterInfoTextsA(hDlg, PrintStructures->lpPrinterInfo);
     
    10441111    }
    10451112
     1113#ifdef __WIN32OS2__
     1114    dmSize = DocumentPropertiesA(0, hprn, name, NULL, NULL, 0);
     1115#else
    10461116    dmSize = DocumentPropertiesA(0, 0, name, NULL, NULL, 0);
     1117#endif
    10471118    if(dmSize == -1) {
    10481119        ERR("DocumentProperties fails on %s\n", debugstr_a(name));
     
    10501121    }
    10511122    PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
     1123
     1124#ifdef __WIN32OS2__
     1125    dmSize = DocumentPropertiesA(0, hprn, name, PrintStructures->lpDevMode, NULL,
     1126#else
    10521127    dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL,
     1128#endif
    10531129                                 DM_OUT_BUFFER);
     1130
    10541131    if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
    10551132                          !strcmp(lpdm->dmDeviceName,
    10561133                                  PrintStructures->lpDevMode->dmDeviceName)) {
    10571134      /* Supplied devicemode matches current printer so try to use it */
     1135#ifdef __WIN32OS2__
     1136        DocumentPropertiesA(0, hprn, name, PrintStructures->lpDevMode, lpdm,
     1137#else
    10581138        DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm,
     1139#endif
    10591140                            DM_OUT_BUFFER | DM_IN_BUFFER);
    10601141    }
     1142#ifdef __WIN32OS2__
     1143    ClosePrinter(hprn);
     1144#endif
    10611145    if(lpdm)
    10621146        GlobalUnlock(lppd->hDevMode);
     
    14231507        name = HeapAlloc(GetProcessHeap(),0,256);
    14241508        if (GetDlgItemTextA(hDlg, comboID, name, 255))
     1509#ifdef __WIN32OS2__
     1510            PrnNameToQueue(name, name);
     1511#endif
    14251512            PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
    14261513        HeapFree(GetProcessHeap(),0,name);
     
    14291516        char name[200];
    14301517        BOOL ret = PRINTDLG_GetDefaultPrinterNameA(name, sizeof(name));
    1431 
     1518#ifdef __WIN32OS2__
     1519        PrnNameToQueue(name, name);
     1520#endif
    14321521        if (ret)
    14331522            PRINTDLG_ChangePrinterA(hDlg, name, PrintStructures);
     
    17451834
    17461835         GetDlgItemTextA(hDlg, PrinterComboID, PrinterName, 255);
     1836#ifdef __WIN32OS2__
     1837         PrnNameToQueue(PrinterName, PrinterName);
     1838#endif
    17471839         if (!OpenPrinterA(PrinterName, &hPrinter, NULL)) {
    17481840             FIXME(" Call to OpenPrinter did not succeed!\n");
     
    17851877             char   PrinterName[256];
    17861878             GetDlgItemTextA(hDlg, LOWORD(wParam), PrinterName, 255);
     1879#ifdef __WIN32OS2__
     1880             PrnNameToQueue(PrinterName, PrinterName);
     1881#endif
    17871882             PRINTDLG_ChangePrinterA(hDlg, PrinterName, PrintStructures);
    17881883         }
     
    35813676        return E_NOTIMPL;
    35823677}
     3678
Note: See TracChangeset for help on using the changeset viewer.