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

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