|
//---------- Main Form 에서의 조작 --------------
void __fastcall TForm1::OpenFileBtnMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
LoadLogForm->ShowModal(); // LoadLogForm을 불러냄
}
//--------- (SUB Form)두번째 LoadLogForm ------------------------
void __fastcall TLoadLogForm::FormShow(TObject *Sender)
{
char data[ 64];
short cnt;
HANDLE S_hcom;
if( ListBox1->ItemIndex != ( -1)){
ListBox1->Clear();
}
S_hcom = CreateFile( S_full_path, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
// ReadFile()를 다른 .CPP 작성해서 공유
do{
cnt = LogFile_LineInput( S_hcom, data, 64); //지정파일에서 데이타 불러옴
if ( cnt > 0){
ListBox1->Items->Add( data);
ListBox1->Selected[ ListBox1->Items->Count-1] = TRUE;
ListBox1->SetFocus();
}
}while( cnt != 0);
CloseHandle( S_hcom);
}
//----------- OpenDialog1를 불러냄 --------
void __fastcall TLoadLogForm::SearchBtnMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
short cnt;
long len;
char *buf;
if( OpenDialog1->Execute() == TRUE) {
Timer1->Enabled = FALSE;
TStringList *list = new TStringList;
if( ListBox1->ItemIndex != ( -1)){
ListBox1->Clear();
}
list->LoadFromFile( OpenDialog1->FileName);
for( cnt = 0; cnt < list->Count; cnt++){
ListBox1->Items->Append( list->Strings[ cnt ]);
}
ListBox1->Selected[ ListBox1->Items->Count - 1] = TRUE;
ListBox1->SetFocus();
delete list;
}
}
FormShow()에서 CreateFile() -> OpenFile() -> CloseHandle() 로 ListBox에 데이타( Default Data임)를 나열해놓고,
OpenDialog1->Execute()로 선택한 다른 데이타를 ListBox에 나열을 했습니다..
그런데 FormClose()해서 다시 FormShow()했는데 Default Data 핸들이 "FFFFFFFF"되어 Data를 불러올수가 없습니다..
파일오픈했으면 반드시 파일을 닫는 식을로 했는데...
다시 파일 오픈하니깐 핸들이 "FFFFFFFF"로 되어 열수가 없습니다...
무슨이유인지 도대체 알수가 없습니다...
아시는 분 설명이라도 좋으니 알려주세요...
|