Annotation of pmsdk/samples/opendlg/file.c, revision 1.1.1.1

1.1       root        1: /*
                      2:     FILE.C -- Open/Save As Dialog Box library routines
                      3:     Created by Microsoft Corporation, 1989
                      4: */
                      5: #define  INCL_DOSQUEUES
                      6: #include "tool.h"
                      7: 
                      8: 
                      9: /****************************************************************************\
                     10: * This function is the Open dialog box window procedure.  It handles input,
                     11: * allows the user to change directories, checks for legal filenames, opens
                     12: * specified files, appends default extensions and returns the file's name.
                     13: *
                     14: * The return values are
                     15: *   TDF_INVALID - Library error (internal error),
                     16: *   TDF_NOOPEN  - User hits cancel
                     17: *   TDF_NEWOPEN - Created new file (file left open)
                     18: *   TDF_OLDOPEN - Opened existing file (file left open)
                     19: \****************************************************************************/
                     20: 
                     21: MRESULT CALLBACK DlgOpenWndProc(hwnd, msg, mp1, mp2)
                     22: HWND hwnd;
                     23: USHORT msg;
                     24: MPARAM mp1;
                     25: MPARAM mp2;
                     26:     {
                     27:     PDLF pdlf;
                     28:     PSZ  lpchFile;
                     29:     CHAR sz[MAX_FNAME_LEN];
                     30: 
                     31:     switch (msg)
                     32:         {
                     33:     case WM_INITDLG:
                     34:         /* initialize dialog box */
                     35:         DlgInitOpen(hwnd, LONGFROMMP(mp2));
                     36: 
                     37:         /* fill static field with path name and fill list box with
                     38:            filenames that lMatch spec */
                     39:         if (!DlgDirList(hwnd, ((PDLF)(mp2))->pszExt+1, ID_DIRLIST,
                     40:                         ID_FILELIST, ID_PATH, ((PDLF)(mp2))->rgbFlags))
                     41:             /* NOTE: shouldn't we post a message if something screws up? */
                     42:             WinDismissDlg(hwnd, TDF_INVALID);
                     43:         break;
                     44: 
                     45:     case WM_COMMAND:
                     46:         pdlf = (PDLF) WinQueryWindowULong(hwnd, 0);
                     47:         switch (SHORT1FROMMP(mp1))
                     48:             {
                     49:         case MBID_OK:
                     50:             /* Open button pressed */
                     51:             /* get name from edit box */
                     52:             WinQueryWindowText(WinWindowFromID(hwnd, ID_EDIT),
                     53:                 CBROOTNAMEMAX, (PSZ)pdlf->szFileName);
                     54:            Upper((PSZ)pdlf->szFileName);
                     55:             if (lstrlen((PSZ)pdlf->szFileName))
                     56:                 DlgOpenName(hwnd, pdlf);
                     57:             break;
                     58: 
                     59:         case MBID_CANCEL:
                     60:             /* Cancel button pressed, dismiss dialog box */
                     61:             WinDismissDlg(hwnd, TDF_NOOPEN);
                     62:            break;
                     63: 
                     64:        case MBID_HELP:
                     65:            /* Help button pressed */
                     66:            WinMessageBox( HWND_DESKTOP
                     67:                         , hwnd
                     68:                         , pdlf->pszInstructions
                     69:                         , pdlf->pszTitle
                     70:                         , NULL
                     71:                         , MB_OK | MB_APPLMODAL );
                     72:            break;
                     73:             }
                     74:         break;
                     75: 
                     76:     case WM_CONTROL:
                     77:         pdlf = (PDLF) WinQueryWindowULong(hwnd, 0);
                     78:         switch (SHORT1FROMMP(mp1))
                     79:             {
                     80:         case ID_DIRLIST:
                     81:             /* user clicked in directory list box */
                     82:             switch (SHORT2FROMMP(mp1))
                     83:                 {
                     84:             case LN_SELECT:
                     85:                 /* single click case */
                     86:                 /* get current edit string */
                     87:                 WinQueryWindowText(WinWindowFromID(hwnd, ID_EDIT),
                     88:                                    CBROOTNAMEMAX, (PSZ)sz);
                     89:                 Upper((PSZ)sz);
                     90: 
                     91:                 /* get selected string */
                     92:                 if (DlgDirSelect(hwnd, (PSZ)pdlf->szFileName, ID_DIRLIST))
                     93:                     {
                     94:                     /* if edit field contains wild card, then append file
                     95:                       part to selected directory, otherwise append
                     96:                       last wildcard search spec */
                     97:                     lpchFile = FileInPath((PSZ)sz);
                     98:                    lstrcat( (PSZ)pdlf->szFileName
                     99:                           , DlgSearchSpec( lpchFile)
                    100:                             ? lpchFile
                    101:                             : (PSZ)pdlf->szLastWild );
                    102:                     /* set edit box to resulting name */
                    103:                     WinSetWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    104:                                      (PSZ)pdlf->szFileName);
                    105:                     }
                    106:                 break;
                    107: 
                    108:             case LN_ENTER:
                    109:                /* get text from edit box */
                    110:                WinQueryWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    111:                                   CBROOTNAMEMAX, (PSZ)pdlf->szFileName);
                    112:                Upper((PSZ)pdlf->szFileName);
                    113:                if( DlgSearchSpec( (PSZ)pdlf->szFileName))
                    114:                    {
                    115:                    DlgDirList( hwnd
                    116:                              , (PSZ)pdlf->szFileName
                    117:                              , ID_DIRLIST
                    118:                              , ID_FILELIST
                    119:                              , ID_PATH
                    120:                              , pdlf->rgbFlags );
                    121:                    lstrcpy( (PSZ)pdlf->szLastWild
                    122:                           , FileInPath( (PSZ)pdlf->szFileName));
                    123:                    WinSetWindowText( WinWindowFromID( hwnd, ID_EDIT)
                    124:                                    , (PSZ)pdlf->szFileName );
                    125:                    }
                    126:                 break;
                    127:                 }
                    128:             break;
                    129: 
                    130:         case ID_FILELIST:
                    131:             /* user clicked in file list box */
                    132:             switch (SHORT2FROMMP(mp1))
                    133:                 {
                    134:             case LN_SELECT:
                    135:                 /* single click case */
                    136: 
                    137:                /* get current edit string */
                    138:                /* if it contains a wildcard, save it before obliteration */
                    139:                 WinQueryWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    140:                                    CBROOTNAMEMAX, (PSZ)sz);
                    141:                Upper((PSZ)sz);
                    142:                if( DlgSearchSpec( (PSZ)sz))
                    143:                    lstrcpy( (PSZ)pdlf->szLastWild, FileInPath( (PSZ)sz));
                    144: 
                    145:                 /* get selected file name */
                    146:                 DlgDirSelect(hwnd, (PSZ)pdlf->szFileName, ID_FILELIST);
                    147:                 /* set edit box to resulting name */
                    148:                 WinSetWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    149:                                  (PSZ)pdlf->szFileName);
                    150:                 break;
                    151: 
                    152:             case LN_ENTER:
                    153:                 /* double click case, single click already processed */
                    154:                 DlgOpenName(hwnd, pdlf);
                    155:                 break;
                    156:                 }
                    157:             break;
                    158:             }
                    159:         break;
                    160: 
                    161:     default:
                    162:         return (WinDefDlgProc(hwnd, msg, mp1, mp2));
                    163:         }
                    164: 
                    165:     return (MRFROMLONG(0L));  /* message processed */
                    166:     }
                    167: 
                    168: 
                    169: 
                    170: 
                    171: /****************************************************************************\
                    172: * This function stores the pdlf in the dialog window structure, sets
                    173: * the title and instruction texts and limits the text size.
                    174: \****************************************************************************/
                    175: 
                    176: VOID PASCAL DlgInitOpen (hwnd, lpParm)
                    177: HWND hwnd;
                    178: ULONG lpParm;
                    179:     {
                    180:     PDLF pdlf;
                    181: 
                    182:     /* Set pdlf local to window */
                    183:     pdlf = (PDLF) lpParm;
                    184:     WinSetWindowULong(hwnd, 0, lpParm);
                    185: 
                    186:     /* set edit box text size limit */
                    187:     WinSendDlgItemMsg(hwnd, ID_EDIT, EM_SETTEXTLIMIT, (MPARAM)CBROOTNAMEMAX, 0L);
                    188: 
                    189:     /* set edit window to search spec */
                    190:     if (pdlf->pszExt != (PSZ)NULL)
                    191:         WinSetWindowText(WinWindowFromID(hwnd, ID_EDIT), pdlf->pszExt+1);
                    192: 
                    193:     /* set title window */
                    194:     if (pdlf->pszTitle != (PSZ)NULL)
                    195:        WinSetWindowText(WinWindowFromID(hwnd, FID_TITLEBAR), pdlf->pszTitle);
                    196:     }
                    197: 
                    198: 
                    199: 
                    200: 
                    201: /****************************************************************************\
                    202: * This function processes the currently selected name in the open dialog
                    203: * box.  If the name represents a directory, the current directory is
                    204: * changed to that one and the corresponding files are displayed.  If the
                    205: * name is a file, then it is opened.
                    206: \****************************************************************************/
                    207: 
                    208: VOID PASCAL DlgOpenName(hwnd, pdlf)
                    209: HWND hwnd;
                    210: PDLF pdlf;
                    211:     {
                    212:     PSZ  lpch;
                    213:     USHORT wVal;
                    214:     CHAR sz[MAX_FNAME_LEN];
                    215: 
                    216:     /* try using current name as a directory */
                    217:     lstrcpy((PSZ)sz, (PSZ)pdlf->szFileName);
                    218:     if (!DlgSearchSpec((PSZ)sz))
                    219:         DlgAddSearchExt(pdlf, (PSZ)sz);
                    220:     if (DlgDirList(hwnd, (PSZ)sz, ID_DIRLIST, ID_FILELIST, ID_PATH,
                    221:                    pdlf->rgbFlags))
                    222:         {
                    223:         /* name was a directory, extract and set file name */
                    224:         lpch = FileInPath((PSZ)sz);
                    225:         lstrcpy((PSZ)pdlf->szFileName, lpch);
                    226:         WinSetWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    227:                          (PSZ)pdlf->szFileName);
                    228:         }
                    229:     else
                    230:         /* try to open name as a file */
                    231:         if ((wVal = DlgOpenFile(pdlf, hwnd)) != TDF_NOOPEN)
                    232:             WinDismissDlg(hwnd, wVal);
                    233:     }
                    234: 
                    235: 
                    236: 
                    237: 
                    238: /****************************************************************************\
                    239: * This function is the SaveAs dialog box window procedure.  It handles input,
                    240: * tests for legal filenames and uses message boxes to report any problems.
                    241: *
                    242: * Return values are:
                    243: *     TDF_INVALID - Library error (internal error),
                    244: *     TDF_NOOPEN  - User hits cancel
                    245: *   Specific for DLG_NOOPEN
                    246: *     TDF_NEWSAVE - user wants to save to a new file (file not created)
                    247: *     TDF_OLDSAVE - user wants to save over existing file (file not opened)
                    248: *   else
                    249: *     TDF_NEWSAVE - user wants to save to a new file (file left open)
                    250: *     TDF_OLDSAVE - user wants to save over existing file (file left open)
                    251: \****************************************************************************/
                    252: 
                    253: MRESULT CALLBACK DlgSaveAsWndProc(hwnd, msg, mp1, mp2)
                    254: HWND   hwnd;
                    255: USHORT msg;
                    256: MPARAM mp1;
                    257: MPARAM mp2;
                    258:     {
                    259:     PDLF    pdlf;
                    260:     PSZ     lpchFile;
                    261:     CHAR    sz[MAX_FNAME_LEN];
                    262: 
                    263:     switch (msg)
                    264:         {
                    265:     case WM_INITDLG:
                    266:         /* Store pdlf, set instructions, limit text size */
                    267:         DlgInitSaveAs(hwnd, LONGFROMMP(mp2));
                    268: 
                    269:         /* fill static field with path name and fill list box with
                    270:            filenames that lMatch spec */
                    271:         if (!DlgDirList(hwnd, ((PDLF)(mp2))->pszExt+1, ID_DIRLIST,
                    272:                         ID_FILELIST, ID_PATH, ((PDLF)(mp2))->rgbFlags))
                    273:             /* NOTE: shouldn't we post a message if something screws up? */
                    274:             WinDismissDlg(hwnd, TDF_INVALID);
                    275:         break;
                    276: 
                    277:     case WM_COMMAND:
                    278:         pdlf = (PDLF) WinQueryWindowULong(hwnd, 0);
                    279:         switch (SHORT1FROMMP(mp1))
                    280:            {
                    281:         case MBID_OK:
                    282:             /* get text from edit box */
                    283:             WinQueryWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    284:                                CBROOTNAMEMAX, (PSZ)pdlf->szFileName);
                    285:            Upper((PSZ)pdlf->szFileName);
                    286:            if( DlgSearchSpec( (PSZ)pdlf->szFileName))
                    287:                {
                    288:                DlgDirList( hwnd
                    289:                          , (PSZ)pdlf->szFileName
                    290:                          , ID_DIRLIST
                    291:                          , ID_FILELIST
                    292:                          , ID_PATH
                    293:                          , pdlf->rgbFlags );
                    294:                lstrcpy( (PSZ)pdlf->szLastWild
                    295:                       , FileInPath( (PSZ)pdlf->szFileName));
                    296:                lstrcpy( (PSZ)pdlf->szFileName, (PSZ)pdlf->szLastFile);
                    297:                WinSetWindowText( WinWindowFromID( hwnd, ID_EDIT)
                    298:                                , (PSZ)pdlf->szFileName );
                    299:                }
                    300:            else if( lstrlen( (PSZ)pdlf->szFileName))
                    301:                DlgSaveAsName( hwnd, pdlf);
                    302:             break;
                    303: 
                    304:         case MBID_CANCEL:
                    305:             WinDismissDlg(hwnd, TDF_NOSAVE);
                    306:             break;
                    307: 
                    308:        case MBID_HELP:
                    309:            /* Help button pressed */
                    310:            WinMessageBox( HWND_DESKTOP
                    311:                         , hwnd
                    312:                         , pdlf->pszInstructions
                    313:                         , pdlf->pszTitle
                    314:                         , NULL
                    315:                         , MB_OK | MB_APPLMODAL );
                    316:            break;
                    317:             }
                    318:         break;
                    319: 
                    320:     case WM_CONTROL:
                    321:         pdlf = (PDLF) WinQueryWindowULong(hwnd, 0);
                    322:         switch (SHORT1FROMMP(mp1))
                    323:             {
                    324:         case ID_DIRLIST:
                    325:             /* user clicked in directory list box */
                    326:             switch (SHORT2FROMMP(mp1))
                    327:                 {
                    328:             case LN_SELECT:
                    329:                 /* single click case */
                    330:                 /* get current edit string */
                    331:                 WinQueryWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    332:                                    CBROOTNAMEMAX, (PSZ)sz);
                    333:                 Upper((PSZ)sz);
                    334: 
                    335:                 /* get selected string */
                    336:                 if (DlgDirSelect(hwnd, (PSZ)pdlf->szFileName, ID_DIRLIST))
                    337:                     {
                    338:                     /* if edit field contains wild card, then append file
                    339:                       part to selected directory, otherwise append
                    340:                       last wildcard search spec */
                    341:                     lpchFile = FileInPath((PSZ)sz);
                    342:                    if( DlgSearchSpec( lpchFile))
                    343:                        {
                    344:                        lstrcat( (PSZ)pdlf->szFileName, lpchFile );
                    345:                        lstrcpy( (PSZ)pdlf->szLastWild, lpchFile);
                    346:                        }
                    347:                    else
                    348:                        {
                    349:                        lstrcat( (PSZ)pdlf->szFileName, (PSZ)pdlf->szLastWild );
                    350:                        lstrcpy( (PSZ)pdlf->szLastFile, lpchFile);
                    351:                        }
                    352:                     /* set edit box to resulting name */
                    353:                     WinSetWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    354:                                      (PSZ)pdlf->szFileName);
                    355:                     }
                    356:                 break;
                    357: 
                    358:             case LN_ENTER:
                    359:                /* get text from edit box */
                    360:                WinQueryWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    361:                                   CBROOTNAMEMAX, (PSZ)pdlf->szFileName);
                    362:                Upper((PSZ)pdlf->szFileName);
                    363:                if( DlgSearchSpec( (PSZ)pdlf->szFileName))
                    364:                    {
                    365:                    DlgDirList( hwnd
                    366:                              , (PSZ)pdlf->szFileName
                    367:                              , ID_DIRLIST
                    368:                              , ID_FILELIST
                    369:                              , ID_PATH
                    370:                              , pdlf->rgbFlags );
                    371:                    lstrcpy( (PSZ)pdlf->szLastWild
                    372:                           , FileInPath( (PSZ)pdlf->szFileName));
                    373:                    lstrcpy( (PSZ)pdlf->szFileName, (PSZ)pdlf->szLastFile);
                    374:                    WinSetWindowText( WinWindowFromID( hwnd, ID_EDIT)
                    375:                                    , (PSZ)pdlf->szFileName );
                    376:                    }
                    377:                break;
                    378:                }
                    379:             break;
                    380: 
                    381:         case ID_FILELIST:
                    382:             /* user clicked in file list box */
                    383:             switch (SHORT2FROMMP(mp1))
                    384:                 {
                    385:             case LN_SELECT:
                    386:                 /* single click case */
                    387: 
                    388:                /* get current edit string */
                    389:                /* if it contains a wildcard, save it before obliteration */
                    390:                 WinQueryWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    391:                                    CBROOTNAMEMAX, (PSZ)sz);
                    392:                Upper((PSZ)sz);
                    393:                if( DlgSearchSpec( (PSZ)sz))
                    394:                    lstrcpy( (PSZ)pdlf->szLastWild, FileInPath( (PSZ)sz));
                    395: 
                    396:                 /* get selected file name */
                    397:                 DlgDirSelect(hwnd, (PSZ)pdlf->szFileName, ID_FILELIST);
                    398:                 /* set edit box to resulting name */
                    399:                 WinSetWindowText(WinWindowFromID(hwnd, ID_EDIT),
                    400:                                  (PSZ)pdlf->szFileName);
                    401:                 break;
                    402: 
                    403:             case LN_ENTER:
                    404:                 /* double click case, single click already processed */
                    405:                DlgSaveAsName(hwnd, pdlf);
                    406:                 break;
                    407:                 }
                    408:             break;
                    409:             }
                    410:         break;
                    411: 
                    412:     default:
                    413:         return (WinDefDlgProc(hwnd, msg, mp1, mp2));
                    414:         }
                    415: 
                    416:     return (MRFROMLONG(0L));    /* message processed */
                    417:     }
                    418: 
                    419: 
                    420: 
                    421: /******************************************************************************/
                    422: /*                                                                           */
                    423: /* This function attempts to open a file for writing.  It queries if over-    */
                    424: /* write is OK if the file already exists.                                   */
                    425: /*                                                                           */
                    426: /******************************************************************************/
                    427: VOID PASCAL DlgSaveAsName( hwnd, pdlf)
                    428: HWND  hwnd;
                    429: PDLF  pdlf;
                    430:     {
                    431:     USHORT  usTdf;
                    432: 
                    433:     /* add extension if there is not one already */
                    434:     AddExt((PSZ)pdlf->szFileName, pdlf->pszExt);
                    435:     /* test file name legality */
                    436:     if (!DlgParseFile((PSZ)pdlf->szFileName,
                    437:                      (PSZ)pdlf->szOpenFile, FALSE, FALSE))
                    438:        {
                    439:        /* illegal filename */
                    440:        DlgAlertBox(hwnd, IDS_IFN, pdlf,
                    441:                    MB_OK | MB_ICONEXCLAMATION);
                    442:        return;
                    443:        }
                    444:     usTdf = TDF_NEWSAVE;
                    445:     /* test if file already exists */
                    446:     if (DlgParseFile((PSZ)pdlf->szFileName,
                    447:                     (PSZ)pdlf->szOpenFile, TRUE, FALSE))
                    448:        {
                    449:        /* overwrite? */
                    450:        if (DlgAlertBox(hwnd, IDS_REF, pdlf,
                    451:                        MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION)
                    452:            == MBID_NO)
                    453:            return;
                    454:        usTdf = TDF_OLDSAVE;
                    455:        }
                    456:     if (!(pdlf->rgbAction & DLG_NOOPEN) &&
                    457:        !(OpenFile( (PSZ)pdlf->szFileName
                    458:                  , pdlf->phFile
                    459:                  , (PSZ)pdlf->szOpenFile
                    460:                  , OF_WRITE)))
                    461:        {
                    462:        DlgAlertBox(hwnd, IDS_EOF, pdlf,
                    463:                    MB_OK | MB_ICONEXCLAMATION);
                    464:        return;
                    465:        }
                    466:     WinDismissDlg(hwnd, usTdf);
                    467:     }
                    468: 
                    469: 
                    470: 
                    471: /****************************************************************************\
                    472: * This function initializes the SaveAs dialog box.  It puts the current
                    473: * directory string in the ID_PATH field and initializes the edit box
                    474: * with the proposed filename.  It is the simple relative file name if current
                    475: * dir == pdlf->szOpenFile.  Otherwise, it is the fully qualified name.
                    476: \****************************************************************************/
                    477: 
                    478: VOID PASCAL DlgInitSaveAs (hwnd, lpParm)
                    479: HWND hwnd;
                    480: ULONG lpParm;
                    481:     {
                    482:     PDLF pdlf;
                    483:     CHAR sz[MAX_FNAME_LEN];
                    484:     PSZ  lpszFile, lpszFN, lpszCD;
                    485: 
                    486:     /* set pdlf local to window */
                    487:     pdlf = (PDLF) lpParm;
                    488:     WinSetWindowULong(hwnd, 0, lpParm);
                    489: 
                    490:     /* set edit box text size limit */
                    491:     WinSendDlgItemMsg(hwnd, ID_EDIT, EM_SETTEXTLIMIT, (MPARAM)CBROOTNAMEMAX, 0L);
                    492: 
                    493:     /* set title window */
                    494:     if (pdlf->pszTitle != (PSZ)NULL)
                    495:        WinSetWindowText(WinWindowFromID(hwnd, FID_TITLEBAR), pdlf->pszTitle);
                    496: 
                    497:     /* set szLastWild to search spec */
                    498:     if (pdlf->pszExt != (PSZ)NULL)
                    499:        lstrcpy( (PSZ)pdlf->szLastWild, (PSZ)pdlf->pszExt+1 );
                    500: 
                    501:     /* get current directory */
                    502:     DosSearchPath(0, (PSZ)szDot, (PSZ)szStarStar, (PSZ)sz, MAX_FNAME_LEN);
                    503:     lpszFile = FileInPath((PSZ)sz);
                    504:     if (lpszFile > (PSZ)sz + 3)
                    505:         lpszFile--;
                    506:     *lpszFile = '\0';
                    507: 
                    508:     /* compare path part name to previously opened file name and
                    509:        make the file name relative if they are the same */
                    510:     lpszFN = (PSZ)pdlf->szOpenFile;
                    511:     lpszCD = (PSZ)sz;
                    512:     lpszFile = FileInPath((PSZ)pdlf->szOpenFile);
                    513:     while (lpszFN < lpszFile && *lpszFN == *lpszCD)
                    514:         {
                    515:         lpszFN = NextChar(lpszFN);
                    516:         lpszCD = NextChar(lpszCD);
                    517:         }
                    518:     if (*lpszCD)
                    519:         lpszFN = (PSZ)pdlf->szOpenFile;
                    520:     else if (*lpszFN == '\\')
                    521:        lpszFN = NextChar(lpszFN);
                    522:     Upper( lpszFN);
                    523:     WinSetWindowText(WinWindowFromID(hwnd, ID_EDIT), lpszFN);
                    524:     lstrcpy( (PSZ)pdlf->szLastFile, lpszFN);
                    525: 
                    526:     /* set current path field */
                    527:     WinSetWindowText(WinWindowFromID(hwnd, ID_PATH),
                    528:                      DlgFitPathToBox(hwnd, ID_PATH, (PSZ)sz));
                    529:     }
                    530: 
                    531: 
                    532: 
                    533: 
                    534: /****************************************************************************\
                    535: * This function returns the filename part of the given path string.
                    536: \****************************************************************************/
                    537: 
                    538: PSZ  CALLBACK FileInPath(lpsz)
                    539: PSZ  lpsz;
                    540:     {
                    541:     PSZ  lpch;
                    542: 
                    543:     /* strip path/drive specification from name if there is one */
                    544:     lpch = lpsz + lstrlen(lpsz);
                    545:     while (lpch > lpsz)
                    546:         {
                    547:         lpch = PrevChar(lpsz, lpch);
                    548:         if (*lpch == '\\' || *lpch == ':')
                    549:             {
                    550:             lpch = NextChar(lpch);
                    551:             break;
                    552:             }
                    553:         }
                    554:     return(lpch);
                    555:     }
                    556: 
                    557: 
                    558: 
                    559: 
                    560: /****************************************************************************\
                    561: * This function adds the extension to a file name if it is missing.
                    562: \****************************************************************************/
                    563: 
                    564: VOID CALLBACK AddExt(lpsz, lpszExt)
                    565: PSZ  lpsz;
                    566: PSZ  lpszExt;
                    567:     {
                    568:     PSZ  lpch;
                    569: 
                    570:     lpch = lpsz + lstrlen(lpsz);
                    571:     while (*lpch != '.' && *lpch != '\\' && *lpch != ':' && lpch > lpsz)
                    572:         lpch = PrevChar(lpsz, lpch);
                    573: 
                    574:     if (*lpch != '.')
                    575:         lstrcat(lpsz, (PSZ)(lpszExt+2));
                    576:     }
                    577: 
                    578: 
                    579: 
                    580: 
                    581: /****************************************************************************\
                    582: * This function adds the "appropriate" extension to a filename, partial
                    583: * filename, search spec or partial search spec.
                    584: \****************************************************************************/
                    585: 
                    586: VOID PASCAL DlgAddSearchExt(pdlf, lpszEdit)
                    587: PDLF pdlf;
                    588: PSZ  lpszEdit;
                    589:     {
                    590:     PSZ  lpchLast;
                    591: 
                    592:     lpchLast = PrevChar(lpszEdit, lpszEdit + lstrlen(lpszEdit));
                    593:     if (*lpchLast == '\\' || *lpchLast == ':')
                    594:         lstrcat(lpszEdit, pdlf->pszExt + 1);
                    595:     else
                    596:         lstrcat(lpszEdit, pdlf->pszExt);
                    597:     }
                    598: 
                    599: 
                    600: 
                    601: 
                    602: /****************************************************************************\
                    603: * This function returns TRUE if lpsz contains a wildcard character '*' or '?';
                    604: \****************************************************************************/
                    605: 
                    606: BOOL PASCAL DlgSearchSpec(lpsz)
                    607: PSZ  lpsz;
                    608:    {
                    609:     for (; *lpsz; lpsz = NextChar(lpsz))
                    610:         if (*lpsz == '*' || *lpsz == '?')
                    611:             return TRUE;
                    612:     return FALSE;
                    613:    }
                    614: 
                    615: 
                    616: 
                    617: 
                    618: /****************************************************************************\
                    619: * This function displays an error or warning msg.
                    620: \****************************************************************************/
                    621: 
                    622: int PASCAL DlgAlertBox(hwnd, ids, pdlf, wStyle)
                    623: HWND hwnd;
                    624: int ids;
                    625: PDLF pdlf;
                    626: USHORT wStyle;
                    627:     {
                    628:     /* note:  5th param is idHelp */
                    629:     return (AlertBox(hwnd, ids, (PSZ)pdlf->szFileName, pdlf->pszAppName,
                    630:                          NULL, wStyle | MB_APPLMODAL));
                    631:     }

unix.superglobalmegacorp.com

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