🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #5665

Drag 'n Drop of a folder (with textfiles) into a ListBox - confuse effect...

#5665
From: Oren Halvani
Date: Tue, 02 Aug 2005 00:32
77 lines
3426 bytes
dear builders,

again a strange drag 'n drop problerm...
i want my programm to be able to recognize folders
and drop their file-content into my ListBox (name: FileBox)
so, i've tryed the below code..the while loop seems to work
but after more testing, i have note that my ListBox is not longer
working properly - the OnClick, OnDoubleClick, OnKeyPress
and other Events are not working at all...WHY???

what is wrong here again...? i know the problem is in the while loop
but can someone describe it to me so i can fix it...?



thanks for any help....


Oren

/*************************************************************/
void __fastcall TfrmMainUnit::WMDropFiles(TWMDropFiles &Message)
{
    int ilFilesCount, ilStrLength;
    char caFileName[MAX_PATH];

    ilFilesCount = DragQueryFile((HDROP)Message.Drop, -1, NULL, 0);

    // step through all dropped files - even if they are folders...
    /*****************************************************************/
    for(int ilIndex = 0; ilIndex < ilFilesCount; ilIndex++)
    {
      ilStrLength = DragQueryFile((HDROP)Message.Drop,ilIndex,NULL,0);
      DragQueryFile((HDROP)Message.Drop, ilIndex, caFileName, ilStrLength+1);


      // is it a folder...?
      /*****************************************************************/
      if(FileGetAttr(caFileName) & faDirectory)
      {
         String filename = caFileName, wildcard = "\\*.*", strResult = filename + wildcard;

         char const * Result = strResult.c_str();

         TSearchRec searchRecord;
         int result = FindFirst(Result, faAnyFile ^ faDirectory, searchRecord);

         while(result == 0)
         {
           // ***** HERE'S THE WIRED ERROR *****

           if(IsAscii(caFileName)) // is it a text-file..?
           {
               FileBox->Items->Add(searchRecord.Name);
           }
           result = FindNext(searchRecord);
         }
         FindClose(searchRecord);
      }
      /*****************************************************************/
      else
      {
         if(IsAscii(caFileName))  // is it a text-file..?
         {
            FileShow(caFileName);
            SaveRegFiles();
            FileBox_Operations();
         }
         else
         {
            MessageBox(NULL, msg_BinaryFile.c_str(), msg_BinaryFileTitle.c_str(),
            MB_OK|MB_DEFBUTTON2|MB_ICONWARNING|MB_SETFOREGROUND|MB_TOPMOST);
         }
      }
      if(ilFilesCount > 1) txtCurrentFile->Text = caFileName;
    }
}
Technical Details
Message-ID: <42eebf1b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d5e6340a5f435d04,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 02 Aug 2005 02:32:27 +0200
From: Oren Halvani <xx@xx.com>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
X-Accept-Language: de-DE, de, en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Drag 'n Drop of a folder (with textfiles) into a ListBox - confuse
 effect...
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 84.176.88.90
Message-ID: <42eebf1b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1122942747 84.176.88.90 (1 Aug 2005 17:32:27 -0700)
Lines: 77
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail