Article View: borland.public.cppbuilder.nativeapi
Article #5676Re: Drag 'n Drop of a folder (with textfiles) into a ListBox - confuse effect...
From: Oren Halvani
Date: Tue, 02 Aug 2005 17:49
Date: Tue, 02 Aug 2005 17:49
137 lines
4966 bytes
4966 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im
Newsbeitrag news:42efa79a$1@newsgroups.borland.com...
> Well, then you need to show 100% of your processing code. You did not
show
> all of it, and there is nothing inheritantly wrong with the code you did
> show, so the problem has to be in the code that you did not show.
>
> > here's the complete code..
>
> That is not the complete code. You did not show what IsAscii(),
FileShow(),
> SaveRegFiles(), or FileBox_Operations() actually do. For that matter, you
> never said whether you tried to actually debug the code to see if it hangs
> anywhere.
here you go Remy, the code of all functions that i'm calling...
// IsAscii() // by the way, this function fails on many TEXT files...
/********************************************************/
typedef Set<BYTE, 0, 255> TByteSet;
bool __fastcall TfrmMainUnit::IsAscii(const AnsiString &NomeFile)
{
const int SETT = 2048;
bool a, err;
int F, TotSize, IncSize, ReadSize;
BYTE c[SETT]; TByteSet OkChars = TByteSet() << 9 << 10 << 13 << 26;
if(!FileExists(NomeFile)) return false;
F = FileOpen(NomeFile, fmOpenRead | fmShareDenyWrite);
if( F == -1 ) return false;
TotSize = FileSeek(F, 0, 2);
err = (TotSize < 0);
FileSeek(F, 0, 0);
if(err == false)
{
IncSize = 0;
a = true;
while((IncSize < TotSize) && (a == true))
{
ReadSize = SETT;
if((IncSize + ReadSize) > TotSize) ReadSize = (TotSize - IncSize);
ReadSize = FileRead(F, c, ReadSize);
err = (ReadSize < 1);
if( err == true ) break;
IncSize += ReadSize;
for(int i = 0; (i < ReadSize) && (a == true); ++i)
{
if( (c[i] < 32) && !OkChars.Contains(c[i])) a = false;
}
}
}
FileClose(F);
return ((a == true) && (err == false));
}
// FileShow()
/********************************************************/
void __fastcall TfrmMainUnit::FileShow(String file)
{
if(IsAscii(file))
{
rePreview->Clear();
Screen->Cursor = crHourGlass;
FileBox->Items->Add(file); // zur FileBox hinzuf�gen...
rePreview->Lines->LoadFromFile(file); // Datei laden...
txtCurrentFile->Text = file; // als aktuelle Datei
setzen...
/************** Captions anzeigen ... ***************/
lblFiltered_Records->Caption = lbl_FilteredRecord;
lblDuration_Seconds->Caption = 0;
lblWanted_Records->Caption = Thousand(rePreview->Lines->Count);
Caption = "ShowRecord 1.31 - " + ExtractFileName(txtCurrentFile->Text);
FileBox_Operations();
Screen->Cursor = crDefault;
}
FileBox_CheckCount();
}
// SaveRegFiles()
/********************************************************/
void __fastcall TfrmMainUnit::SaveRegFiles()
{
TRegistry* reg = new TRegistry;
try
{
if(reg->KeyExists(MRUFilesKey)) reg->DeleteKey(MRUFilesKey);
reg->OpenKey(frmMainUnit->MRUFilesKey, true);
int lines = FileBox->Items->Count;
for(int x = 0; x < lines; ++x)
{
String str = FileBox->Items->Strings[x];
if(FileExists(str)) reg->WriteString("File_" + IntToStr(x), str);
}
reg->CloseKey();
reg->OpenKey(frmMainUnit->RegistryKey, true);
if(txtCurrentFile->Text != "") reg->WriteString("LastFile",
txtCurrentFile->Text);
else reg->DeleteValue("LastFile");
reg->CloseKey();
}
__finally {delete reg;}
}
// FileBox_Operations() // these 3 functions are working 100% correct
/********************************************************/
void __fastcall TfrmMainUnit::FileBox_Operations()
{
ListBox_ScrolHorizontal(FileBox);
Sort_StringLines(FileBox);
Kill_DoubleItems(FileBox);
}
Technical Details
Message-ID:
<42efb22a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!cyclone.bc.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42eebf1b@newsgroups.borland.com> <42eec485$1@newsgroups.borland.com> <42ef29dc$1@newsgroups.borland.com> <42efa79a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d5e6340a5f435d04 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII Reply-To: "Oren Halvani" <NoSpam@fdtd.com> From: "Oren Halvani" <NoSpam@fdtd.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <42eebf1b@newsgroups.borland.com> <42eec485$1@newsgroups.borland.com> <42ef29dc$1@newsgroups.borland.com> <42efa79a$1@newsgroups.borland.com> Subject: Re: Drag 'n Drop of a folder (with textfiles) into a ListBox - confuse effect... Date: Tue, 2 Aug 2005 19:49:32 +0200 Lines: 140 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 84.176.52.2 Message-ID: <42efb22a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1123004970 84.176.52.2 (2 Aug 2005 10:49:30 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!cyclone.bc.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail