Annotation of ntddk/src/print/pscrptui/document.c, revision 1.1

1.1     ! root        1: //--------------------------------------------------------------------------
        !             2: //
        !             3: // Module Name:  DOCUMENT.C
        !             4: //
        !             5: // Brief Description:  This module contains the PSCRIPT driver's User
        !             6: // Document Property functions and related routines.
        !             7: //
        !             8: // Author:  Kent Settle (kentse)
        !             9: // Created: 13-Apr-1992
        !            10: //
        !            11: // Copyright (c) 1992 Microsoft Corporation
        !            12: //--------------------------------------------------------------------------
        !            13: 
        !            14: #include <stddef.h>
        !            15: #include <stdlib.h>
        !            16: #include <string.h>
        !            17: #include "pscript.h"
        !            18: #include "enable.h"
        !            19: #include <winspool.h>
        !            20: #include "dlgdefs.h"
        !            21: #include "pscrptui.h"
        !            22: #include "help.h"
        !            23: 
        !            24: #define DEFAULT_DOCUMENT_DIALOG 0
        !            25: #define DOES_DUPLEX             1
        !            26: #define DOES_COLLATE            2
        !            27: 
        !            28: #define MAX_FORM_NAME   32
        !            29: 
        !            30: // declarations of routines defined within this module.
        !            31: 
        !            32: LONG DocPropDialogProc(HWND, UINT, DWORD, LONG);
        !            33: LONG AdvDocPropDialogProc(HWND, UINT, DWORD, LONG);
        !            34: BOOL InitializeDocPropDialog(HWND, PDOCDETAILS);
        !            35: BOOL InitializeAdvDocPropDialog(HWND, PDOCDETAILS);
        !            36: BOOL AdjustDevmode(PDOCDETAILS);
        !            37: VOID SetOrientation(HWND, PDOCDETAILS);
        !            38: VOID SetDuplex(HWND, PDOCDETAILS);
        !            39: VOID SetCollation(HWND, PDOCDETAILS);
        !            40: 
        !            41: extern VOID vDoColorAdjUI(LPSTR, COLORADJUSTMENT *, BOOL, BOOL);
        !            42: 
        !            43: BYTE    DP_AnsiDeviceName[128];
        !            44: 
        !            45: extern LONG  AboutDlgProc( HWND, UINT, DWORD, LONG );
        !            46: extern BOOL SetDefaultPSDEVMODE(PSDEVMODE *, PWSTR, PNTPD, HANDLE);
        !            47: extern BOOL ValidateSetDEVMODE(PSDEVMODE *, PSDEVMODE *, HANDLE, PNTPD);
        !            48: extern VOID SetFormSize(HANDLE, PSDEVMODE *, PWSTR);
        !            49: extern PFORM_INFO_1 GetFormsDataBase(HANDLE, DWORD *, PNTPD);
        !            50: extern BOOL bAbout(HWND, PNTPD);
        !            51: 
        !            52: //--------------------------------------------------------------------------
        !            53: // LONG DrvDocumentProperties(hWnd, hPrinter, pDeviceName, pDevModeOutput,
        !            54: //                            pDevModeInput, fMode)
        !            55: // HWND        hWnd;
        !            56: // HANDLE      hPrinter;
        !            57: // PSTR        pDeviceName;
        !            58: // PDEVMODE    pDevModeOutput;
        !            59: // PDEVMODE    pDevModeInput;
        !            60: // DWORD       fMode;
        !            61: //
        !            62: // This routine is called to set the public portions of the DEVMODE
        !            63: // structure for the given print document.
        !            64: //
        !            65: // History:
        !            66: //   13-Apr-1992    -by-    Kent Settle     (kentse)
        !            67: //  Re-Wrote it.
        !            68: //   27-Mar-1992    -by-    Dave Snipp      (davesn)
        !            69: //  Wrote it.
        !            70: //--------------------------------------------------------------------------
        !            71: 
        !            72: LONG DrvDocumentProperties(hWnd, hPrinter, pDeviceName, pDevModeOutput,
        !            73:                            pDevModeInput, fMode)
        !            74: HWND        hWnd;
        !            75: HANDLE      hPrinter;
        !            76: PWSTR       pDeviceName;
        !            77: PDEVMODE    pDevModeOutput;
        !            78: PDEVMODE    pDevModeInput;
        !            79: DWORD       fMode;
        !            80: {
        !            81:     LPWSTR          pwRealDeviceName;
        !            82:     LONG            ReturnValue;
        !            83:     DOCDETAILS      DocDetails;
        !            84:     PSDEVMODE      *pDMInput;
        !            85:     int             iDialog;
        !            86: 
        !            87: 
        !            88:     // if the user passed in fMode == 0, return the size of the
        !            89:     // total DEVMODE structure.
        !            90: 
        !            91:     if (!fMode)
        !            92:         return(sizeof(PSDEVMODE));
        !            93: 
        !            94: #if 0
        !            95: //!!! in order not to break WOW just yet, we won't check this, but
        !            96: //!!! we will at some point.  -kentse.
        !            97: 
        !            98:     // it would be wrong to call this function with fMode != 0 and not
        !            99:     // have the DM_COPY bit set.
        !           100: 
        !           101:     if (!(fMode & DM_COPY))
        !           102:     {
        !           103:         RIP("PSCRPTUI!DocumentProperties: fMode not NULL and no DM_COPY.\n");
        !           104:         SetLastError(ERROR_INVALID_PARAMETER);
        !           105:         return(-1L);
        !           106:     }
        !           107: #endif
        !           108: 
        !           109:     // if the copy bit is set, then there had better be a pointer
        !           110:     // to an output buffer.
        !           111: 
        !           112:     if ((!pDevModeOutput) && (fMode & DM_COPY))
        !           113:     {
        !           114:         RIP("PSCRPTUI!DocumentProperties: NULL pDevModeOutput and DM_COPY.\n");
        !           115:         SetLastError(ERROR_INVALID_PARAMETER);
        !           116:         return(-1L);
        !           117:     }
        !           118: 
        !           119:     // initialize the document details structure.
        !           120: 
        !           121:     memset (&DocDetails, 0, sizeof(DOCDETAILS));
        !           122: 
        !           123:     // make a working copy of the input PSDEVMODE structure, if we
        !           124:     // have been supplied one.
        !           125: 
        !           126:     if (pDevModeInput)
        !           127:     {
        !           128:         DWORD   cb;
        !           129: 
        !           130:         cb = pDevModeInput->dmSize + pDevModeInput->dmDriverExtra;
        !           131:         cb = min(sizeof(PSDEVMODE), cb);
        !           132: 
        !           133:         CopyMemory(&DocDetails.DMBuffer, pDevModeInput, cb);
        !           134: 
        !           135:         pDMInput = &DocDetails.DMBuffer;
        !           136:     }
        !           137:     else
        !           138:         pDMInput = NULL;
        !           139: 
        !           140:     // fill in document details.
        !           141: 
        !           142:     DocDetails.hPrinter = hPrinter;
        !           143:     DocDetails.pDeviceName = pDeviceName;
        !           144:     DocDetails.pDMOutput = (PSDEVMODE *)pDevModeOutput;
        !           145:     DocDetails.pDMInput = (PSDEVMODE *)pDMInput;
        !           146:     DocDetails.flDialogFlags = DEFAULT_DOCUMENT_DIALOG;
        !           147: 
        !           148:     // get a pointer to our NTPD structure for printer information.
        !           149: 
        !           150:     if (!(DocDetails.pntpd = MapPrinter(DocDetails.hPrinter)))
        !           151:     {
        !           152:         RIP("PSCRPTUI!DocumentProperties: MapPrinter failed.\n");
        !           153:         return(-1L);
        !           154:     }
        !           155: 
        !           156:     // prompt the user with a dialog box, if that flag is set, otherwise
        !           157:     // make sure we have a useful DEVMODE and return that things are fine.
        !           158: 
        !           159:     if (fMode & DM_PROMPT)
        !           160:     {
        !           161:         //
        !           162:         // Make up ANSI version of the device name for later halftone
        !           163:         // UI to use
        !           164:         //
        !           165: 
        !           166:         pwRealDeviceName = (PWSTR)((PSTR)DocDetails.pntpd +
        !           167:                                    DocDetails.pntpd->lowszPrinterName);
        !           168: 
        !           169:         WideCharToMultiByte(CP_ACP,
        !           170:                             0,
        !           171:                             (LPWSTR)pwRealDeviceName,
        !           172:                             (int)(wcslen(pwRealDeviceName) + 1),
        !           173:                             DP_AnsiDeviceName,
        !           174:                             sizeof(DP_AnsiDeviceName),
        !           175:                             NULL,
        !           176:                             NULL);
        !           177: 
        !           178: 
        !           179:         // set some option flags, depending on which functions the
        !           180:         // current printer supports.  these options will be used to
        !           181:         // determine which dialog box to present to the user.
        !           182: 
        !           183:         if ((DocDetails.pntpd->loszDuplexNone) ||
        !           184:             (DocDetails.pntpd->loszDuplexNoTumble) ||
        !           185:             (DocDetails.pntpd->loszDuplexTumble))
        !           186:             DocDetails.flDialogFlags |= DOES_DUPLEX;
        !           187: 
        !           188:         if (DocDetails.pntpd->loszCollateOn)
        !           189:             DocDetails.flDialogFlags |= DOES_COLLATE;
        !           190: 
        !           191:         switch(DocDetails.flDialogFlags)
        !           192:         {
        !           193:             case DEFAULT_DOCUMENT_DIALOG:
        !           194:                 iDialog = DOCPROPDIALOG;
        !           195: 
        !           196:                 break;
        !           197: 
        !           198:             case DOES_DUPLEX:
        !           199:                 iDialog = DOCDUPDIALOG;
        !           200: 
        !           201:                 break;
        !           202: 
        !           203:             case DOES_COLLATE:
        !           204:                 iDialog = DOCCOLLDIALOG;
        !           205: 
        !           206:                 break;
        !           207: 
        !           208:             case (DOES_DUPLEX | DOES_COLLATE):
        !           209:                 iDialog = DOCBOTHDIALOG;
        !           210: 
        !           211:                 break;
        !           212:         }
        !           213: 
        !           214:         // present the user with the document properties dialog
        !           215:         // box, which may or may not support duplex or collate.
        !           216: 
        !           217:         ReturnValue = DialogBoxParam(hModule,
        !           218:                                      MAKEINTRESOURCE(iDialog),
        !           219:                                      hWnd, (DLGPROC)DocPropDialogProc,
        !           220:                                      (LPARAM)&DocDetails);
        !           221:     }
        !           222:     else
        !           223:     {
        !           224:         // make sure we have a useful PSDEVMODE structure to work with.
        !           225: 
        !           226:         if (!AdjustDevmode(&DocDetails))
        !           227:         {
        !           228:             RIP("PSCRPTUI!DocumentDetails: AdjustDevmode failed.\n");
        !           229:             return(-1L);
        !           230:         }
        !           231: 
        !           232:         ReturnValue = IDOK;
        !           233:     }
        !           234: 
        !           235:     if ((ReturnValue == IDOK) && (fMode & DM_COPY))
        !           236: 
        !           237:         // copy our newly developed PSDEVMODE structure
        !           238:         // into the provided buffer.
        !           239: 
        !           240:         *DocDetails.pDMOutput = *DocDetails.pDMInput;
        !           241: 
        !           242:     // free up the NTPD memory.
        !           243: 
        !           244:     if (DocDetails.pntpd)
        !           245:         GlobalFree((HGLOBAL)DocDetails.pntpd);
        !           246: 
        !           247:     return ReturnValue;
        !           248: }
        !           249: 
        !           250: 
        !           251: //--------------------------------------------------------------------------
        !           252: // BOOL InitializeDocPropDialog(hWnd, pDocDetails)
        !           253: // HWND                hWnd;
        !           254: // PDOCDETAILS         pDocDetails;
        !           255: //
        !           256: // This routine does what it's name suggests.
        !           257: //
        !           258: // History:
        !           259: //   14-Apr-1992    -by-    Kent Settle     (kentse)
        !           260: //  Re-Wrote form enumeration stuff.
        !           261: //   27-Mar-1992    -by-    Dave Snipp      (davesn)
        !           262: //  Wrote it.
        !           263: //--------------------------------------------------------------------------
        !           264: 
        !           265: BOOL InitializeDocPropDialog(hWnd, pDocDetails)
        !           266: HWND                hWnd;
        !           267: PDOCDETAILS         pDocDetails;
        !           268: {
        !           269:     FORM_INFO_1    *pdbForm, *pdbForms;
        !           270:     DWORD           count;
        !           271:     DWORD           i, iForm;
        !           272:     PNTPD           pntpd;
        !           273:     PWSTR           pwstrFormName;
        !           274:     BOOL            bTmp;
        !           275: 
        !           276:     // default to proper orientation, duplex and collation.
        !           277: 
        !           278:     bTmp = (pDocDetails->pDMInput->dm.dmOrientation == DMORIENT_LANDSCAPE);
        !           279: 
        !           280:     CheckRadioButton(hWnd, IDD_DEVICEMODEPORTRAIT, IDD_DEVICEMODELANDSCAPE,
        !           281:                      bTmp ? IDD_DEVICEMODELANDSCAPE : IDD_DEVICEMODEPORTRAIT);
        !           282: 
        !           283:     SetOrientation(hWnd, pDocDetails);
        !           284: 
        !           285:     if (pDocDetails->flDialogFlags & DOES_DUPLEX)
        !           286:     {
        !           287:         switch (pDocDetails->pDMInput->dm.dmDuplex)
        !           288:         {
        !           289:             case DMDUP_VERTICAL:
        !           290:                 i = IDD_DUPLEX_LONG;
        !           291:                 break;
        !           292: 
        !           293:             case DMDUP_HORIZONTAL:
        !           294:                 i = IDD_DUPLEX_SHORT;
        !           295:                 break;
        !           296: 
        !           297:             default:
        !           298:                 i = IDD_DUPLEX_NONE;
        !           299:                 break;
        !           300:         }
        !           301: 
        !           302:         // now set the appropriate radio button.
        !           303: 
        !           304:         CheckRadioButton(hWnd, IDD_DUPLEX_NONE, IDD_DUPLEX_SHORT, i);
        !           305: 
        !           306:         SetDuplex(hWnd, pDocDetails);
        !           307:     }
        !           308: 
        !           309:     if (pDocDetails->flDialogFlags & DOES_COLLATE)
        !           310:     {
        !           311:         bTmp = pDocDetails->pDMInput->dm.dmCollate;
        !           312: 
        !           313:         CheckRadioButton(hWnd, IDD_COLLATE_OFF, IDD_COLLATE_ON,
        !           314:                          bTmp ? IDD_COLLATE_ON : IDD_COLLATE_OFF);
        !           315: 
        !           316:         SetCollation(hWnd, pDocDetails);
        !           317:     }
        !           318: 
        !           319:     // fill in the given number of copies.
        !           320: 
        !           321:     SetDlgItemInt(hWnd, IDD_DEVICEMODENOCOPIES,
        !           322:                   (int)pDocDetails->pDMInput->dm.dmCopies, FALSE);
        !           323: 
        !           324:     // get a local pointer to NTPD structure.
        !           325: 
        !           326:     pntpd = pDocDetails->pntpd;
        !           327: 
        !           328:     // fill in the forms list box.
        !           329: 
        !           330:     if (!(pdbForms = GetFormsDataBase(pDocDetails->hPrinter, &count, pntpd)))
        !           331:     {
        !           332:         RIP("PSCRPTUI!InitializeDocPropDialog: GetFormsDataBase failed.\n");
        !           333:         return(FALSE);
        !           334:     }
        !           335:     else
        !           336:     {
        !           337:         // enumerate each form name.  check to see if it is
        !           338:         // valid for the current printer.  if it is, insert
        !           339:         // the form name into the forms combo box.
        !           340: 
        !           341:         pdbForm = pdbForms;
        !           342: 
        !           343:         for (i = 0; i < count; i++)
        !           344:         {
        !           345:             if (pdbForm->Flags & PSCRIPT_VALID_FORM)
        !           346:             {
        !           347:                 // add the form to the list box.
        !           348: 
        !           349:                 SendDlgItemMessage(hWnd, IDD_FORMCOMBO, CB_ADDSTRING,
        !           350:                                    (WPARAM)0, (LPARAM)pdbForm->pName);
        !           351:             }
        !           352: 
        !           353:             pdbForm++;
        !           354:         }
        !           355: 
        !           356:         SendDlgItemMessage(hWnd, IDD_FORMCOMBO, CB_SETCURSEL, 0, 0L);
        !           357:     }
        !           358: 
        !           359:     GlobalFree((HGLOBAL)pdbForms);
        !           360: 
        !           361:     // select the form specified in the DEVMODE in the combo box.
        !           362: 
        !           363:     pwstrFormName = pDocDetails->pDMInput->dm.dmFormName;
        !           364: 
        !           365:     iForm = SendDlgItemMessage(hWnd, IDD_FORMCOMBO, CB_FINDSTRING,
        !           366:                                (WPARAM)-1, (LPARAM)pwstrFormName);
        !           367: 
        !           368:     // if the specified form could not be found in the list box, simply
        !           369:     // select the first one.
        !           370: 
        !           371:     if (iForm == CB_ERR)
        !           372:         iForm = 0;
        !           373: 
        !           374:     SendDlgItemMessage(hWnd, IDD_FORMCOMBO, CB_SETCURSEL, (WPARAM)iForm,
        !           375:                        (LPARAM)0);
        !           376: 
        !           377:     return(TRUE);
        !           378: }
        !           379: 
        !           380: 
        !           381: //--------------------------------------------------------------------------
        !           382: // LONG DocPropDialogProc(hWnd, usMst, wParam, lParam)
        !           383: // HWND    hWnd;
        !           384: // UINT    usMsg;
        !           385: // DWORD   wParam;
        !           386: // LONG    lParam;
        !           387: //
        !           388: // This routine services the Document Properties dialog box.
        !           389: //
        !           390: // History:
        !           391: //   15-Apr-1992    -by-    Kent Settle     (kentse)
        !           392: //  Added NTPD stuff, IDD_OPTIONS, IDD_FORMCOMBO.
        !           393: //   27-Mar-1992    -by-    Dave Snipp      (davesn)
        !           394: //  Wrote it.
        !           395: //--------------------------------------------------------------------------
        !           396: 
        !           397: LONG DocPropDialogProc(hWnd, usMsg, wParam, lParam)
        !           398: HWND    hWnd;
        !           399: UINT    usMsg;
        !           400: DWORD   wParam;
        !           401: LONG    lParam;
        !           402: {
        !           403:     PDOCDETAILS     pDocDetails;
        !           404:     BOOL            bTmp;
        !           405:     DWORD           dwDialog;
        !           406: 
        !           407:     switch(usMsg)
        !           408:     {
        !           409:         case WM_INITDIALOG:
        !           410:             pDocDetails = (PDOCDETAILS)lParam;
        !           411: 
        !           412:             if (!pDocDetails)
        !           413:             {
        !           414:                 RIP("PSCRPTUI!DocPropDialogProc: null pDocDetails.\n");
        !           415:                 return(FALSE);
        !           416:             }
        !           417: 
        !           418:             // make sure we have a useful PSDEVMODE structure to work with.
        !           419: 
        !           420:             if (!AdjustDevmode(pDocDetails))
        !           421:             {
        !           422:                 RIP("PSCRPTUI!DocPropDialogProc: AdjustDevmode failed.\n");
        !           423:                 return(FALSE);
        !           424:             }
        !           425: 
        !           426:             // save the pointer to the possibly adjusted DOCDETAILS structure.
        !           427: 
        !           428:             SetWindowLong(hWnd, GWL_USERDATA, lParam);
        !           429: 
        !           430:             InitializeDocPropDialog(hWnd, pDocDetails);
        !           431: 
        !           432:             // intialize the help stuff.
        !           433: 
        !           434:             vHelpInit();
        !           435: 
        !           436:             pDocDetails->coloradj = pDocDetails->pDMInput->coloradj;
        !           437: 
        !           438:             return TRUE;
        !           439: 
        !           440:         case WM_COMMAND:
        !           441:             pDocDetails = (PDOCDETAILS)GetWindowLong(hWnd, GWL_USERDATA);
        !           442: 
        !           443:             switch(LOWORD(wParam))
        !           444:             {
        !           445:                 case IDD_HELP_BUTTON:
        !           446:                     dwDialog = HLP_DOC_PROP_STANDARD;
        !           447: 
        !           448:                     switch(pDocDetails->flDialogFlags)
        !           449:                     {
        !           450:                         case DEFAULT_DOCUMENT_DIALOG:
        !           451:                             break;
        !           452: 
        !           453:                         case DOES_DUPLEX:
        !           454:                             dwDialog = HLP_DOC_PROP_DUPLEX;
        !           455:                             break;
        !           456: 
        !           457:                         case DOES_COLLATE:
        !           458:                             dwDialog = HLP_DOC_PROP_COLLATE;
        !           459:                             break;
        !           460: 
        !           461:                         case (DOES_DUPLEX | DOES_COLLATE):
        !           462:                             dwDialog = HLP_DOC_PROP_BOTH;
        !           463:                             break;
        !           464:                     }
        !           465: 
        !           466:                     vShowHelp(hWnd, HELP_CONTEXT, dwDialog,
        !           467:                               pDocDetails->hPrinter);
        !           468:                     return(TRUE);
        !           469: 
        !           470:                 case IDOK:
        !           471:                     // copy the number of copies into PSDEVMODE.
        !           472: 
        !           473:                     pDocDetails->pDMInput->dm.dmCopies =
        !           474:                             (short)GetDlgItemInt(hWnd, IDD_DEVICEMODENOCOPIES,
        !           475:                                                  &bTmp, FALSE);
        !           476: 
        !           477:                     GetDlgItemText(hWnd, IDD_FORMCOMBO,
        !           478:                                    pDocDetails->pDMInput->dm.dmFormName,
        !           479:                                    sizeof(pDocDetails->pDMInput->dm.dmFormName));
        !           480: 
        !           481:                     // update paper size information in DEVMODE based on the
        !           482:                     // form name.
        !           483: 
        !           484:                     SetFormSize(pDocDetails->hPrinter, pDocDetails->pDMInput,
        !           485:                                 pDocDetails->pDMInput->dm.dmFormName);
        !           486: 
        !           487:                     // Update color adjustment
        !           488: 
        !           489:                     pDocDetails->pDMInput->coloradj = pDocDetails->coloradj;
        !           490: 
        !           491:                     EndDialog (hWnd, IDOK);
        !           492:                     return TRUE;
        !           493: 
        !           494:                 case IDCANCEL:
        !           495:                     EndDialog (hWnd, IDCANCEL);
        !           496:                     return TRUE;
        !           497: 
        !           498:                 case IDD_DEVICEMODEPORTRAIT:
        !           499:                     pDocDetails->pDMInput->dm.dmOrientation = DMORIENT_PORTRAIT;
        !           500:                     SetOrientation(hWnd, pDocDetails);
        !           501:                     SetDuplex(hWnd, pDocDetails);
        !           502:                     break;
        !           503: 
        !           504:                 case IDD_DEVICEMODELANDSCAPE:
        !           505:                     pDocDetails->pDMInput->dm.dmOrientation = DMORIENT_LANDSCAPE;
        !           506:                     SetOrientation(hWnd, pDocDetails);
        !           507:                     SetDuplex(hWnd, pDocDetails);
        !           508:                     break;
        !           509: 
        !           510:                 case IDD_DUPLEX_NONE:
        !           511:                     pDocDetails->pDMInput->dm.dmDuplex = DMDUP_SIMPLEX;
        !           512:                     SetDuplex(hWnd, pDocDetails);
        !           513:                     break;
        !           514: 
        !           515:                 case IDD_DUPLEX_LONG:
        !           516:                     pDocDetails->pDMInput->dm.dmDuplex = DMDUP_VERTICAL;
        !           517:                     SetDuplex(hWnd, pDocDetails);
        !           518:                     break;
        !           519: 
        !           520:                 case IDD_DUPLEX_SHORT:
        !           521:                     pDocDetails->pDMInput->dm.dmDuplex = DMDUP_HORIZONTAL;
        !           522:                     SetDuplex(hWnd, pDocDetails);
        !           523:                     break;
        !           524: 
        !           525:                 case IDD_COLLATE_ON:
        !           526:                     pDocDetails->pDMInput->dm.dmCollate = DMCOLLATE_TRUE;
        !           527:                     SetCollation(hWnd, pDocDetails);
        !           528:                     break;
        !           529: 
        !           530:                 case IDD_COLLATE_OFF:
        !           531:                     pDocDetails->pDMInput->dm.dmCollate = DMCOLLATE_FALSE;
        !           532:                     SetCollation(hWnd, pDocDetails);
        !           533:                     break;
        !           534: 
        !           535:                 case IDD_OPTIONS: // Advanced dialog stuff.
        !           536:                     DialogBoxParam(hModule, MAKEINTRESOURCE(ADVDOCPROPDIALOG),
        !           537:                                    hWnd, (DLGPROC)AdvDocPropDialogProc,
        !           538:                                    (LPARAM)pDocDetails);
        !           539: 
        !           540:                     SetFocus(GetDlgItem(hWnd, IDOK));
        !           541:                     return TRUE;
        !           542: 
        !           543:                 case IDD_HALFTONE_PUSH_BUTTON:
        !           544: 
        !           545:                     vDoColorAdjUI(DP_AnsiDeviceName, &pDocDetails->coloradj,
        !           546:                                   (BOOL)((pDocDetails->pntpd->flFlags &
        !           547:                                                             COLOR_DEVICE) &&
        !           548:                                          (pDocDetails->pDMInput->dm.dmColor ==
        !           549:                                                             DMCOLOR_COLOR)),
        !           550:                                                             TRUE);
        !           551: 
        !           552:                     return(TRUE);
        !           553: 
        !           554:                 case IDD_ABOUT:
        !           555:                     return(bAbout(hWnd, pDocDetails->pntpd));
        !           556: 
        !           557:                 default:
        !           558:                     return (FALSE);
        !           559:             }
        !           560: 
        !           561:             break;
        !           562: 
        !           563:         case WM_DESTROY:
        !           564:             // clean up any used help stuff.
        !           565: 
        !           566:             vHelpDone(hWnd);
        !           567:             return(TRUE);
        !           568: 
        !           569:         default:
        !           570:             return (FALSE);
        !           571:     }
        !           572: 
        !           573:     return  FALSE;
        !           574: }
        !           575: 
        !           576: 
        !           577: //--------------------------------------------------------------------------
        !           578: // LONG DrvAdvancedDocumentProperties(hWnd, hPrinter, pDeviceName, pDevModeOutput,
        !           579: //                                 pDevModeInput)
        !           580: // HWND        hWnd;
        !           581: // HANDLE      hPrinter;
        !           582: // LPSTR       pDeviceName;
        !           583: // PDEVMODE    pDevModeOutput;
        !           584: // PDEVMODE    pDevModeInput;
        !           585: //
        !           586: // This routine is called to set the public portions of the DEVMODE
        !           587: // structure for the given print document.
        !           588: //
        !           589: // History:
        !           590: //   15-Apr-1992    -by-    Kent Settle     (kentse)
        !           591: //  Added DocDetails.
        !           592: //   27-Mar-1992    -by-    Dave Snipp      (davesn)
        !           593: //  Wrote it.
        !           594: //--------------------------------------------------------------------------
        !           595: 
        !           596: LONG DrvAdvancedDocumentProperties(hWnd, hPrinter, pDeviceName, pDevModeOutput,
        !           597:                                    pDevModeInput)
        !           598: HWND        hWnd;
        !           599: HANDLE      hPrinter;
        !           600: PWSTR       pDeviceName;
        !           601: PDEVMODE    pDevModeOutput;
        !           602: PDEVMODE    pDevModeInput;
        !           603: {
        !           604:     LONG        ReturnValue;
        !           605:     DOCDETAILS  DocDetails;
        !           606:     PSDEVMODE  *pDMInput;
        !           607: 
        !           608:     // make a working copy of the input PSDEVMODE structure, if we
        !           609:     // have been supplied one.
        !           610: 
        !           611:     if (pDevModeInput)
        !           612:     {
        !           613:         DocDetails.DMBuffer = *(PSDEVMODE *)pDevModeInput;
        !           614:         pDMInput = &DocDetails.DMBuffer;
        !           615:     }
        !           616:     else
        !           617:         pDMInput = NULL;
        !           618: 
        !           619:     // Fill in the DOCDETAILS structure so that lower level functions
        !           620:     // can access this important data.
        !           621: 
        !           622:     DocDetails.hPrinter = hPrinter;
        !           623:     DocDetails.pDeviceName = pDeviceName;
        !           624:     DocDetails.pDMOutput = (PSDEVMODE *)pDevModeOutput;
        !           625:     DocDetails.pDMInput = (PSDEVMODE *)pDMInput;
        !           626: 
        !           627:     // get a pointer to our NTPD structure for printer information.
        !           628: 
        !           629:     if (!(DocDetails.pntpd = MapPrinter(DocDetails.hPrinter)))
        !           630:     {
        !           631:         RIP("PSCRPTUI!DocumentProperties: MapPrinter failed.\n");
        !           632:         return(-1L);
        !           633:     }
        !           634: 
        !           635:     ReturnValue = DialogBoxParam(hModule,
        !           636:                              MAKEINTRESOURCE(ADVDOCPROPDIALOG),
        !           637:                              hWnd,
        !           638:                              (DLGPROC)AdvDocPropDialogProc,
        !           639:                              (LPARAM)&DocDetails);
        !           640: 
        !           641:     // free up the NTPD memory.
        !           642: 
        !           643:     if (DocDetails.pntpd)
        !           644:         GlobalFree((HGLOBAL)DocDetails.pntpd);
        !           645: 
        !           646:     return ReturnValue;
        !           647: }
        !           648: 
        !           649: 
        !           650: //--------------------------------------------------------------------------
        !           651: // LONG AdvDocPropDialogProc(hWnd, usMsg, wParam, lParam)
        !           652: // HWND    hWnd;
        !           653: // UINT    usMsg;
        !           654: // DWORD   wParam;
        !           655: // LONG    lParam;
        !           656: //
        !           657: // This routine services the Advanced Document Properties dialog box.
        !           658: //
        !           659: // History:
        !           660: //   15-Apr-1992    -by-    Kent Settle     (kentse)
        !           661: //  Re-Wrote it.
        !           662: //   27-Mar-1992    -by-    Dave Snipp      (davesn)
        !           663: //  Wrote it.
        !           664: //--------------------------------------------------------------------------
        !           665: 
        !           666: LONG AdvDocPropDialogProc(hWnd, usMsg, wParam, lParam)
        !           667: HWND    hWnd;
        !           668: UINT    usMsg;
        !           669: DWORD   wParam;
        !           670: LONG    lParam;
        !           671: {
        !           672:     PDOCDETAILS     pDocDetails;
        !           673:     WCHAR           wcbuf[8];
        !           674:     CHAR            cbuf[8];
        !           675:     PWSTR           pwstr;
        !           676:     PSTR            pstr;
        !           677:     LONG            i;
        !           678:     BOOL            bTmp;
        !           679: 
        !           680:     switch(usMsg)
        !           681:     {
        !           682:         case WM_INITDIALOG:
        !           683:             // get a local pointer to our DOCDETAILS structure.
        !           684: 
        !           685:             pDocDetails = (PDOCDETAILS)lParam;
        !           686: 
        !           687:             // make sure we have a useful PSDEVMODE structure to work with.
        !           688: 
        !           689:             if (!AdjustDevmode(pDocDetails))
        !           690:             {
        !           691:                 RIP("PSCRPTUI!AdvDocPropDialogProc: AdjustDevmode failed.\n");
        !           692:                 return(FALSE);
        !           693:             }
        !           694: 
        !           695:             // save a copy of the DEVMODE in case we cancel out of this.
        !           696: 
        !           697:             CopyMemory(&pDocDetails->DMOriginal, &pDocDetails->DMBuffer,
        !           698:                        sizeof(PSDEVMODE));
        !           699: 
        !           700:             // save away the pointer to possibly adjusted DOCDETAILS structure.
        !           701: 
        !           702:             SetWindowLong(hWnd, GWL_USERDATA, (LONG)pDocDetails);
        !           703: 
        !           704:             if (!InitializeAdvDocPropDialog(hWnd, pDocDetails))
        !           705:             {
        !           706:                 RIP("PSCRPTUI!AdvDocPropDialogProc: InitializeAdvDocPropDialog failed.\n");
        !           707:                 return(FALSE);
        !           708:             }
        !           709: 
        !           710:             // intialize the help stuff.
        !           711: 
        !           712:             vHelpInit();
        !           713: 
        !           714:             return (TRUE);
        !           715: 
        !           716:         case WM_COMMAND:
        !           717:             // get the DOCDETAILS structure we save at initialization.
        !           718: 
        !           719:             pDocDetails = (PDOCDETAILS)GetWindowLong(hWnd, GWL_USERDATA);
        !           720: 
        !           721:             switch(LOWORD(wParam))
        !           722:             {
        !           723:                 case IDOK:
        !           724:                     // if the output is going to EPS file, get the
        !           725:                     // EPS file name from the edit box, and copy
        !           726:                     // it to our PSDEVMODE structure.
        !           727: 
        !           728:                     if (pDocDetails->pDMInput->dwFlags & PSDEVMODE_EPS)
        !           729:                         GetDlgItemText(hWnd, IDD_ENCAPS_FILE_EDIT_BOX,
        !           730:                                        pDocDetails->pDMInput->wstrEPSFile,
        !           731:                                        sizeof(pDocDetails->pDMInput->wstrEPSFile));
        !           732: 
        !           733:                     // copy the selected resolution into PSDEVMODE. first
        !           734:                     // get the selected value from the combo box.
        !           735: 
        !           736:                     i = SendDlgItemMessage(hWnd, IDD_RESOLUTION_COMBO_BOX,
        !           737:                                            CB_GETCURSEL, 0, 0L);
        !           738: 
        !           739:                     if (i == CB_ERR)
        !           740:                     {
        !           741:                         RIP("PSCRPTUI!AdvDocPropDialogProc: CB_GETCURSEL failed.\n");
        !           742:                         return (FALSE);
        !           743:                     }
        !           744: 
        !           745:                     i = SendDlgItemMessage(hWnd, IDD_RESOLUTION_COMBO_BOX,
        !           746:                                            CB_GETLBTEXT, i, (DWORD)wcbuf);
        !           747: 
        !           748:                     if (i == CB_ERR)
        !           749:                     {
        !           750:                         RIP("PSCRPTUI!AdvDocPropDialogProc: CB_GETLBTEXT failed.\n");
        !           751:                         return (FALSE);
        !           752:                     }
        !           753: 
        !           754:                     pwstr = wcbuf;
        !           755:                     pstr = cbuf;
        !           756: 
        !           757:                     while (*pwstr)
        !           758:                         *pstr++ = (CHAR)*pwstr++;
        !           759: 
        !           760:                     i = atoi(cbuf);
        !           761:                     pDocDetails->pDMInput->dm.dmPrintQuality = (short)i;
        !           762: 
        !           763:                     // copy the scaling percent into PSDEVMODE.
        !           764: 
        !           765:                     pDocDetails->pDMInput->dm.dmScale =
        !           766:                             (short)GetDlgItemInt(hWnd, IDD_SCALING_EDIT_BOX,
        !           767:                                                  &bTmp, FALSE);
        !           768: 
        !           769:                     // copy our newly developed PSDEVMODE structure
        !           770:                     // into the provided buffer.
        !           771: 
        !           772:                     *pDocDetails->pDMOutput = *pDocDetails->pDMInput;
        !           773: 
        !           774:                     EndDialog (hWnd, IDOK);
        !           775:                     return (TRUE);
        !           776: 
        !           777:                 case IDCANCEL:
        !           778:                     // leave the PSDEVMODE buffer unchanged, end the
        !           779:                     // dialog, and return that the operation was cancelled.
        !           780: 
        !           781:                     // restore copy of the DEVMODE.
        !           782: 
        !           783:                     CopyMemory(&pDocDetails->DMBuffer,
        !           784:                                &pDocDetails->DMOriginal,
        !           785:                                sizeof(PSDEVMODE));
        !           786: 
        !           787:                     EndDialog (hWnd, IDCANCEL);
        !           788:                     return (TRUE);
        !           789: 
        !           790:                 case IDD_HELP_BUTTON:
        !           791:                     vShowHelp(hWnd, HELP_CONTEXT, HLP_ADV_DOC_PROP,
        !           792:                               pDocDetails->hPrinter);
        !           793:                     return (TRUE);
        !           794: 
        !           795:                 case IDD_SUBST_RADIO_BUTTON:
        !           796:                     pDocDetails->pDMInput->dwFlags |= PSDEVMODE_FONTSUBST;
        !           797: 
        !           798:                     return(TRUE);
        !           799: 
        !           800:                 case IDD_SOFTFONT_RADIO_BUTTON:
        !           801:                     pDocDetails->pDMInput->dwFlags &= ~PSDEVMODE_FONTSUBST;
        !           802: 
        !           803:                     return(TRUE);
        !           804: 
        !           805:                 case IDD_PRINTER_RADIO_BUTTON:
        !           806:                     // if the user was printing to an EPS file,
        !           807:                     // then we must clean that up and print to
        !           808:                     // the printer.  otherwise, there is nothing
        !           809:                     // for us to do.
        !           810: 
        !           811:                     if (pDocDetails->pDMInput->dwFlags & PSDEVMODE_EPS)
        !           812:                     {
        !           813:                         // check the Printer radio button, and turn
        !           814:                         // off the EPS file radio button.
        !           815: 
        !           816:                         CheckRadioButton(hWnd, IDD_PRINTER_RADIO_BUTTON,
        !           817:                                          IDD_ENCAPS_FILE_RADIO_BUTTON,
        !           818:                                          IDD_PRINTER_RADIO_BUTTON);
        !           819: 
        !           820:                         // empty out the EPS filename edit box.
        !           821: 
        !           822:                         SetDlgItemText(hWnd, IDD_ENCAPS_FILE_EDIT_BOX, L"");
        !           823: 
        !           824:                         // disable the EPS file edit box and text.
        !           825: 
        !           826:                         EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_TEXT),
        !           827:                                      FALSE);
        !           828:                         EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_EDIT_BOX),
        !           829:                                      FALSE);
        !           830: 
        !           831:                         // clear the EPS file flag.
        !           832: 
        !           833:                         pDocDetails->pDMInput->dwFlags &= ~PSDEVMODE_EPS;
        !           834:                     }
        !           835: 
        !           836:                     return (TRUE);
        !           837: 
        !           838:                 case IDD_ENCAPS_FILE_RADIO_BUTTON:
        !           839:                     // if the user was printing to a printer,
        !           840:                     // then we must clean that up and print to
        !           841:                     // the EPS file.  otherwise, there is nothing
        !           842:                     // for us to do.
        !           843: 
        !           844:                     if (!(pDocDetails->pDMInput->dwFlags & PSDEVMODE_EPS))
        !           845:                     {
        !           846:                         // check the EPS file radio button, and turn off
        !           847:                         // the printer radio button.
        !           848: 
        !           849:                         CheckRadioButton(hWnd, IDD_PRINTER_RADIO_BUTTON,
        !           850:                                          IDD_ENCAPS_FILE_RADIO_BUTTON,
        !           851:                                          IDD_ENCAPS_FILE_RADIO_BUTTON);
        !           852: 
        !           853:                         // fill in the last know EPS file name.
        !           854: 
        !           855:                         SetDlgItemText(hWnd, IDD_ENCAPS_FILE_EDIT_BOX,
        !           856:                                        pDocDetails->pDMInput->wstrEPSFile);
        !           857: 
        !           858:                         // enable the EPS file edit box and text.
        !           859: 
        !           860:                         EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_TEXT),
        !           861:                                      TRUE);
        !           862:                         EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_EDIT_BOX),
        !           863:                                      TRUE);
        !           864: 
        !           865:                         // set the EPS file flag.
        !           866: 
        !           867:                         pDocDetails->pDMInput->dwFlags |= PSDEVMODE_EPS;
        !           868:                     }
        !           869: 
        !           870:                     SendDlgItemMessage(hWnd, IDD_ENCAPS_FILE_EDIT_BOX,
        !           871:                                        EM_SETSEL, 0, 0x7FFF0000);
        !           872: 
        !           873:                     SetFocus(GetDlgItem(hWnd, IDD_ENCAPS_FILE_EDIT_BOX));
        !           874: 
        !           875:                     return (TRUE);
        !           876: 
        !           877:                 case IDD_COLOR_CHECK_BOX:
        !           878:                     // check the current state of the button, and change it
        !           879:                     // to the opposite state.
        !           880: 
        !           881:                     if (pDocDetails->pDMInput->dm.dmColor == DMCOLOR_COLOR)
        !           882:                     {
        !           883:                         // option is enabled, so disable it.
        !           884: 
        !           885:                         CheckDlgButton(hWnd, IDD_COLOR_CHECK_BOX, 0);
        !           886:                         pDocDetails->pDMInput->dm.dmColor = DMCOLOR_MONOCHROME;
        !           887:                     }
        !           888:                     else
        !           889:                     {
        !           890:                         // option is disabled, so enable it.
        !           891: 
        !           892:                         CheckDlgButton(hWnd, IDD_COLOR_CHECK_BOX, 1);
        !           893:                         pDocDetails->pDMInput->dm.dmColor = DMCOLOR_COLOR;
        !           894:                     }
        !           895: 
        !           896:                     return (TRUE);
        !           897: 
        !           898: 
        !           899:                 case IDD_ERROR_HANDLER_CHECK_BOX:
        !           900:                 case IDD_MIRROR_CHECK_BOX:
        !           901:                 case IDD_COLORS_TO_BLACK_CHECK_BOX:
        !           902:                 case IDD_NEG_IMAGE_CHECK_BOX:
        !           903:                     // this case statement is written to handle multiple cases.
        !           904:                     // NOTE! it does assume the order of some things which are
        !           905:                     // asserted below.
        !           906: 
        !           907:                     ASSERTPS((IDD_MIRROR_CHECK_BOX == IDD_ERROR_HANDLER_CHECK_BOX + 1) &&
        !           908:                              (IDD_COLORS_TO_BLACK_CHECK_BOX == IDD_MIRROR_CHECK_BOX + 1) &&
        !           909:                              (IDD_NEG_IMAGE_CHECK_BOX == IDD_COLORS_TO_BLACK_CHECK_BOX + 1),
        !           910:                              "PSCRPTUI!AdvDocPropDialogProc: invalid check box id's.\n");
        !           911: 
        !           912:                     ASSERTPS((PSDEVMODE_MIRROR == PSDEVMODE_EHANDLER << 1) &&
        !           913:                              (PSDEVMODE_BLACK == PSDEVMODE_MIRROR << 1) &&
        !           914:                              (PSDEVMODE_NEG == PSDEVMODE_BLACK << 1),
        !           915:                              "PSCRPTUI!AdvDocPropDialogProc: invalid PSDEVMODE id's.\n");
        !           916: 
        !           917:                     // check the current state of the button, and change it
        !           918:                     // to the opposite state.
        !           919: 
        !           920:                     if (pDocDetails->pDMInput->dwFlags &
        !           921:                         (PSDEVMODE_EHANDLER << (LOWORD(wParam) - IDD_ERROR_HANDLER_CHECK_BOX)))
        !           922:                     {
        !           923:                         // option is enabled, so disable it.
        !           924: 
        !           925:                         CheckDlgButton(hWnd, LOWORD(wParam), 0);
        !           926:                         pDocDetails->pDMInput->dwFlags &=
        !           927:                             ~(PSDEVMODE_EHANDLER << (LOWORD(wParam) - IDD_ERROR_HANDLER_CHECK_BOX));
        !           928:                     }
        !           929:                     else
        !           930:                     {
        !           931:                         // option is disabled, so enable it.
        !           932: 
        !           933:                         CheckDlgButton(hWnd, LOWORD(wParam), 1);
        !           934:                         pDocDetails->pDMInput->dwFlags |=
        !           935:                             (PSDEVMODE_EHANDLER << (LOWORD(wParam) - IDD_ERROR_HANDLER_CHECK_BOX));
        !           936:                     }
        !           937: 
        !           938:                     return (TRUE);
        !           939: 
        !           940:                 default:
        !           941:                     return (FALSE);
        !           942:             }
        !           943: 
        !           944:             break;
        !           945: 
        !           946:         case WM_DESTROY:
        !           947:             // clean up any used help stuff.
        !           948: 
        !           949:             vHelpDone(hWnd);
        !           950:             return (TRUE);
        !           951: 
        !           952:         default:
        !           953:             return (FALSE);
        !           954:     }
        !           955: 
        !           956:     return (FALSE);
        !           957: }
        !           958: 
        !           959: 
        !           960: //--------------------------------------------------------------------------
        !           961: // BOOL InitializeAdvDocPropDialog(hWnd, pDocDetails)
        !           962: // HWND                hWnd;
        !           963: // PDOCDETAILS         pDocDetails;
        !           964: //
        !           965: // This routine does what it's name suggests.
        !           966: //
        !           967: // History:
        !           968: //   15-Apr-1992    -by-    Kent Settle     (kentse)
        !           969: //  Wrote it.
        !           970: //--------------------------------------------------------------------------
        !           971: 
        !           972: BOOL InitializeAdvDocPropDialog(hWnd, pDocDetails)
        !           973: HWND                hWnd;
        !           974: PDOCDETAILS         pDocDetails;
        !           975: {
        !           976:     BOOL            bEPS = FALSE;
        !           977:     PSDEVMODE      *pdevmode;
        !           978:     PWSTR           pwstr;
        !           979:     WCHAR           wcbuf[8];
        !           980:     CHAR            cbuf[8];
        !           981:     LONG            i, j, iResolution;
        !           982:     PSRESOLUTION   *pRes;
        !           983:     PNTPD           pntpd;
        !           984:     BOOL            bFontSubstitution;
        !           985: 
        !           986:     pdevmode = pDocDetails->pDMInput;
        !           987:     pntpd = pDocDetails->pntpd;
        !           988: 
        !           989: //!!! temporarily disable EPS printing until it works.  -kentse.
        !           990: 
        !           991:     EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_TEXT), FALSE);
        !           992:     EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_EDIT_BOX), FALSE);
        !           993:     EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_RADIO_BUTTON), FALSE);
        !           994: 
        !           995: //     if (pdevmode->dwFlags & PSDEVMODE_EPS)
        !           996: //        bEPS = TRUE;
        !           997: 
        !           998:     // check the appropriate Print To radio button.
        !           999: 
        !          1000:     CheckRadioButton(hWnd, IDD_PRINTER_RADIO_BUTTON,
        !          1001:                      IDD_ENCAPS_FILE_RADIO_BUTTON,
        !          1002:                      bEPS ? IDD_ENCAPS_FILE_RADIO_BUTTON :
        !          1003:                                  IDD_PRINTER_RADIO_BUTTON);
        !          1004: 
        !          1005:     SendDlgItemMessage (hWnd, IDD_ENCAPS_FILE_EDIT_BOX, EM_LIMITTEXT,
        !          1006:                         MAX_EPS_FILE, 0L);
        !          1007: 
        !          1008:     // if we are printing to an EPS file, initialize the Name
        !          1009:     // edit box, and enable it.
        !          1010: 
        !          1011:     if (bEPS)
        !          1012:         pwstr = pdevmode->wstrEPSFile;
        !          1013:     else
        !          1014:         pwstr = L"";
        !          1015: 
        !          1016:     SetDlgItemText(hWnd, IDD_ENCAPS_FILE_EDIT_BOX, pwstr);
        !          1017: 
        !          1018:     EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_TEXT), bEPS);
        !          1019:     EnableWindow(GetDlgItem(hWnd, IDD_ENCAPS_FILE_EDIT_BOX), bEPS);
        !          1020: 
        !          1021:     // reset the content of the resolution combo box.
        !          1022: 
        !          1023:     SendDlgItemMessage (hWnd, IDD_RESOLUTION_COMBO_BOX, CB_RESETCONTENT, 0, 0);
        !          1024: 
        !          1025:     // fill in the resolution combo box.
        !          1026: 
        !          1027:     if (pntpd->cResolutions == 0)
        !          1028:     {
        !          1029:         itoa((int)pntpd->iDefResolution, (char *)cbuf, (int)10);
        !          1030:         strcpy2WChar(wcbuf, cbuf);
        !          1031: 
        !          1032:         iResolution = SendDlgItemMessage(hWnd, IDD_RESOLUTION_COMBO_BOX,
        !          1033:                                          CB_INSERTSTRING, (WPARAM)-1,
        !          1034:                                          (LPARAM)wcbuf);
        !          1035:     }
        !          1036:     else
        !          1037:     {
        !          1038:         pRes = (PSRESOLUTION *)((CHAR *)pntpd + pntpd->loResolution);
        !          1039: 
        !          1040:         iResolution = 0;
        !          1041: 
        !          1042:         for (i = 0; i < (int)pntpd->cResolutions; i++)
        !          1043:         {
        !          1044:             itoa((int)pRes->iValue, (CHAR *)cbuf, (int)10);
        !          1045:             strcpy2WChar(wcbuf, cbuf);
        !          1046: 
        !          1047:             j = SendDlgItemMessage(hWnd, IDD_RESOLUTION_COMBO_BOX, CB_INSERTSTRING,
        !          1048:                                    (WPARAM)-1, (LPARAM)wcbuf);
        !          1049: 
        !          1050:             if ((pdevmode->dm.dmPrintQuality == (short)pRes++->iValue))
        !          1051:                 iResolution = j;
        !          1052:         }
        !          1053:     }
        !          1054: 
        !          1055:     // highlight the given resolution.
        !          1056: 
        !          1057:     SendDlgItemMessage(hWnd, IDD_RESOLUTION_COMBO_BOX, CB_SETCURSEL,
        !          1058:                        iResolution, 0L);
        !          1059: 
        !          1060:     // fill in the scaling percentage.
        !          1061: 
        !          1062:     SetDlgItemInt(hWnd, IDD_SCALING_EDIT_BOX, (int)pdevmode->dm.dmScale, FALSE);
        !          1063: 
        !          1064:     // set the state of the color check box.  if the printer is b/w, grey
        !          1065:     // out the check box.  if the printer is color, and DMCOLOR_COLOR is
        !          1066:     // set in the PSDEVMODE, then check the check box.  otherwise, clear
        !          1067:     // the check box.
        !          1068: 
        !          1069:     if (!(pntpd->flFlags & COLOR_DEVICE))
        !          1070:     {
        !          1071:         CheckDlgButton(hWnd, IDD_COLOR_CHECK_BOX, 0);
        !          1072:         EnableWindow(GetDlgItem(hWnd, IDD_COLOR_CHECK_BOX), FALSE);
        !          1073:     }
        !          1074:     else if (pdevmode->dm.dmColor == DMCOLOR_COLOR)
        !          1075:     {
        !          1076:         EnableWindow(GetDlgItem(hWnd, IDD_COLOR_CHECK_BOX), TRUE);
        !          1077:         CheckDlgButton(hWnd, IDD_COLOR_CHECK_BOX, 1);
        !          1078:     }
        !          1079:     else
        !          1080:     {
        !          1081:         EnableWindow(GetDlgItem(hWnd, IDD_COLOR_CHECK_BOX), TRUE);
        !          1082:         CheckDlgButton(hWnd, IDD_COLOR_CHECK_BOX, 0);
        !          1083:     }
        !          1084: 
        !          1085:     // set the state of the negative image check box.
        !          1086: 
        !          1087:     if (pdevmode->dwFlags & PSDEVMODE_NEG)
        !          1088:         CheckDlgButton(hWnd, IDD_NEG_IMAGE_CHECK_BOX, 1);
        !          1089:     else
        !          1090:         CheckDlgButton(hWnd, IDD_NEG_IMAGE_CHECK_BOX, 0);
        !          1091: 
        !          1092:     // set the state of the all colors to black check box.
        !          1093: 
        !          1094:     if (pdevmode->dwFlags & PSDEVMODE_BLACK)
        !          1095:         CheckDlgButton(hWnd, IDD_COLORS_TO_BLACK_CHECK_BOX, 1);
        !          1096:     else
        !          1097:         CheckDlgButton(hWnd, IDD_COLORS_TO_BLACK_CHECK_BOX, 0);
        !          1098: 
        !          1099:     // set the state of the mirror image check box.
        !          1100: 
        !          1101:     if (pdevmode->dwFlags & PSDEVMODE_MIRROR)
        !          1102:         CheckDlgButton(hWnd, IDD_MIRROR_CHECK_BOX, 1);
        !          1103:     else
        !          1104:         CheckDlgButton(hWnd, IDD_MIRROR_CHECK_BOX, 0);
        !          1105: 
        !          1106:     // set the state of the error handler check box.
        !          1107: 
        !          1108:     if (pdevmode->dwFlags & PSDEVMODE_EHANDLER)
        !          1109:         CheckDlgButton(hWnd, IDD_ERROR_HANDLER_CHECK_BOX, 1);
        !          1110:     else
        !          1111:         CheckDlgButton(hWnd, IDD_ERROR_HANDLER_CHECK_BOX, 0);
        !          1112: 
        !          1113:     // check whether font substitution is enabled, and set
        !          1114:     // the appropriate radio button.
        !          1115: 
        !          1116:     if (pdevmode->dm.dmDriverExtra &&
        !          1117:         (!(pdevmode->dwFlags & PSDEVMODE_FONTSUBST)))
        !          1118:         bFontSubstitution = FALSE;
        !          1119:     else
        !          1120:         bFontSubstitution = TRUE;
        !          1121: 
        !          1122:     CheckRadioButton(hWnd, IDD_SUBST_RADIO_BUTTON, IDD_SOFTFONT_RADIO_BUTTON,
        !          1123:                      bFontSubstitution ? IDD_SUBST_RADIO_BUTTON :
        !          1124:                      IDD_SOFTFONT_RADIO_BUTTON);
        !          1125: 
        !          1126:     return(TRUE);
        !          1127: }
        !          1128: 
        !          1129: 
        !          1130: //--------------------------------------------------------------------------
        !          1131: // VOID SetOrientation(hWnd, pDocDetails)
        !          1132: // HWND        hWnd;
        !          1133: // DOCDETAILS *pDocDetails;
        !          1134: //
        !          1135: // This routine selects the proper portrait or landscape icon, depending
        !          1136: // on bPortrait.
        !          1137: //
        !          1138: // History:
        !          1139: //   27-Mar-1992    -by-    Dave Snipp      (davesn)
        !          1140: //  Wrote it.
        !          1141: //--------------------------------------------------------------------------
        !          1142: 
        !          1143: VOID SetOrientation(hWnd, pDocDetails)
        !          1144: HWND        hWnd;
        !          1145: DOCDETAILS *pDocDetails;
        !          1146: {
        !          1147:     BOOL    bLandscape;
        !          1148: 
        !          1149:     bLandscape = (pDocDetails->pDMInput->dm.dmOrientation == DMORIENT_LANDSCAPE);
        !          1150: 
        !          1151:     // load the icons needed within this dialog box.
        !          1152: 
        !          1153:     pDocDetails->hIconPortrait = LoadIcon(hModule,
        !          1154:                                           MAKEINTRESOURCE(ICOPORTRAIT));
        !          1155:     pDocDetails->hIconLandscape = LoadIcon(hModule,
        !          1156:                                           MAKEINTRESOURCE(ICOLANDSCAPE));
        !          1157: 
        !          1158:     SendDlgItemMessage(hWnd, IDD_ORIENTATION_ICON, STM_SETICON,
        !          1159:                        bLandscape ? (WPARAM)pDocDetails->hIconLandscape :
        !          1160:                                    (WPARAM)pDocDetails->hIconPortrait, 0L);
        !          1161: }
        !          1162: 
        !          1163: 
        !          1164: //--------------------------------------------------------------------------
        !          1165: // VOID SetDuplex(hWnd, pDocDetails)
        !          1166: // HWND        hWnd;
        !          1167: // PDOCDETAILS pDocDetails;
        !          1168: //
        !          1169: // This routine will operate on pDocDetails->pDMInput PSDEVMODE structure,
        !          1170: // making sure that is a structure we know about and can handle.
        !          1171: //
        !          1172: // History:
        !          1173: //   20-Apr-1992    -by-    Kent Settle     (kentse)
        !          1174: //  Wrote it.
        !          1175: //--------------------------------------------------------------------------
        !          1176: 
        !          1177: VOID SetDuplex(hWnd, pDocDetails)
        !          1178: HWND        hWnd;
        !          1179: PDOCDETAILS pDocDetails;
        !          1180: {
        !          1181:     BOOL    bPortrait;
        !          1182:     HANDLE  hDuplexIcon;
        !          1183: 
        !          1184:     // set up for proper default duplex mode if it exists on the printer.
        !          1185: 
        !          1186:     if (pDocDetails->flDialogFlags & DOES_DUPLEX)
        !          1187:     {
        !          1188:         // load the duplex icons.
        !          1189: 
        !          1190:         pDocDetails->hIconPDuplexNone = LoadIcon(hModule,
        !          1191:                                                  MAKEINTRESOURCE(ICO_P_NONE));
        !          1192:         pDocDetails->hIconLDuplexNone = LoadIcon(hModule,
        !          1193:                                                  MAKEINTRESOURCE(ICO_L_NONE));
        !          1194:         pDocDetails->hIconPDuplexTumble = LoadIcon(hModule,
        !          1195:                                                  MAKEINTRESOURCE(ICO_P_HORIZ));
        !          1196:         pDocDetails->hIconLDuplexTumble = LoadIcon(hModule,
        !          1197:                                                  MAKEINTRESOURCE(ICO_L_VERT));
        !          1198:         pDocDetails->hIconPDuplexNoTumble = LoadIcon(hModule,
        !          1199:                                                  MAKEINTRESOURCE(ICO_P_VERT));
        !          1200:         pDocDetails->hIconLDuplexNoTumble = LoadIcon(hModule,
        !          1201:                                                  MAKEINTRESOURCE(ICO_L_HORIZ));
        !          1202: 
        !          1203: //!!! Should we have to worry about TRUE and FALSE Duplex printers? - kentse.
        !          1204: 
        !          1205:         bPortrait = (pDocDetails->pDMInput->dm.dmOrientation ==
        !          1206:                     DMORIENT_PORTRAIT);
        !          1207: 
        !          1208:         switch (pDocDetails->pDMInput->dm.dmDuplex)
        !          1209:         {
        !          1210:             case DMDUP_VERTICAL:
        !          1211:                 hDuplexIcon = bPortrait ? pDocDetails->hIconPDuplexNoTumble :
        !          1212:                                           pDocDetails->hIconLDuplexTumble;
        !          1213:                 break;
        !          1214: 
        !          1215:             case DMDUP_HORIZONTAL:
        !          1216:                 hDuplexIcon = bPortrait ? pDocDetails->hIconPDuplexTumble :
        !          1217:                                           pDocDetails->hIconLDuplexNoTumble;
        !          1218:                 break;
        !          1219: 
        !          1220:             default:
        !          1221:                 hDuplexIcon = bPortrait ? pDocDetails->hIconPDuplexNone :
        !          1222:                                           pDocDetails->hIconLDuplexNone;
        !          1223:                 break;
        !          1224:         }
        !          1225: 
        !          1226:         // now set the appropriate icon.
        !          1227: 
        !          1228:         SendDlgItemMessage(hWnd, IDD_DUPLEX_ICON, STM_SETICON,
        !          1229:                            (LONG)hDuplexIcon, 0L);
        !          1230:     }
        !          1231: }
        !          1232: 
        !          1233: 
        !          1234: //--------------------------------------------------------------------------
        !          1235: // VOID SetCollation(hWnd, pDocDetails)
        !          1236: // HWND        hWnd;
        !          1237: // DOCDETAILS *pDocDetails;
        !          1238: //
        !          1239: // This routine selects the proper collation icon and radio
        !          1240: // buttons, depending on pDocDetails.
        !          1241: //
        !          1242: // History:
        !          1243: //   01-Dec-1992    -by-    Kent Settle     (kentse)
        !          1244: //  Wrote it.
        !          1245: //--------------------------------------------------------------------------
        !          1246: 
        !          1247: VOID SetCollation(hWnd, pDocDetails)
        !          1248: HWND        hWnd;
        !          1249: DOCDETAILS *pDocDetails;
        !          1250: {
        !          1251:     BOOL    bCollate;
        !          1252: 
        !          1253:     // set up for proper default collate mode if it exists on the printer.
        !          1254: 
        !          1255:     if (pDocDetails->flDialogFlags & DOES_COLLATE)
        !          1256:     {
        !          1257:         bCollate = pDocDetails->pDMInput->dm.dmCollate;
        !          1258: 
        !          1259:         // load the icons needed within this dialog box.
        !          1260: 
        !          1261:         pDocDetails->hIconCollateOn = LoadIcon(hModule,
        !          1262:                                               MAKEINTRESOURCE(ICO_COLLATE));
        !          1263:         pDocDetails->hIconCollateOff = LoadIcon(hModule,
        !          1264:                                               MAKEINTRESOURCE(ICO_NO_COLLATE));
        !          1265: 
        !          1266:         SendDlgItemMessage(hWnd, IDD_COLLATE_ICON, STM_SETICON,
        !          1267:                            bCollate ? (WPARAM)pDocDetails->hIconCollateOn :
        !          1268:                                       (WPARAM)pDocDetails->hIconCollateOff, 0L);
        !          1269:     }
        !          1270: }
        !          1271: 
        !          1272: 
        !          1273: //--------------------------------------------------------------------------
        !          1274: // BOOL AdjustDevmode(pDocDetails)
        !          1275: // DOCDETAILS *pDocDetails;
        !          1276: //
        !          1277: // This routine will operate on pDocDetails->pDMInput PSDEVMODE structure,
        !          1278: // making sure that is a structure we know about and can handle.
        !          1279: //
        !          1280: // History:
        !          1281: //   20-Apr-1992    -by-    Kent Settle     (kentse)
        !          1282: //  Wrote it.
        !          1283: //--------------------------------------------------------------------------
        !          1284: 
        !          1285: BOOL AdjustDevmode(pDocDetails)
        !          1286: DOCDETAILS *pDocDetails;
        !          1287: {
        !          1288:     PSDEVMODE  devmodeT;
        !          1289: 
        !          1290:     // first create the default DEVMODE structure in pDocDetails->pDMBuffer;
        !          1291: 
        !          1292:     if (!(SetDefaultPSDEVMODE(&devmodeT, pDocDetails->pDeviceName,
        !          1293:                               pDocDetails->pntpd, pDocDetails->hPrinter)))
        !          1294:     {
        !          1295:         RIP("PSCRPTUI!AdjustDevmode: SetDefaultPSDEVMODE failed.\n");
        !          1296:         return(FALSE);
        !          1297:     }
        !          1298: 
        !          1299:     // make sure this is a DEVMODE we can live with.
        !          1300: 
        !          1301:     if (!(ValidateSetDEVMODE(&devmodeT, pDocDetails->pDMInput,
        !          1302:                              pDocDetails->hPrinter, pDocDetails->pntpd)))
        !          1303:     {
        !          1304:         RIP("PSCRPTUI!AdjustDevmode: ValidateSetDEVMODE failed.\n");
        !          1305:         return(FALSE);
        !          1306:     }
        !          1307: 
        !          1308:     // copy our newly created and validated devmode.
        !          1309: 
        !          1310:     pDocDetails->DMBuffer = devmodeT;
        !          1311:     pDocDetails->pDMInput = &pDocDetails->DMBuffer;
        !          1312: 
        !          1313:     return(TRUE);
        !          1314: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.