home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / kwclass.zip / KFILLST.CPP < prev    next >
C/C++ Source or Header  |  1994-04-18  |  1KB  |  65 lines

  1. #define INCL_BASE
  2. #include <os2.h>
  3. #include <kfillst.hpp>
  4. #include <kwconst.hpp>
  5. #include <itextctl.hpp>
  6.  
  7. Boolean KFileListHandler::dispatchHandlerEvent(IEvent &event)
  8. {
  9.   if (event.eventId() == KW_FILL)
  10.      return fillList(event);
  11.   else
  12.      return false;
  13. }
  14.  
  15.  
  16. Boolean KFileListBox::fill()
  17. {
  18.    FILEFINDBUF3 findBuf;
  19.    unsigned long ulSearchCount;
  20.    HDIR hDir;
  21.    APIRET rc;
  22.  
  23.    // use the system-default search-directory handle
  24.    hDir = HDIR_SYSTEM;
  25.  
  26.    // initialize the search count to 1, to only find 1 file at a time
  27.    ulSearchCount = 1;
  28.  
  29.    // clear current items
  30.    removeAll();
  31.  
  32.    // initiate the search
  33.    rc = DosFindFirst(spec, 
  34.                      &hDir, FILE_NORMAL,
  35.                      &findBuf, sizeof(findBuf),
  36.                      &ulSearchCount, FIL_STANDARD);
  37.    if (rc && rc != ERROR_NO_MORE_FILES)        
  38.       return false;
  39.    if (!rc)
  40.    {
  41.       while (rc != ERROR_NO_MORE_FILES)
  42.       {
  43.          // add the file name to the list box
  44.          addAsLast(findBuf.achName);
  45.  
  46.          // get the next file
  47.          rc = DosFindNext(hDir, 
  48.                           &findBuf, sizeof(findBuf),
  49.                           &ulSearchCount);
  50.       }
  51.  
  52.       // terminate the search
  53.       DosFindClose(hDir);
  54.    }
  55.    return true;
  56. }
  57.  
  58. Boolean KFileListBox::fillList(IEvent &event)
  59. {
  60.   fill();
  61.   if (target)
  62.      target->setText("");
  63.   return true;
  64. }
  65.