home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / bmp2.zip / OPENDLG.C < prev    next >
C/C++ Source or Header  |  1995-08-06  |  22KB  |  640 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 "rops.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( )
  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. DosError(FERR_DISABLEHARDERR);
  424.  
  425. for ( i    = cDrives = 0; i < 26; i++ )
  426.    {
  427.                /* Determine if a disk drive present by masking    */
  428.                /* out the drive    present    bit            */
  429.  
  430.    if (    ulDriveMap & ulDriveMask )
  431.        {
  432.                /* Save the drive designation for the drive    */
  433.                /* that is present                */
  434.  
  435.        aszDrives[cDrives][0] = szDrive[0] = (CHAR)(i + 'A');
  436.        memcpy(&aszDrives[cDrives][1], ":\\ ", 4);
  437.  
  438.                /* Start    with hard disk drives, check to    see if    */
  439.                /* the drive is local or    remote.     Remote    drives    */
  440.                /* are generally    networked drives.  Prominare    */
  441.                /* Builder denotes diskette, local and remote    */
  442.                /* drives within    the Drives/Directories window.    */
  443.        if ( i >    1 )
  444.        {
  445.                /* Initialize the buffer    count before the file    */
  446.                /* system is queried otherwise the call may fail    */
  447.  
  448.        cbDrvi = 1024UL;
  449.  
  450.        if (    (ulError = DosQueryFSAttach(szDrive, 1UL, FSAIL_QUERYNAME,
  451.                         (PFSQBUFFER2)psqbf,
  452.                         &cbDrvi)) == ERROR_NOT_READY )
  453.            afRemoveable[cDrives++] = TRUE;
  454.        else
  455.            if ( !ulError )
  456.            if (    !memcmp(&psqbf->rgFSAData[1], "CDFS", 5) )
  457.                afRemoveable[cDrives++] = TRUE;
  458.            else
  459.                ++cDrives;
  460.        }
  461.        else
  462.        afRemoveable[cDrives++] = TRUE;
  463.        }
  464.                /* Shift    the drive designation bitmap mask    */
  465.    ulDriveMask <<= 1;
  466.    }
  467. DosError(FERR_ENABLEHARDERR);
  468.  
  469.                /* Release the memory allocated for the query    */
  470.                /* buffer                    */
  471. free(psqbf);
  472. }
  473. #pragma    subtitle("   Open Bitmap - Directory Retrieval/Display Function")
  474. #pragma    page( )
  475.  
  476. /* --- ulGetDirList -----------------------------------    [ Private ] ---    */
  477. /*                                    */
  478. /*     This function is    used to    search for sub-directories and files    */
  479. /*     within the current sub-directory/drive and place    the entries    */
  480. /*     within two list boxes.                        */
  481. /*                                    */
  482. /*     Upon Entry:                            */
  483. /*                                    */
  484. /*     HWND hwndDrives;    = Drives Combo Box Handle            */
  485. /*     HWND hwndDirs;    = Directories List Box Handle            */
  486. /*     HWND hwndFiles;    = Files    List Box Handle                */
  487. /*                                    */
  488. /*     Upon Exit:                            */
  489. /*                                    */
  490. /*     ulGetDirList = Number of    Files in Files List Box            */
  491. /*                                    */
  492. /* --------------------------------------------------------------------    */
  493.  
  494. static ULONG ulGetDirList(HWND hwndDrives, HWND    hwndDirs, HWND hwndFiles)
  495.  
  496. {
  497. HDIR          hDir = (HDIR)HDIR_CREATE;/* Directory Handle        */
  498. HPOINTER      hptr;           /* Mouse Pointer Handle        */
  499. PFILEFINDBUF3 pfindbuf3;       /* File Find    Buffer            */
  500. PFILEFINDBUF3 pfindbuf;           /* File Find    Buffer            */
  501. ULONG          cFiles = 0UL;       /* Files Count            */
  502. ULONG          ulCurDrive;       /* Current Drive Designation        */
  503. ULONG          ulDrives;           /* Drive Bit    Map Holder        */
  504. ULONG          ulErr;           /* OS/2 Error Value            */
  505. ULONG          ulFileCnt    = 71UL;       /* File Counter Holder        */
  506. register INT i,    n;           /* Loop Counters            */
  507.  
  508. hptr = WinQueryPointer(HWND_DESKTOP);
  509.  
  510.                /* Set the mouse    pointer    to hourglass shape    */
  511.                /* while    directory search taking    place        */
  512.  
  513. WinSetPointer(HWND_DESKTOP,
  514.           WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
  515.  
  516.                /* Allocate memory for a    large directory    search    */
  517.                /* buffer                    */
  518.  
  519. pfindbuf3 = (PFILEFINDBUF3)malloc(71UL * sizeof(FILEFINDBUF3));
  520.  
  521.                /* Get the handles of the list boxes and    disable    */
  522.                /* updating of them while inserting the data    */
  523.                /* into them and    delete the contents within them    */
  524.  
  525. WinEnableWindowUpdate(hwndDirs,     FALSE);
  526. WinEnableWindowUpdate(hwndFiles, FALSE);
  527. WinSendMsg(hwndDirs,  LM_DELETEALL, 0L,    0L);
  528. WinSendMsg(hwndFiles, LM_DELETEALL, 0L,    0L);
  529.  
  530.                /* Start    directory search            */
  531.  
  532. if ( !(ulErr = DosFindFirst("*.*", &hDir, MUST_HAVE_DIRECTORY |    FILE_DIRECTORY,
  533.                 (PVOID)pfindbuf3, 71UL * sizeof(FILEFINDBUF3),
  534.                 &ulFileCnt,    FIL_STANDARD)) )
  535.    {
  536.    do
  537.        for ( i = 0, pfindbuf = pfindbuf3; i < ulFileCnt; i++ )
  538.        {
  539.                /* If file found    a sub-directory, place into the    */
  540.                /* Directories list box                */
  541.  
  542.        if (    (pfindbuf->attrFile & FILE_DIRECTORY) && memcmp(pfindbuf->achName, ".",    2) )
  543.            WinSendMsg(hwndDirs, LM_INSERTITEM, MPFROMSHORT(LIT_SORTASCENDING),
  544.               MPFROMP(pfindbuf->achName));
  545.        pfindbuf = (PFILEFINDBUF3)((PBYTE)pfindbuf +    pfindbuf->oNextEntryOffset);
  546.        }
  547.        while ( (ulFileCnt == 71UL) &&
  548.            !DosFindNext(hDir, pfindbuf3, 71UL * sizeof(FILEFINDBUF3), &ulFileCnt) );
  549.  
  550.                /* Close    directory search handle            */
  551.    DosFindClose(hDir);
  552.    }
  553. else
  554.    if (    ulErr != ERROR_NO_MORE_FILES )
  555.        {
  556.                /* Release the memory allocated for the search    */
  557.                /* buffer                    */
  558.  
  559.        free((PVOID)pfindbuf3);
  560.        return(0);
  561.        }
  562.  
  563. if ( !fDrivesFilled )
  564.    {
  565.                /* Form the current drive/path and display    */
  566.                /* within the Path display field            */
  567.  
  568.    DosQueryCurrentDisk(&ulCurDrive, &ulDrives);
  569.    if (    ulDriveMap != ulDrives )
  570.        QueryDriveList( );
  571.    for ( i = 0;    i < cDrives; i++ )
  572.        {
  573.        if ( !afRemoveable[i] )
  574.        DiskVolDrive((ULONG)(i + 1),    &aszDrives[i][4]);
  575.        else
  576.        aszDrives[i][4] = (CHAR)0;
  577.        n = (INT)LONGFROMMR(WinSendMsg(hwndDrives, LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(aszDrives[i])));
  578.        if ( i == (ulCurDrive - 1) )
  579.        WinSendMsg(hwndDrives, LM_SELECTITEM, MPFROMLONG(n),    MPFROMLONG(TRUE));
  580.        }
  581.    fDrivesFilled = TRUE;
  582.    }
  583.                /* Reset    directory handle and file counter    */
  584. hDir = (HDIR)HDIR_CREATE;
  585. ulFileCnt = 71UL;
  586.                /* Start    file search                */
  587.  
  588. if ( !(ulErr = DosFindFirst("*.bmp", &hDir, FILE_NORMAL,
  589.                 (PVOID)pfindbuf3, 71UL * sizeof(FILEFINDBUF3),
  590.                 &ulFileCnt,    FIL_STANDARD)) )
  591.    {
  592.    do
  593.        for ( i = 0, pfindbuf = pfindbuf3; i < ulFileCnt; i++ )
  594.        {
  595.                /* If file found    not a sub-directory, place    */
  596.                /* filename in list box                */
  597.  
  598.        if (    (pfindbuf->attrFile & FILE_DIRECTORY) != FILE_DIRECTORY    )
  599.            {
  600.            ++cFiles;
  601.            WinSendMsg(hwndFiles, LM_INSERTITEM, MPFROMSHORT(LIT_SORTASCENDING),
  602.               MPFROMP(pfindbuf->achName));
  603.            }
  604.        pfindbuf = (PFILEFINDBUF3)((PBYTE)pfindbuf +    pfindbuf->oNextEntryOffset);
  605.        }
  606.                /* Search for remaining entries and place valid    */
  607.                /* entries in list box                */
  608.  
  609.        while ( (ulFileCnt == 71UL) &&
  610.         !DosFindNext(hDir, pfindbuf3, 71UL * sizeof(FILEFINDBUF3), &ulFileCnt) );
  611.  
  612.                /* Close    directory search handle            */
  613.    DosFindClose(hDir);
  614.    }
  615. else
  616.    if (    ulErr != ERROR_NO_MORE_FILES )
  617.        {
  618.                /* Release the memory allocated for the search    */
  619.                /* buffer                    */
  620.  
  621.        free((PVOID)pfindbuf3);
  622.        return(0);
  623.        }
  624.                /* Release the memory allocated for the search    */
  625.                /* buffer                    */
  626. free((PVOID)pfindbuf3);
  627.                /* Re-enable updating to    the list boxes and    */
  628.                /* force    the displaying of the new contents    */
  629.  
  630. WinShowWindow(hwndDirs,    TRUE);
  631. WinShowWindow(hwndFiles, TRUE);
  632.  
  633.                /* Reset    edit field text    in case    invalid    search    */
  634.                /* spec entered and reset mouse pointer back to    */
  635.                /* arrow    shape                    */
  636.  
  637. WinSetPointer(HWND_DESKTOP, hptr);
  638. return(cFiles);
  639. }
  640.