님이 하고자 하는 내용의 대부분은 아래에 구현되어있습니다.
만들고 보니 findclose 를 빼먹었구요.
알아서 넣고 변형해보세요.
그리고 책을 처음부터 다시 정독하세요.
void TForm1::GetImageFileList(String Path , TStringList *filelst)
{
TSearchRec sr;
if(FindFirst(Path, faAnyFile, sr) == 0)
{
do
{
if (ExtractFileExt(sr.Name) == ".bmp" || ExtractFileExt(sr.Name) == ".jpg")
{
filelst->Add(ExtractFilePath(Path)+ "\\" + sr.Name);
}
}
while(FindNext(sr) == 0);
}
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TStringList *lst = new TStringList ;
GetImageFileList("C:\\temp\\*.*", lst);
for (int i = 0; i < lst->Count; i++)
{
TImage *newImg = new TImage(this);
newImg->Parent = this;
newImg->Left = i * 100 ;
newImg->Top = 200 ;
newImg->Stretch = true;
newImg->Width = 100;
newImg->Height = 100;
newImg->Picture->LoadFromFile(lst->Strings[i]);
}
delete lst;
}
//---------------------------------------------------------------------------
량이 님이 쓰신 글 :
: if(FindFirst(path, faAnyFile, sr) == 0)
: {
: do
: {
: //불러온 파일을 리스트에 저장
: (sr.Attr & iAttributes) == sr.Attr;
: Image[n+1] = new TImage(this);
: list->i = sr.Name;
: tlist->Add(list);
:
: //저장된 리스트의 파일을 이미지로 출력하기
: list = (List*) tlist->Items[n];
: //저장된 리스트의 파일을 텍스트로 출력
: word[n]->Text = list->i;
:
: pImg[n]->Picture->LoadFromFile(LMDDirDlg1->Path + "\\" + list->i);
:
: n++;
:
: }
: while(FindNext(sr) == 0);
: }
: FindClose(sr);
:
: //bmp파일 불러오기
: if(FindFirst(path2, faAnyFile, sr) == 0)
: {
: do
: {
:
: //불러온 파일을 리스트에 저장
: (sr.Attr & iAttributes) == sr.Attr;
: //Image[n+1] = new TImage(this);
: list->i = sr.Name;
: tlist->Add(list);
: //저장된 리스트의 파일을 이미지로 출력하기
: list = (List*) tlist->Items[n];
: //저장된 리스트의 파일을 텍스트로 출력
: word[n]->Text = list->i;
:
: pImg[n]->Picture->LoadFromFile(LMDDirDlg1->Path + "\\" + list->i);
: n++;
:
: }
: while(FindNext(sr) == 0);
: }
: FindClose(sr);
: }
: //폴더 경로를 Edit에 표시
: Edit1->Text = LMDDirDlg1->Path;
:
:
:
:
: -----------------------------------------------------
: {
: //이미지파일과 이미지정보 연결
: int DataSize = sizeof(S_CaptureParam);
: pParam = new S_CaptureParam();
: String information;
:
: Form1->list = (List*)Form1->tlist->Items[Form1->g-1];
: information = Form1->LMDDirDlg1->Path + "\\" + Form1->list->i;
: int data = FileOpen(information,fmOpenReadWrite);
:
: if(data != 0)
: {
: FileSeek(data, -DataSize, 2);
: FileRead(data, pParam, DataSize);
: FileClose(data);
: }
:
: 첫번째 폼에서 리스트로 전부다 받아들였는데 두번째 소스
:
: information = Form1->LMDDirDlg1->Path + "\\" + Form1->list->i;
: 이부분에서 i값이 리스트로 불러들여온 값들중에서 맨 마지막값만 자꾸 받아서 출력시켜요 ㅠ.ㅠ..
:
: 별짓을 다해봤는데 저녀석이 확실한 문제인건 알아냈는데 해결할 방법을 못찾겠어요..
: 조금만 저에게 힘을주세요 ...
|