home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / bmp1.zip / OpenDlg.C < prev    next >
C/C++ Source or Header  |  1995-10-25  |  22KB  |  637 lines

  1. #pragma    title("View Bitmap  --  Version 1  --  (OpenDlg.C)")
  2. #pragma    subtitle("   File Open - Interface Definitions")
  3.  
  4. #define    INCL_DOS           /* Include OS/2 DOS Kernal        */
  5. #define    INCL_DOSERRORS           /* Include OS/2 DOS Errors        */
  6. #define    INCL_GPI           /* Include OS/2 PM GPI Interface    */
  7. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  8.  
  9. #pragma    info(noext)
  10.  
  11. #include <malloc.h>
  12. #include <os2.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16.  
  17. #include "appdefs.h"
  18. #include "viewbmp.h"
  19.  
  20. /* This    module contains    the routines that allow    the user to select a    */
  21. /* bitmap file to open and view.                    */
  22.  
  23. /* Filename:   OpenDlg.C                        */
  24.  
  25. /*  Version:   1                            */
  26. /*  Created:   1995-07-05                        */
  27. /*  Revised:   1995-07-22                        */
  28.  
  29. /* Routines:   MRESULT EXPENTRY    OpenBitmapDlgProc(HWND hWnd,        */
  30. /*                          ULONG    msg,        */
  31. /*                          MPARAM mp1,        */
  32. /*                          MPARAM mp2);        */
  33. /*           static VOID ShowDirInfo(HWND hWnd, ULONG    idPath,        */
  34. /*                       ULONG idVol, ULONG idRoom);    */
  35. /*           static VOID DiskVolDrive(ULONG ulDrive,            */
  36. /*                    CHAR *pszDiskName);        */
  37. /*           static VOID QueryDriveList( );                */
  38. /*           static ULONG ulGetDirList(HWND hwndDrives, HWND hwndDirs,*/
  39. /*                     HWND hwndFiles);        */
  40.  
  41. /************************************************************************/
  42. /************************************************************************/
  43. /************************************************************************/
  44. /* DISCLAIMER OF WARRANTIES:                        */
  45. /* -------------------------                        */
  46. /* The following [enclosed] code is sample code    created    by IBM        */
  47. /* Corporation and Prominare Inc.  This    sample code is not part    of any    */
  48. /* standard IBM    product    and is provided    to you solely for the purpose    */
  49. /* of assisting    you in the development of your applications.  The code    */
  50. /* is provided "AS IS",    without    warranty of any    kind.  Neither IBM nor    */
  51. /* Prominare shall be liable for any damages arising out of your    */
  52. /* use of the sample code, even    if they    have been advised of the    */
  53. /* possibility of such damages.                        */
  54. /************************************************************************/
  55. /************************************************************************/
  56. /************************************************************************/
  57. /*               D I S C L A I M E R                */
  58. /* This    code is    provided on an as is basis with    no implied support.    */
  59. /* It should be    considered freeware that cannot    be rebundled as        */
  60. /* part    of a larger "*ware" offering without our consent.        */
  61. /************************************************************************/
  62. /************************************************************************/
  63. /************************************************************************/
  64.  
  65. /* Copyright ╕ International Business Machines Corp., 1995.        */
  66. /* Copyright ╕ 1995  Prominare Inc.  All Rights    Reserved.        */
  67.  
  68. /* --------------------------------------------------------------------    */
  69.  
  70. /************************************************************************/
  71. /*                                    */
  72. /*     Module Prototype    Definitions                    */
  73. /*                                    */
  74. /************************************************************************/
  75.  
  76. static VOID  QueryDriveList(VOID);
  77. static ULONG ulGetDirList(HWND hwndDrives, HWND    hwndDirs, HWND hwndFiles);
  78. static VOID  DiskVolDrive(ULONG    ulDrive, CHAR *pszDiskName);
  79. static VOID  ShowDirInfo(HWND hWnd, ULONG idPath, ULONG    idVol, ULONG idRoom);
  80.  
  81. /************************************************************************/
  82. /*                                    */
  83. /*     Module Data Definitions                        */
  84. /*                                    */
  85. /************************************************************************/
  86.  
  87. BOOL  fLineNumbers = FALSE;       /* Line Numbers Flag            */
  88. INT   iFileSel = LIT_NONE;       /* File Selected            */
  89. BOOL  fDrivesFilled;           /* Drives Filled Flag        */
  90. ULONG ulDriveMap;           /* Drive Bit    Map Holder        */
  91. LONG  cDrives;
  92. CHAR  aszDrives[26][20];
  93. BOOL  afRemoveable[26] = { FALSE, FALSE, FALSE,    FALSE, FALSE, FALSE, FALSE, FALSE,
  94.                FALSE, FALSE, FALSE,    FALSE, FALSE, FALSE, FALSE, FALSE,
  95.                FALSE, FALSE, FALSE,    FALSE, FALSE, FALSE, FALSE, FALSE,
  96.                FALSE, FALSE    };
  97.  
  98. #pragma    subtitle("   Open Bitmap -  Open Bitmap Dialogue Procedure")
  99. #pragma    page( )
  100.  
  101. /* --- OpenBitmapDlgProc ------------------------------- [ Public ] ---    */
  102. /*                                    */
  103. /*     This function is    used to    retrieve a bitmap file for viewing    */
  104. /*     print dialogue procedure.                    */
  105. /*                                    */
  106. /*     Upon Entry:                            */
  107. /*                                    */
  108. /*     HWND   hWnd; = Dialog Window Handle                */
  109. /*     ULONG  msg;  = PM Message                    */
  110. /*     MPARAM mp1;  = Message Parameter    1                */
  111. /*     MPARAM mp2;  = Message Parameter    2                */
  112. /*                                    */
  113. /*     Upon Exit:                            */
  114. /*                                    */
  115. /*     OpenBitmapDlgProc = Message Handling Result            */
  116. /*                                    */
  117. /* --------------------------------------------------------------------    */
  118.  
  119. MRESULT    EXPENTRY OpenBitmapDlgProc(HWND    hWnd, ULONG msg, MPARAM    mp1, MPARAM mp2)
  120.  
  121. {
  122. CHAR     szFileName[CCHMAXPATH];   /* Filename Holder            */
  123. CHAR     szStrBuf[CCHMAXPATH];       /* String Buffer            */
  124. register INT i;               /* Loop Counters            */
  125.  
  126. switch ( msg )
  127.    {
  128.                /* Perform dialog initialization            */
  129.    case    WM_INITDLG :
  130.        WinSetPointer(HWND_DESKTOP, hptrWait);
  131.  
  132.                /* Clear    the drives filled flag            */
  133.  
  134.        fDrivesFilled = FALSE;
  135.  
  136.                /* Get a    list of    the drives, directories    and    */
  137.                /* files    for the    list boxes and show the    number    */
  138.                /* of files within the directory            */
  139.  
  140.        sprintf(szStrBuf, "%d", ulGetDirList(WinWindowFromID(hWnd, CBX_DRIVES),
  141.                         WinWindowFromID(hWnd, LB_DIRECTORIES),
  142.                         WinWindowFromID(hWnd, LB_FILES)));
  143.        WinSetDlgItemText(hWnd, IT_FILECOUNT, szStrBuf);
  144.  
  145.                /* Get directory/file list and display in list    */
  146.                /* boxes                        */
  147.  
  148.        ShowDirInfo(hWnd, IT_DIRECTORY, IT_VOLUMELABEL, IT_DISKFREE);
  149.  
  150.                /* Select the last Open Bitmaped             */
  151.  
  152.        if ( iFileSel !=    LIT_NONE )
  153.        WinSendDlgItemMsg(hWnd, LB_DIRECTORIES, LM_SELECTITEM, MPFROMSHORT(iFileSel),
  154.                  MPFROMSHORT(TRUE));
  155.        WinSetPointer(HWND_DESKTOP, hptrArrow);
  156.        break;
  157.             /* Process control selections            */
  158.    case    WM_CONTROL :
  159.        switch (    SHORT2FROMMP(mp1) )
  160.        {
  161.                /* Enter    or selection made within error combo    */
  162.                /* box                        */
  163.        case    CBN_ENTER :
  164.            switch (    SHORT1FROMMP(mp1) )
  165.            {
  166.            case    CBX_DRIVES :
  167.  
  168.                /* Get item selected from the list box        */
  169.  
  170.                WinSendDlgItemMsg(hWnd, CBX_DRIVES, LM_QUERYITEMTEXT,
  171.                   MPFROM2SHORT(LONGFROMMR(WinSendDlgItemMsg(hWnd, CBX_DRIVES,
  172.                                         LM_QUERYSELECTION,
  173.                                         0L,    0L)),
  174.                            CCHMAXPATH),
  175.                   MPFROMP(szFileName));
  176.  
  177.                /* Change drives                    */
  178.  
  179.                DosSetDefaultDisk((ULONG)((szFileName[0]    & 223) - '@'));
  180.  
  181.                /* Refresh the directory    files list and show the    */
  182.                /* number of files within the directory        */
  183.  
  184.                sprintf(szStrBuf, "%d", ulGetDirList(WinWindowFromID(hWnd, CBX_DRIVES),
  185.                     WinWindowFromID(hWnd, LB_DIRECTORIES),
  186.                     WinWindowFromID(hWnd, LB_FILES)));
  187.                WinSetDlgItemText(hWnd, IT_FILECOUNT, szStrBuf);
  188.  
  189.                /* Display the directory    path, volume label and    */
  190.                /* total    disk space free                */
  191.  
  192.                ShowDirInfo(hWnd, IT_DIRECTORY, IT_VOLUMELABEL, IT_DISKFREE);
  193.                break;
  194.  
  195.            default :
  196.                break;
  197.            }
  198.            break;
  199.                /* Drive/directory selected, get    entry selected    */
  200.                /* and change to    drive or directory selected    */
  201.  
  202.        case    LN_ENTER :
  203.            switch (    SHORT1FROMMP(mp1) )
  204.            {
  205.            case    LB_DIRECTORIES :
  206.  
  207.                /* Get item selected from the directories list    */
  208.                /* box                        */
  209.  
  210.                WinSendDlgItemMsg(hWnd, LB_DIRECTORIES, LM_QUERYITEMTEXT,
  211.                   MPFROM2SHORT(LONGFROMMR(WinSendDlgItemMsg(hWnd, LB_DIRECTORIES,
  212.                                         LM_QUERYSELECTION, 0L, 0L)),
  213.                            sizeof(szFileName)),
  214.                   MPFROMP(szFileName));
  215.  
  216.                /* Change to the    selected directory        */
  217.  
  218.                DosSetCurrentDir(szFileName);
  219.  
  220.                /* Refresh the directory    files list and show the    */
  221.                /* number of files within the directory        */
  222.  
  223.                sprintf(szStrBuf, "%d", ulGetDirList(WinWindowFromID(hWnd, CBX_DRIVES),
  224.                     WinWindowFromID(hWnd, LB_DIRECTORIES),
  225.                     WinWindowFromID(hWnd, LB_FILES)));
  226.                WinSetDlgItemText(hWnd, IT_FILECOUNT, szStrBuf);
  227.  
  228.                /* Display the directory    path, volume label and    */
  229.                /* total    disk space free                */
  230.  
  231.                ShowDirInfo(hWnd, IT_DIRECTORY, IT_VOLUMELABEL, IT_DISKFREE);
  232.                break;
  233.  
  234.            case    LB_FILES :
  235.  
  236.                /* Item within the files    list box double    clicked    */
  237.                /* on, user indicating that the file selected    */
  238.                /* should be printed, therefore,    force the    */
  239.                /* simulation of    the Print push button        */
  240.  
  241.                WinSendMsg(hWnd,    WM_COMMAND, MPFROMSHORT(DID_OK), 0L);
  242.                break;
  243.            }
  244.            break;
  245.        }
  246.        break;
  247.             /* Process push    button selections        */
  248.    case    WM_COMMAND :
  249.     switch ( SHORT1FROMMP(mp1) )
  250.         {
  251.                /* Print    push button clicked            */
  252.        case    DID_OK :
  253.                /* Get the file selected                */
  254.  
  255.            if ( (iFileSel =    (i = (INT)LONGFROMMR(WinSendDlgItemMsg(hWnd, LB_FILES,
  256.                                        LM_QUERYSELECTION,
  257.                                        0L, 0L)))) == LIT_NONE )
  258.            break;
  259.            else
  260.                /* Get item selected from the list box and    */
  261.                /* determine which file selected            */
  262.  
  263.            WinSendDlgItemMsg(hWnd, LB_FILES, LM_QUERYITEMTEXT,
  264.                      MPFROM2SHORT(i, CCHMAXPATH),
  265.                      MPFROMP(szBitmapFile));
  266.  
  267.            WinDismissDlg(hWnd, TRUE);
  268.            break;
  269.                /* Cancel push button selected            */
  270.        case    DID_CANCEL :
  271.            WinDismissDlg(hWnd, FALSE);
  272.            break;
  273.         }
  274.     break;
  275.             /* Close requested, exit dialogue        */
  276.    case    WM_CLOSE :
  277.     WinDismissDlg(hWnd, FALSE);
  278.     break;
  279.             /* Pass    through    unhandled messages        */
  280.    default :
  281.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  282.    }
  283. return(0L);
  284. }
  285. #pragma    subtitle("   Open Bitmap - Directory Information Display Function")
  286. #pragma    page( )
  287.  
  288. /* --- ShowDirInfo ------------------------------------    [ Private ] ---    */
  289. /*                                    */
  290. /*     This function is    used to    display    information regarding the    */
  291. /*     path, volume label and room remaining.                */
  292. /*                                    */
  293. /*     Upon Entry:                            */
  294. /*                                    */
  295. /*     HWND  hWnd;   = Dialog Dialogue Window Handle            */
  296. /*     ULONG idPath; = Path ID                        */
  297. /*     ULONG idVol;  = Volume Label ID                    */
  298. /*     ULONG idRoom; = Room Remaining ID                */
  299. /*                                    */
  300. /*     Upon Exit:                            */
  301. /*                                    */
  302. /*     Nothing                                */
  303. /*                                    */
  304. /* --------------------------------------------------------------------    */
  305.  
  306. static VOID ShowDirInfo(HWND hWnd, ULONG idPath, ULONG idVol, ULONG idRoom)
  307.  
  308. {
  309. CHAR       szStrBuf[CCHMAXPATH];   /* String Buffer            */
  310. FSALLOCATE diskinfo;           /* Disk Information Structure    */
  311. FSINFO       fsinf;           /* Disk Volume Information Structure    */
  312. ULONG       cbBuf;           /* Directory    Buffer Size Count    */
  313. ULONG       ulCurDrive;           /* Current Drive Designation        */
  314. ULONG       ulDrives;           /* Drive Map                */
  315.  
  316.                /* Form the current drive/path and display    */
  317.                /* within the Path display field            */
  318.  
  319. DosQueryCurrentDisk(&ulCurDrive, &ulDriveMap);
  320.  
  321.                /* Get the current drive    and path being used and    */
  322.                /* display with Path display field        */
  323.  
  324. DosQueryCurrentDisk(&ulCurDrive, &ulDrives);
  325. memcpy(&szStrBuf[1], ":\\", 3);
  326. szStrBuf[0] = (CHAR)(ulCurDrive    + '@');
  327. cbBuf =    CCHMAXPATH - 3;
  328.                /* Get information on the current directory    */
  329.  
  330. if ( !DosQueryCurrentDir(ulCurDrive, &szStrBuf[3], &cbBuf) )
  331.    {
  332.                /* Show the full    path information        */
  333.  
  334.    WinSetDlgItemText(hWnd, idPath, szStrBuf);
  335.  
  336.                /* Get the volume information and display it    */
  337.  
  338.    if (    !DosQueryFSInfo(0UL, FSIL_VOLSER, (PBYTE)(&fsinf), sizeof(FSINFO)) )
  339.        if ( fsinf.vol.szVolLabel[0] )
  340.        WinSetDlgItemText(hWnd, idVol, fsinf.vol.szVolLabel);
  341.        else
  342.        WinSetDlgItemText(hWnd, idVol, "");
  343.  
  344.                /* Get the remaining space of the drive and    */
  345.                /* display                    */
  346.  
  347.    if (    !DosQueryFSInfo(ulCurDrive, FSIL_ALLOC,    (PVOID)&diskinfo,
  348.             sizeof(FSALLOCATE)) )
  349.        WinSetDlgItemText(hWnd, idRoom,
  350.              strcat(_ltoa((LONG)(diskinfo.cbSector * diskinfo.cSectorUnit *    diskinfo.cUnitAvail),
  351.                 szStrBuf, 10), " Bytes"));
  352.    }
  353. }
  354. #pragma    subtitle("   Open Bitmap - Get Disk Volume Label Function")
  355. #pragma    page( )
  356.  
  357. /* --- DiskVolDrive -----------------------------------    [ Private ] ---    */
  358. /*                                    */
  359. /*     This function is    used to    retrieve the volume label of the    */
  360. /*     default disk drive.                        */
  361. /*                                    */
  362. /*     Upon Entry:                            */
  363. /*                                    */
  364. /*     ULONG ulDrive;       = Drive Number                */
  365. /*     CHAR  *pszDiskName; = Holder for    Volume Label            */
  366. /*                                    */
  367. /*     Upon Exit:                            */
  368. /*                                    */
  369. /*     Nothing                                */
  370. /*                                    */
  371. /* --------------------------------------------------------------------    */
  372.  
  373. static VOID DiskVolDrive(ULONG ulDrive,    CHAR *pszDiskName)
  374.  
  375. {
  376. FSINFO fsinf;              /* Disk Volume Information Structure */
  377.  
  378.                /* Get the disk volume label            */
  379.  
  380. if ( !DosQueryFSInfo(ulDrive, FSIL_VOLSER, (PBYTE)(&fsinf), sizeof(FSINFO)) )
  381.    if (    fsinf.vol.szVolLabel[0]    )
  382.        strcat(strcat(memcpy(pszDiskName, "[ ", 3), fsinf.vol.szVolLabel), " ]");
  383.    else
  384.        pszDiskName[0] =    (CHAR)0;
  385. }
  386. #pragma    subtitle("   Open Bitmap - Drive List Query Procedure")
  387. #pragma    page( )
  388.  
  389. /* --- QueryDriveList ---------------------------------- [ Public ] ---    */
  390. /*                                    */
  391. /*     This function is    used to    build a    list of    valid drives.        */
  392. /*                                    */
  393. /*     Upon Entry:                            */
  394. /*                                    */
  395. /*     Nothing                                */
  396. /*                                    */
  397. /*     Upon Exit:                            */
  398. /*                                    */
  399. /*     Nothing                                */
  400. /*                                    */
  401. /* --------------------------------------------------------------------    */
  402.  
  403. static VOID QueryDriveList(VOID)
  404.  
  405. {
  406. CHAR        szDrive[4];           /* Drive Designation    Holder        */
  407. PFSQBUFFER2 psqbf;           /* File System Query    Buffer Pointer    */
  408. ULONG        cbDrvi;           /* Buffer Count            */
  409. ULONG        ulError;           /* OS/2 Error            */
  410. ULONG        ulCurDrive;           /* Current Drive Designation        */
  411. ULONG        ulDriveMask    = 1;       /* Drive Bit    Map Mask        */
  412. register INT i;               /* Loop Counter            */
  413.  
  414.                /* Perform general initialization        */
  415.  
  416. DosQueryCurrentDisk(&ulCurDrive, &ulDriveMap);
  417.  
  418.                /* Allocate space for the file system query    */
  419.                /* buffer                    */
  420.  
  421. psqbf =    (PFSQBUFFER2)malloc(1024UL);
  422. memcpy(&szDrive[1], ":", 2);
  423.  
  424. for ( i    = cDrives = 0; i < 26; i++ )
  425.    {
  426.                /* Determine if a disk drive present by masking    */
  427.                /* out the drive    present    bit            */
  428.  
  429.    if (    ulDriveMap & ulDriveMask )
  430.        {
  431.                /* Save the drive designation for the drive    */
  432.                /* that is present                */
  433.  
  434.        aszDrives[cDrives][0] = szDrive[0] = (CHAR)(i + 'A');
  435.        memcpy(&aszDrives[cDrives][1], ":\\ ", 4);
  436.  
  437.                /* Start    with hard disk drives, check to    see if    */
  438.                /* the drive is local or    remote.     Remote    drives    */
  439.                /* are generally    networked drives.  Prominare    */
  440.                /* Builder denotes diskette, local and remote    */
  441.                /* drives within    the Drives/Directories window.    */
  442.        if ( i >    1 )
  443.        {
  444.                /* Initialize the buffer    count before the file    */
  445.                /* system is queried otherwise the call may fail    */
  446.  
  447.        cbDrvi = 1024UL;
  448.  
  449.        if (    (ulError = DosQueryFSAttach(szDrive, 1UL, FSAIL_QUERYNAME,
  450.                         (PFSQBUFFER2)psqbf,
  451.                         &cbDrvi)) == ERROR_NOT_READY )
  452.            afRemoveable[cDrives++] = TRUE;
  453.        else
  454.            if ( !ulError )
  455.            if (    !memcmp(&psqbf->rgFSAData[1], "CDFS", 5) )
  456.                afRemoveable[cDrives++] = TRUE;
  457.            else
  458.                ++cDrives;
  459.        }
  460.        else
  461.        afRemoveable[cDrives++] = TRUE;
  462.        }
  463.                /* Shift    the drive designation bitmap mask    */
  464.    ulDriveMask <<= 1;
  465.    }
  466.                /* Release the memory allocated for the query    */
  467.                /* buffer                    */
  468. free(psqbf);
  469. }
  470. #pragma    subtitle("   Open Bitmap - Directory Retrieval/Display Function")
  471. #pragma    page( )
  472.  
  473. /* --- ulGetDirList -----------------------------------    [ Private ] ---    */
  474. /*                                    */
  475. /*     This function is    used to    search for sub-directories and files    */
  476. /*     within the current sub-directory/drive and place    the entries    */
  477. /*     within two list boxes.                        */
  478. /*                                    */
  479. /*     Upon Entry:                            */
  480. /*                                    */
  481. /*     HWND hwndDrives;    = Drives Combo Box Handle            */
  482. /*     HWND hwndDirs;    = Directories List Box Handle            */
  483. /*     HWND hwndFiles;    = Files    List Box Handle                */
  484. /*                                    */
  485. /*     Upon Exit:                            */
  486. /*                                    */
  487. /*     ulGetDirList = Number of    Files in Files List Box            */
  488. /*                                    */
  489. /* --------------------------------------------------------------------    */
  490.  
  491. static ULONG ulGetDirList(HWND hwndDrives, HWND    hwndDirs, HWND hwndFiles)
  492.  
  493. {
  494. HDIR          hDir = (HDIR)HDIR_CREATE;/* Directory Handle        */
  495. HPOINTER      hptr;           /* Mouse Pointer Handle        */
  496. PFILEFINDBUF3 pfindbuf3;       /* File Find    Buffer            */
  497. PFILEFINDBUF3 pfindbuf;           /* File Find    Buffer            */
  498. ULONG          cFiles = 0UL;       /* Files Count            */
  499. ULONG          ulCurDrive;       /* Current Drive Designation        */
  500. ULONG          ulDrives;           /* Drive Bit    Map Holder        */
  501. ULONG          ulErr;           /* OS/2 Error Value            */
  502. ULONG          ulFileCnt    = 71UL;       /* File Counter Holder        */
  503. register INT i,    n;           /* Loop Counters            */
  504.  
  505. hptr = WinQueryPointer(HWND_DESKTOP);
  506.  
  507.                /* Set the mouse    pointer    to hourglass shape    */
  508.                /* while    directory search taking    place        */
  509.  
  510. WinSetPointer(HWND_DESKTOP,
  511.           WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
  512.  
  513.                /* Allocate memory for a    large directory    search    */
  514.                /* buffer                    */
  515.  
  516. pfindbuf3 = (PFILEFINDBUF3)malloc(71UL * sizeof(FILEFINDBUF3));
  517.  
  518.                /* Get the handles of the list boxes and    disable    */
  519.                /* updating of them while inserting the data    */
  520.                /* into them and    delete the contents within them    */
  521.  
  522. WinEnableWindowUpdate(hwndDirs,     FALSE);
  523. WinEnableWindowUpdate(hwndFiles, FALSE);
  524. WinSendMsg(hwndDirs,  LM_DELETEALL, 0L,    0L);
  525. WinSendMsg(hwndFiles, LM_DELETEALL, 0L,    0L);
  526.  
  527.                /* Start    directory search            */
  528.  
  529. if ( !(ulErr = DosFindFirst("*.*", &hDir, MUST_HAVE_DIRECTORY |    FILE_DIRECTORY,
  530.                 (PVOID)pfindbuf3, 71UL * sizeof(FILEFINDBUF3),
  531.                 &ulFileCnt,    FIL_STANDARD)) )
  532.    {
  533.    do
  534.        for ( i = 0, pfindbuf = pfindbuf3; i < ulFileCnt; i++ )
  535.        {
  536.                /* If file found    a sub-directory, place into the    */
  537.                /* Directories list box                */
  538.  
  539.        if (    (pfindbuf->attrFile & FILE_DIRECTORY) && memcmp(pfindbuf->achName, ".",    2) )
  540.            WinSendMsg(hwndDirs, LM_INSERTITEM, MPFROMSHORT(LIT_SORTASCENDING),
  541.               MPFROMP(pfindbuf->achName));
  542.        pfindbuf = (PFILEFINDBUF3)((PBYTE)pfindbuf +    pfindbuf->oNextEntryOffset);
  543.        }
  544.        while ( (ulFileCnt == 71UL) &&
  545.            !DosFindNext(hDir, pfindbuf3, 71UL * sizeof(FILEFINDBUF3), &ulFileCnt) );
  546.  
  547.                /* Close    directory search handle            */
  548.    DosFindClose(hDir);
  549.    }
  550. else
  551.    if (    ulErr != ERROR_NO_MORE_FILES )
  552.        {
  553.                /* Release the memory allocated for the search    */
  554.                /* buffer                    */
  555.  
  556.        free((PVOID)pfindbuf3);
  557.        return(0);
  558.        }
  559.  
  560. if ( !fDrivesFilled )
  561.    {
  562.                /* Form the current drive/path and display    */
  563.                /* within the Path display field            */
  564.  
  565.    DosQueryCurrentDisk(&ulCurDrive, &ulDrives);
  566.    if (    ulDriveMap != ulDrives )
  567.        QueryDriveList( );
  568.    for ( i = 0;    i < cDrives; i++ )
  569.        {
  570.        if ( !afRemoveable[i] )
  571.        DiskVolDrive((ULONG)(i + 1),    &aszDrives[i][4]);
  572.        else
  573.        aszDrives[i][4] = (CHAR)0;
  574.        n = (INT)LONGFROMMR(WinSendMsg(hwndDrives, LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(aszDrives[i])));
  575.        if ( i == (ulCurDrive - 1) )
  576.        WinSendMsg(hwndDrives, LM_SELECTITEM, MPFROMLONG(n),    MPFROMLONG(TRUE));
  577.        }
  578.    fDrivesFilled = TRUE;
  579.    }
  580.                /* Reset    directory handle and file counter    */
  581. hDir = (HDIR)HDIR_CREATE;
  582. ulFileCnt = 71UL;
  583.                /* Start    file search                */
  584.  
  585. if ( !(ulErr = DosFindFirst("*.bmp", &hDir, FILE_NORMAL,
  586.                 (PVOID)pfindbuf3, 71UL * sizeof(FILEFINDBUF3),
  587.                 &ulFileCnt,    FIL_STANDARD)) )
  588.    {
  589.    do
  590.        for ( i = 0, pfindbuf = pfindbuf3; i < ulFileCnt; i++ )
  591.        {
  592.                /* If file found    not a sub-directory, place    */
  593.                /* filename in list box                */
  594.  
  595.        if (    (pfindbuf->attrFile & FILE_DIRECTORY) != FILE_DIRECTORY    )
  596.            {
  597.            ++cFiles;
  598.            WinSendMsg(hwndFiles, LM_INSERTITEM, MPFROMSHORT(LIT_SORTASCENDING),
  599.               MPFROMP(pfindbuf->achName));
  600.            }
  601.        pfindbuf = (PFILEFINDBUF3)((PBYTE)pfindbuf +    pfindbuf->oNextEntryOffset);
  602.        }
  603.                /* Search for remaining entries and place valid    */
  604.                /* entries in list box                */
  605.  
  606.        while ( (ulFileCnt == 71UL) &&
  607.         !DosFindNext(hDir, pfindbuf3, 71UL * sizeof(FILEFINDBUF3), &ulFileCnt) );
  608.  
  609.                /* Close    directory search handle            */
  610.    DosFindClose(hDir);
  611.    }
  612. else
  613.    if (    ulErr != ERROR_NO_MORE_FILES )
  614.        {
  615.                /* Release the memory allocated for the search    */
  616.                /* buffer                    */
  617.  
  618.        free((PVOID)pfindbuf3);
  619.        return(0);
  620.        }
  621.                /* Release the memory allocated for the search    */
  622.                /* buffer                    */
  623. free((PVOID)pfindbuf3);
  624.                /* Re-enable updating to    the list boxes and    */
  625.                /* force    the displaying of the new contents    */
  626.  
  627. WinShowWindow(hwndDirs,    TRUE);
  628. WinShowWindow(hwndFiles, TRUE);
  629.  
  630.                /* Reset    edit field text    in case    invalid    search    */
  631.                /* spec entered and reset mouse pointer back to    */
  632.                /* arrow    shape                    */
  633.  
  634. WinSetPointer(HWND_DESKTOP, hptr);
  635. return(cFiles);
  636. }
  637.