//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Motivelib_F.h" #include "MainImage.h" #include "Main.h" #include "MainMenu.h" #include "FullView.h" #include "FileManager_F.h"//gabriel #include "VecDraw.h" //gabriel #include "UserColor_F.h"//gabriel #include "PenManager.h"//gabriel #include "Palette.h"//gabriel #include "Define.h" #include "LogData.h" #pragma package(smart_init) #pragma link "RzButton" #pragma link "ZipBuilder" #pragma link "ZipIntSFX" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_MOTIVE StringTable[0] #define IDS_NUMBER StringTable[1] #define IDS_READ StringTable[2] #define IDS_EXIT StringTable[3] #define IDS_DELETE StringTable[4] #define IDS_SAVE StringTable[5] #define IDS_NEW StringTable[6] #define IDS_FILE StringTable[7] #define IDS_DELALLINFO StringTable[8] TMotiveLibForm *MotiveLibForm; //--------------------------------------------------------------------------- // TMotiveLibForm //--------------------------------------------------------------------------- __fastcall TMotiveLibForm::TMotiveLibForm(TComponent* Owner) : TForm(Owner) { StringTable.Create(DirectoryItem, Language, "MotiveLib"); SetSmallFont(Font); Caption = IDS_MOTIVE; Label1->Caption = IDS_NUMBER; Button1->Caption = IDS_READ; // Button2->Caption = IDS_EXIT; MotiveDelete->Caption = IDS_DELETE; SpeedButton1->Hint = IDS_FILE; SpeedButton3->Hint = IDS_NEW; SpeedButton4->Hint = IDS_SAVE; MotivePath = String(InstallPath + "\\Motive"); if(!DirectoryExists(MotivePath)) CreateDir(MotivePath); //MotifItemList = new TList;//gabriel PreviewTag = new Graphics::TBitmap;//gabriel MotifNotSaved = false; DefaultSaving = false;//gabriel PreviewTag->PixelFormat = pf24bit; PreviewTag->Width = 80; PreviewTag->Height = 100; PreviewTag->Canvas->Brush->Color = clWhite; PreviewTag->Canvas->FillRect(Rect(0,0,80,100)); MotiveListView->DoubleBuffered = true; bLoadAutoSave = false; bAddFile = false; totalMotiveNum = 0; } //--------------------------------------------------------------------------- __fastcall TMotiveLibForm::~TMotiveLibForm() { delete PreviewTag; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::DefaultSave()//gabriel: when exit { BEGIN_LOG("::"); #ifdef TRIAL END_LOG; return; #endif //String path = FullPathName(InstallPath + "\\Motive", "Default.mtl"); //String tpath = FullPathName(InstallPath + "\\Motive", "tDefault.mtl"); String path = FullPathName(InstallPath + "\\Motive", "Default.mtl"); String tpath = FullPathName(InstallPath + "\\Motive", "tDefault.mtl"); if (totalMotiveNum == 0) { END_LOG; return; } DefaultSaving = true; //Àӽà ÆÄÀÏÀ» ¸¸µé¾î ÀúÀå ÇÒ ¶§ ¿¡·¯°¡ ¹ß»ýÇϸé ÀÌÀü ÆÄÀÏ·Î º¹±¸ µÇµµ·Ï ¼öÁ¤ by david 080827 if (FileExists(path)) { CopyFile(path.c_str(), tpath.c_str(), false); DeleteFile(path); } if (SaveMotifLibraryFile(MotivePath, String(L"Default.mtl"), gffNON, cmNone) != EC_NONE) { //ÀúÀå ¿À·ù°¡ ¹ß»ýÇÏ¸é ÆÄÀÏÀ» Áö¿ìµµ·Ï ¼öÁ¤ by david 080827 if (FileExists(path)) { DeleteFile(path); if (FileExists(tpath)) RenameFile(tpath, path);//RenameFile(tpath, path); } } if (FileExists(tpath)) DeleteFile(tpath); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::Button1Click(TObject *Sender) { //Read button: image Àбâ BEGIN_LOG("::"); if (!MainImageForm) { END_LOG; return; // by maxleo21c (05.06.09) } //TListItem *pItem = MotiveListView->Selected; TListItem *pItem = MotiveListView->Selected; if (!pItem) { END_LOG; return; } //String FileName = pItem->SubItems->Text; String FileName = pItem->SubItems->Text; if (FileName.IsEmpty()) { END_LOG; return; } int length = FileName.Length(); //Char *c_Filename = FileName.c_str(); Char *c_Filename = FileName.c_str(); //if (c_Filename[length - 2] == '\r' && c_Filename[length - 1] == '\n') if (c_Filename[length - 2] == L'\r' && c_Filename[length - 1] == L'\n') FileName = FileName.SubString(1, length - 2); //String ext = LowerCase(ExtractFileExt(FileName)); String ext = LowerCase(ExtractFileExt(FileName)); //ext = ext.SubString(1, 4); TGraphicFileFormat RealIndex = FindExtension(String(ext)); TSuper TempSuper = FullViewForm->Super; FullViewForm->Super = sNormal; // Merge¹æ½ÄÀ» ÀϹÝÇüÀ¸·Î Á¶Àý MainImageForm->InitMerge(FileName, RealIndex); FullViewForm->Super = TempSuper; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::FormKeyDown(WORD &Key, TShiftState Shift) { BEGIN_LOG("::"); switch (Key){ case VK_RETURN: Button1Click(this); break; case VK_ESCAPE: MainForm->MotiveLoadClick(this); break; case VK_DELETE: MotiveDeleteClick(this); break; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG("::"); MainForm->Motive1->Checked = false; Visible = false; if (FOnUpdateMenu) FOnUpdateMenu(Sender); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::Button2Click(TObject *Sender) { BEGIN_LOG("::"); MainForm->MotiveLoadClick(this); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::FormCreate(TObject *Sender) { BEGIN_LOG("::"); InitData(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::FormDestroy(TObject *Sender) { //Motive Æú´õ ¾È¿¡ ÆÄÀϰú Æú´õ¸¦ Áö¿î´Ù. SearchFilesInDirectory(Motive_Dir, 1); totalMotiveNum = 0; RemoveDirectory(Motive_Dir.c_str()); } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::InitData() { BEGIN_LOG("::"); /* Motive_Dir = AppData_Common_Dir + "YoungWoo\\"; if (!IsDirectoryExist(Motive_Dir.c_str())) { if (!CreateDirectory(Motive_Dir.c_str(), NULL)) { Application->MessageBox("The Directory can not be created.", "Warning", MB_OK);; return; } } Motive_Dir = Motive_Dir + "TexPro" + TexProVersion + "\\TexStylist\\Motive\\"; if (!IsDirectoryExist(Motive_Dir.c_str())) { if (!CreateDirectory(Motive_Dir.c_str(), NULL)) { Application->MessageBox("The Directory can not be created.", "Warning", MB_OK);; return; } } */ //MotivePath = InstallPath + "\\Motive"; Motive_Dir = MotivePath + String("\\Temp\\"); int cExecutingProgram = MainForm->GetCountExecutingProgram(); if (cExecutingProgram == 1) {//¿Ö count°¡ 2°¡ µÇ´ÂÁö ¸ð¸£°Ú´Ù. ÀÚ½ÅÀ» Æ÷ÇÔÇØ¼­ 2°¡ µÇ³ª? ´Ù½Ã 1·Î ¹Ù²Þ SearchFilesInDirectory(Motive_Dir, 5); } if (!DirectoryExists(Motive_Dir)) { if (!CreateDirectory(Motive_Dir.c_str(), NULL)) { Application->MessageBox(L"The Directory can not be created.", L"Warning", MB_OK);; END_LOG; return; } } //TextileÀÌ ¿©·¯°³ ½ÇÇàµÉ ¼ö Àֱ⠶§¹®¿¡ random¹øÈ£(ID)¸¦ °¡Áö°í ÀÖµµ·Ï ó¸®ÇÔ. //ÀÌ Æú´õ´Â Motive FormÀÌ DeleteµÉ ¶§ ÇÔ²² Áö¿öÁø´Ù. randomize(); int num; //String tDir; String tDir; while(1) { num = rand() % 1000; tDir = Motive_Dir + String("Motive"); if (!DirectoryExists(tDir + String(num))) { ID = IntToStr(num); tDir += String(ID); tDir += String("\\"); break; } } Motive_Dir = tDir; if (!DirectoryExists(Motive_Dir)) { if (!CreateDirectory(Motive_Dir.c_str(), NULL)) { Application->MessageBox(L"The Directory can not be created.", L"Warning", MB_OK);; END_LOG; return; } } //Æú´õ¿¡ ÆÄÀÏÀÌ Á¸Àç ÇÑ´Ù¸é Áö¿î´Ù. SearchFilesInDirectory(Motive_Dir, 1); totalMotiveNum = 0; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::MotiveDeleteClick(TObject *Sender) { BEGIN_LOG("::"); //TListItem *pItem = MotiveListView->Selected; TListItem *pItem = MotiveListView->Selected; if (!pItem) { END_LOG; return; } //String FileName = pItem->SubItems->Text; String FileName = pItem->SubItems->Text; if (FileName.IsEmpty()) { END_LOG; return; } int length = FileName.Length(); //Char *c_Filename = FileName.c_str(); Char *c_Filename = FileName.c_str(); //if (c_Filename[length - 2] == '\r' && c_Filename[length - 1] == '\n') if (c_Filename[length - 2] == L'\r' && c_Filename[length - 1] == L'\n') FileName = FileName.SubString(1, length - 2); DeleteFile(FileName); ReArrangeData(pItem->Index); InvalidateMotiveListView(); MotifNotSaved = true; END_LOG; } //--------------------------------------------------------------------------- /**Áß°£¿¡ data¸¦ Áö¿ì¸é ±× ÆÄÀÏ ¹øÈ£ ÀÌÈÄ ÆÄÀÏÀ̸§À» Áö¿î¹øÈ£ºÎÅÍ ¼ø¼­´ë·Î º¯°æÇÏ´Â ÇÔ¼ö Motive Æú´õ ¾È¿¡ ÆÄÀÏÀº Ç×»ó 0ºÎÅÍ ºüÁü¾øÀÌ ¼ø¼­´ë·Î À̸§À» °¡Áö°í ÀÖ¾î¾ß ÇÑ´Ù. */ void __fastcall TMotiveLibForm::ReArrangeData(int index) { BEGIN_LOG("::"); //String Filename, tFilename; //String dir, filename, ext, id; //TListItem *pItem = NULL; String Filename, tFilename; String dir, filename, ext, id; TListItem *pItem = NULL; int del_num, t_num; pItem = MotiveListView->Items->Item[index]; Filename = pItem->SubItems->Text; int length = Filename.Length(); //if (Filename.c_str()[length - 2] == '\r' && Filename.c_str()[length - 1] == '\n') if (Filename.c_str()[length - 2] == L'\r' && Filename.c_str()[length - 1] == L'\n') Filename = Filename.SubString(1, length - 2); //dir = ExtractFileDir(Filename); //filename = ExtractFileName(Filename); dir = ExtractFileDir(Filename); filename = ExtractFileName(Filename); //motive id = filename.SubString(7, filename.Length() - 6 - 4); //ext = ExtractFileExt(Filename); //del_num = id.ToInt(); del_num = String(id).ToInt(); //¸¶Áö¸· index°¡ Áö¿öÁ³À¸¸é º¯°æÇÒ Çʿ䰡 ¾ø´Ù. if (del_num + 1 == MotiveListView->Items->Count) { END_LOG; return; } int count = MotiveListView->Items->Count - del_num - 1; int current_num = del_num; for (int i = 0; i < count; i++, current_num++) { for (int j = 0; j < MotiveListView->Items->Count; j++) { pItem = MotiveListView->Items->Item[j]; Filename = pItem->SubItems->Text; length = Filename.Length(); //if (Filename.c_str()[length - 2] == '\r' && Filename.c_str()[length - 1] == '\n') if (Filename.c_str()[length - 2] == L'\r' && Filename.c_str()[length - 1] == L'\n') Filename = Filename.SubString(1, length - 2); //filename = ExtractFileName(Filename); filename = ExtractFileName(Filename); id = filename.SubString(7, filename.Length() - 6 - 4); //ext = ExtractFileExt(Filename); //t_num = id.ToInt(); ext = ExtractFileExt(Filename); t_num = String(id).ToInt(); if (current_num + 1 == t_num) { //tFilename = dir + "\\motive"; tFilename = dir + String("\\motive"); tFilename += String(current_num); tFilename += ext; //RenameFile(Filename, tFilename); RenameFile(Filename, tFilename); break; } } } END_LOG; } //--------------------------------------------------------------------------- /** ¸ðƼºêµéÀ» ÀúÀåÇÏ´Â ÇÔ¼ö */ void __fastcall TMotiveLibForm::MotiveSave() //gabriel { BEGIN_LOG("::"); if(!MainImageForm->WorkArea->Mask) { END_LOG; return; } if (!bLoadAutoSave) { //óÀ½ ½ÇÇàÇØ¼­ default¸¦ ·ÎµåÇÑ ÀûÀÌ ¾ø´Ù¸é loadÇÑ´Ù. LoadDefaultData(); if (totalMotiveNum == 0) totalMotiveNum = SearchFilesInDirectory(Motive_Dir, 2); } //String FileName, t_fileName, dir_name; String FileName, t_fileName, dir_name; TGraphicFileFormat ExtIndex; TCompressMethod cm = cmZLib; int bitsPerPixel = MainImageForm->iMainImage->uBitmap->BitsPerPixel; FileName = String("motive"); int motive_num = totalMotiveNum; while(1) { t_fileName = FileName + String(motive_num); if (bitsPerPixel == 8) { ExtIndex = gffTEX; t_fileName += String(".tex"); } else { ExtIndex = gffTFC; t_fileName += String(".tfc"); } dir_name = Motive_Dir + t_fileName; if (!FileExists(dir_name)) break; motive_num++; } FileName = t_fileName; MainForm->MoSave = true; MainImageForm->SaveToFile(Motive_Dir, FileName, ExtIndex, cm); MainForm->MoSave = false; InvalidateMotiveListView(); MotifNotSaved = true; END_LOG; } //--------------------------------------------------------------------------- /**Motive Æú´õ¿¡ ÆÄÀÏÀÌ Á¸Àç ÇÏÁö ¾ÊÀ¸¸é false¸¦ ¸®ÅÏÇÑ´Ù. add¸¦ ÇØ¾ß ÇÑ´Ù¸é true ¸®ÅÏ */ bool __fastcall TMotiveLibForm::MDeleteAll(bool bRepaint) { BEGIN_LOG("::"); if (!totalMotiveNum) { END_LOG; return false; } #ifndef LOCK_USB if (MotifNotSaved) { if (Application->MessageBox(IDS_DELALLINFO.c_str(), L"Information", MB_OKCANCEL) == 1) ; else { END_LOG; return true; } } #endif //Æú´õ¿¡ ÆÄÀÏÀÌ Á¸Àç ÇÑ´Ù¸é Áö¿î´Ù. SearchFilesInDirectory(Motive_Dir, 1); totalMotiveNum = 0; MotifNotSaved = false; if (bRepaint) InvalidateMotiveListView(); END_LOG; return false; } //---------------------------------------------------------------------------- void __fastcall TMotiveLibForm::FormShow(TObject *Sender) { BEGIN_LOG("::"); Width = 200; Height = 600; if (!bLoadAutoSave) { //óÀ½ ½ÇÇàÇØ¼­ default¸¦ ·ÎµåÇÑ ÀûÀÌ ¾ø´Ù¸é loadÇÑ´Ù. LoadDefaultData(); } InvalidateMotiveListView(); END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TMotiveLibForm::LoadDefaultData() { BEGIN_LOG("::"); TCursor cur; cur = Screen->Cursor; Screen->Cursor = crHourGlass; //String path, tpath; //path = FullPathName(InstallPath + "\\Motive", "Default.mtl"); //tpath = InstallPath + "\\Motive\\Error" + DateToStr(Date()) + ".mtl"; String path, tpath; path = FullPathName(String(InstallPath + "\\Motive"), String("Default.mtl")); tpath = String(InstallPath + "\\Motive\\Error" + DateToStr(Date()) + ".mtl"); //if (FileExists(path)) {//gabriel if (FileExists(path)) {//gabriel if (!MergeMotifLibraryFile(path, gffNON)) { //RenameFile(path, tpath); RenameFile(path, tpath); } } Screen->Cursor = cur; bLoadAutoSave = true; END_LOG; return true; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::FormResize(TObject *Sender) { BEGIN_LOG("::"); MotiveListView->Height = MotiveLibForm->ClientHeight - MotiveListView->Top - 7; MotiveListView->Width = MotiveLibForm->ClientWidth - 7;//MotiveLibForm->Width-7; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::RestrictSize(TMessage &Msg) { BEGIN_LOG("::"); ((POINT far *) Msg.LParam)[3].x = 200; ((POINT far *) Msg.LParam)[3].y = 400; ((POINT far *) Msg.LParam)[4].x = 900; ((POINT far *) Msg.LParam)[4].y = 900; TForm::Dispatch(&Msg); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::SpeedButton1Click(TObject *Sender) { //Load button BEGIN_LOG("::"); FileManagerForm = new TFileManagerForm(this); FileManagerForm->Extension = 7; FileManagerForm->FilterComboBox->Filter = "Texpro Motif Library File (*.mtl)|*.mtl"; FileManagerForm->OnRead = LoadMotifLibraryFile; FileManagerForm->OnFileName = MTLFileName; FileManagerForm->OnSave = SaveMotifLibraryFile; FileManagerForm->OnMerge = MergeMotifLibraryFile; FileManagerForm->ShowModal(); delete FileManagerForm; InvalidateMotiveListView(); END_LOG; } //--------------------------------------------------------------------------- //String __fastcall TMotiveLibForm::MTLFileName(String FileName, // TGraphicFileFormat ExtIndex) String __fastcall TMotiveLibForm::MTLFileName(String FileName, TGraphicFileFormat ExtIndex) { BEGIN_LOG("::"); //PChar s; PChar s; int FileNameLength, last1, last2, last3, last4; //Char FileIndex1, FileIndex2, FileIndex3, FileIndex4; Char FileIndex1, FileIndex2, FileIndex3, FileIndex4; //=============================================================== FileNameLength = FileName.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; FileIndex1 = L'.'; FileIndex2 = L'm'; FileIndex3 = L't'; FileIndex4 = L'l'; if((FileIndex1 == FileName[last1])&&(FileIndex2 == FileName[last2]) && (FileIndex3 == FileName[last3])&&(FileIndex4 == FileName[last4])){ s = L"PASS"; }else s=NULL; }else s=NULL; //=============================================================== // s = AnsiStrScan(FileName.c_str(), '.'); if (s==NULL) { //String fn; String fn; fn = FileName + String(".mtl"); END_LOG; return fn; } else { END_LOG; return FileName; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::SpeedButton3Click(TObject *Sender) { //New button BEGIN_LOG("::"); MDeleteAll(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TMotiveLibForm::SpeedButton4Click(TObject *Sender) { //Get a motif BEGIN_LOG("::"); if (!MainImageForm) { END_LOG; return; // by maxleo21c (05.06.09) } MotiveSave(); END_LOG; } //--------------------------------------------------------------------------- TPException __fastcall TMotiveLibForm::LoadMotifLibraryFile(TFMReadParameter rp, bool changeFileFormat) { BEGIN_LOG("::"); bAddFile = MDeleteAll(false); if (MergeMotifLibraryFile(FullPathName(rp.DirName, rp.FileName), (TGraphicFileFormat)0)) { InvalidateMotiveListView(); END_LOG; return EC_NONE; } else { return EC_MEMORY_LACK; } } //--------------------------------------------------------------------------- //bool __fastcall TMotiveLibForm::MergeMotifLibraryFile(String FileName, TGraphicFileFormat ExtIndex) bool __fastcall TMotiveLibForm::MergeMotifLibraryFile(String FileName, TGraphicFileFormat ExtIndex) { BEGIN_LOG("::"); HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; TEXPIAFILEHEADER tpfh; DWORD dwRead; //String LoadFilename, s_temp; String LoadFilename, s_temp; if (!FileExists(FileName)) { ec = EC_FILE_NOT_EXIST; SAVE_EXCEPTION(ec); goto fail; } if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(hFile, &tpfh, sizeof(tpfh), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (hFile) CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; if (tpfh.BitsPerPixel == 24 && tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number == 300) { if (!Load_OldVersion_MotiveFile(FileName, ExtIndex)) goto fail; } else { // 090527 upper version if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } try { FileName = FileName.SubString(1, FileName.Length() - 3); LoadFilename = FileName + String("zip"); s_temp = FileName + String("mtl"); //RenameFile(s_temp, LoadFilename); RenameFile(s_temp, LoadFilename); //¼±Åà ÀúÀåÀ» ÇÒ °æ¿ì motive3.tex¿Í °°ÀÌ ¼ø¼­¿Í »ó°ü¾ø´Â À̸§ÀÌ ÀúÀåµÇ±â ¶§¹®¿¡ //Ç×»ó rename¸¦ ÇÒ Çʿ䰡 ÀÖ´Ù. ±×·¡¼­ add¿Í »ó°ü¾øÀÌ Ç×»ó À̸§À» È®ÀÎ Çϵµ·Ï //º¯°æÇÏ¿´´Ù. by david 091006 RenameNCopyData(LoadFilename); //if (bAddFile) RenameNCopyData(LoadFilename); //else UnZipFile(LoadFilename, Motive_Dir); //RenameFile(LoadFilename, s_temp); RenameFile(LoadFilename, s_temp); } catch(...) { goto fail; } } MotifNotSaved = true; bAddFile = false; END_LOG; return true; fail: MotifNotSaved = false; bAddFile = false; if (hFile) CloseHandle(hFile); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; return false; } //--------------------------------------------------------------------------- /** ÆÄÀÏÀ» ¿­¾î ±âÁ¸ data¿¡ Ãß°¡ Çϱâ À§Çؼ­´Â ±âÁ¸ dataÀÇ ¹øÈ£¿¡ ¿¬°áÇÏ¿© À̸§ÀÌ ¸¸µé¾îÁ®¾ß ÇÑ´Ù. ±×·¡¼­ Àӽà Æú´õ¿¡ ¾ÐÃàÀ» Ç®°í Motive_Dir¿¡ ¼ýÀÚ¸¦ ¿¬°áÇØ¼­ Rename and CopyFileÀ» ÇÑ´Ù. */ //void __fastcall TMotiveLibForm::RenameNCopyData(String LoadFilename) void __fastcall TMotiveLibForm::RenameNCopyData(String LoadFilename) { BEGIN_LOG("::"); //String t_Dir = Motive_Dir + "Temp\\"; String t_Dir = Motive_Dir + String("Temp\\"); if (!DirectoryExists(t_Dir)) { if (!CreateDirectory(t_Dir.c_str(), NULL)) { Application->MessageBox(L"The Directory can not be created.", L"Warning", MB_OK);; END_LOG; return; } } UnZipFile(LoadFilename, t_Dir); SearchFilesInDirectory(t_Dir, 3); SearchFilesInDirectory(t_Dir, 1); RemoveDirectory(t_Dir.c_str()); END_LOG; } //--------------------------------------------------------------------------- /** Motive_Dir¿¡ ÀÖ´Â ¸ðµç ÆÄÀÏÀ» ¾ÐÃàÇÏ¿© ÇϳªÀÇ ÆÄÀÏ·Î ¸¸µç´Ù. Tag¸¦ À§ÇØ Tag BitmapÀ» ¸¸µç´Ù. ÆÄÀÏÀ̸§: tag.bmp zipÆÄÀÏÀ» mtl·Î È®ÀåÀÚ¸¦ º¯°æÇÑ´Ù. */ //TPException __fastcall TMotiveLibForm::SaveMotifLibraryFile(String DirName, String FileName, // TGraphicFileFormat ExtIndex, TCompressMethod cm) TPException __fastcall TMotiveLibForm::SaveMotifLibraryFile(String DirName, String FileName, TGraphicFileFormat ExtIndex, TCompressMethod cm) { BEGIN_LOG("::"); HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; int i; DWORD dwWrite; bool SelectedSave = MotiveListView->Selected; try { //String SaveFilename, s_temp; String SaveFilename, s_temp; s_temp = FileName.SubString(1, FileName.Length() - 3); s_temp += String("zip"); SaveFilename = FullPathName(DirName, s_temp); ZipBuilder1->ZipFileName = String(SaveFilename); ZipBuilder1->Verbose = true; if (!DefaultSaving && SelectedSave) { MakeSelectedFile(); } else { MakeTagFile(); ZipBuilder1->FSpecArgs->Add(String(Motive_Dir) + "*.*"); } ZipBuilder1->Add(); s_temp = FullPathName(DirName, FileName); if (FileExists(s_temp)) DeleteFile(s_temp); RenameFile(SaveFilename, s_temp); END_LOG; } catch(...) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } return ec; } //--------------------------------------------------------------------------- /** File Tag BitmapÀ» ¸¸µå´Â ÇÔ¼ö */ void __fastcall TMotiveLibForm::MakeTagFile(bool bSave) { BEGIN_LOG("::"); int count, widn, hein, x_ac, y_ac, n; x_ac = 0; y_ac = 0; //String filename = Motive_Dir; String filename = Motive_Dir; count = MotiveImageList->Count;//for preview tag n = ceil(sqrt(count)); if (!n) n = 1; widn = 80 / n; hein = 100 / n; TRect tagRect(0,0,80,100), destRect; Graphics::TBitmap *tempBitmap = new Graphics::TBitmap; TCanvas *srcCanvas; tempBitmap->Width = 80; tempBitmap->Height = 100; tempBitmap->PixelFormat = pf24bit; tempBitmap->Canvas->Brush->Color = clWhite; tempBitmap->Canvas->FillRect(tagRect); PreviewTag->Canvas->Brush->Color = clWhite; PreviewTag->Canvas->FillRect(tagRect); for (int i = 0; i < count; i++) { tempBitmap->Canvas->Brush->Color = clWhite; tempBitmap->Canvas->FillRect(tagRect); MotiveImageList->GetBitmap(i, tempBitmap); destRect = Rect(x_ac, y_ac, x_ac+widn, y_ac+hein);//draw preview tag PreviewTag->Canvas->CopyRect(destRect, tempBitmap->Canvas, tagRect); x_ac += widn; if (x_ac + widn > 80) { y_ac += hein; x_ac = 0; } } if (bSave) { filename += String("tag.bmp"); if (FileExists(filename)) DeleteFile(filename); PreviewTag->SaveToFile(String(filename)); } delete tempBitmap; END_LOG; } //--------------------------------------------------------------------------- /** ¼±ÅÃÇÑ ÆÄÀÏ ¸¸À» ÀúÀåÇÒ ¶§ »ç¿ëµÇ´Â ÇÔ¼öÀÌ´Ù. ¼±ÅÃÇÑ À̸§À» FSpecArgs->Add()ÇÑ´Ù. */ bool __fastcall TMotiveLibForm::MakeSelectedFile(bool bSave) { BEGIN_LOG("::"); int count, widn, hein, x_ac, y_ac, n; x_ac = 0; y_ac = 0; //String filename = Motive_Dir; String filename = Motive_Dir; count = ceil(sqrt(MotiveListView->SelCount)); //for preview tag n = ceil(sqrt(count)); if (!n) n = 1; widn = 80 / n; hein = 100 / n; TRect tagRect(0,0,80,100), destRect; Graphics::TBitmap *tempBitmap = new Graphics::TBitmap; TCanvas *srcCanvas; //String Filename; //Char *c_Filename; String Filename; Char *c_Filename; int length; tempBitmap->Width = 80; tempBitmap->Height = 100; tempBitmap->Canvas->Brush->Color = clWhite; tempBitmap->Canvas->FillRect(tagRect); PreviewTag->Canvas->Brush->Color = clWhite; PreviewTag->Canvas->FillRect(tagRect); TItemStates selected = TItemStates() << isSelected; TListItem *Item = MotiveListView->Selected; while (Item){ tempBitmap->Canvas->Brush->Color = clWhite; tempBitmap->Canvas->FillRect(tagRect); MotiveImageList->GetBitmap(Item->Index, tempBitmap); destRect = Rect(x_ac, y_ac, x_ac+widn, y_ac+hein);//draw preview tag PreviewTag->Canvas->CopyRect(destRect, tempBitmap->Canvas, tagRect); x_ac += widn; if (x_ac + widn > 80) { y_ac += hein; x_ac = 0; } Filename = Item->SubItems->Text; c_Filename = Filename.c_str(); length = Filename.Length(); if (c_Filename[length - 2] == L'\r' && c_Filename[length - 1] == L'\n') Filename = Filename.SubString(1, length - 2); ZipBuilder1->FSpecArgs->Add(String(Filename)); Item = dynamic_cast(MotiveListView->GetNextItem(Item, sdAll, selected)); } if (bSave) { filename += String("tag.bmp"); if (FileExists(filename)) DeleteFile(filename); PreviewTag->SaveToFile(String(filename)); ZipBuilder1->FSpecArgs->Add(String(filename)); } delete tempBitmap; END_LOG; return true; } //--------------------------------------------------------------------------- /** tPath: ¾ÐÃà ÆÄÀÏ À̸§, sPath: ¾ÐÃàÇÒ ÆÄÀÏÀÌ ÀÖ´Â Æú´õ À̸§ */ //bool __fastcall TMotiveLibForm::ZipFile(String sPath, String tPath) bool __fastcall TMotiveLibForm::ZipFile(String sPath, String tPath) { BEGIN_LOG("::"); ZipBuilder1->ZipFileName = String(tPath); ZipBuilder1->Verbose = true; ZipBuilder1->FSpecArgs->Add(String(sPath) + "*.*"); ZipBuilder1->Add(); END_LOG; return true; } //--------------------------------------------------------------------------- /** tPath: ¾ÐÃà ÆÄÀÏ À̸§, sPath: ¾ÐÃàÀ» Ç® Æú´õ À̸§ */ //bool __fastcall TMotiveLibForm::UnZipFile(String sPath, String tPath) bool __fastcall TMotiveLibForm::UnZipFile(String sPath, String tPath) { BEGIN_LOG("::"); ZipBuilder1->ZipFileName = String(sPath); ZipBuilder1->Verbose = true; ZipBuilder1->ExtrBaseDir = String(tPath); ZipBuilder1->Extract(); END_LOG; return true; } //--------------------------------------------------------------------------- /** zipÆÄÀÏ¿¡¼­ Filename À̸§ÀÇ ÆÄÀÏÀ» ¿­¾î bitmap¿¡ stream ¹æ½ÄÀ¸·Î copyÇÏ´Â ÇÔ¼ö */ //bool __fastcall TMotiveLibForm::UnZipStreamToBitmap(String sPath, String Filename, // Graphics::TBitmap *bitmap) bool __fastcall TMotiveLibForm::UnZipStreamToBitmap(String sPath, String Filename, Graphics::TBitmap *bitmap) { BEGIN_LOG("::"); ZipBuilder1->ZipFileName = String(sPath); ZipBuilder1->Verbose = true; TZipStream *ZipStream = NULL; ZipStream = ZipBuilder1->ExtractFileToStream(String(Filename)); if (!ZipStream) { END_LOG; return false; } ZipStream->Position = 0; bitmap->LoadFromStream(ZipStream); END_LOG; return true; } //--------------------------------------------------------------------------- /** ±âÁ¸ mtl ÆÄÀÏÀº tag_bitmap°ú ¿©·¯°³ÀÇ tex, tfc ÆÄÀÏÀ» ÇϳªÀÇ ÆÄÀÏ·Î °¡Áö°í ÀÖ¾ú´Ù. ±× ÆÄÀÏÀ» motive Æú´õ¿¡ °¢°¢ tex, tfc ÆÄÀÏ·Î ¸¸µé¾î ³Öµµ·Ï ó¸®ÇÏ´Â ÇÔ¼öÀÌ´Ù. bAddFileÀÏ °æ¿ì¿¡´Â TempÆú´õ¿¡ ÆÄÀÏÀ» »ý¼ºÇϰí Motive_Dir¿¡ ¼ø¼­´ë·Î renameÇØ¼­ copyFileÇÑ´Ù. */ //bool __fastcall TMotiveLibForm::Load_OldVersion_MotiveFile(String FileName, TGraphicFileFormat ExtIndex) bool __fastcall TMotiveLibForm::Load_OldVersion_MotiveFile(String FileName, TGraphicFileFormat ExtIndex) { BEGIN_LOG("::"); int i; DWORD dwRead; Byte buf[320] = {0}; bool bReturn = false; TEXPIAFILEHEADER tpfh; WORD MotifCount, tagBitCount; TPalette *tagpalette = NULL; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; TList *MotifItemList = new TList; //String t_Dir; String t_Dir; TPException check_ec = EC_NONE; TGraphicFileFormat gff = FindExtension(ExtractFileExt(FileName)); if (!FileExists(FileName)) { ec = EC_FILE_NOT_EXIST; SAVE_EXCEPTION(ec); goto fail; } if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(hFile, &tpfh, sizeof(tpfh), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(hFile, &(MotifCount), sizeof(MotifCount), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if ((tagpalette = new TPalette) == NULL) goto fail; if (tpfh.Version.Number < 302) tagpalette->LoadFromFileHandle(hFile,1); else tagpalette->LoadFromFileHandle(hFile,2); if (!ReadFile(hFile, &tagBitCount, sizeof(tagBitCount), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } for (i=0; i<100; i++) { if (!ReadFile(hFile, buf, 240, &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } memcpy(PreviewTag->ScanLine[i], buf, 240); } PMotifItem tempItem; for(i=0; ipPalette, tempItem->tpfh, tempItem->pBitmap, gff, false, tempItem->tag)) != EC_NONE) { delete tempItem; goto fail; } MotifItemList->Add(tempItem); } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; bReturn = true; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; if (tagpalette) delete tagpalette; tagpalette = NULL; //-----------------------------------------------------------------------// //Motive_Dir Àӽà Æú´õ¿¡ ÆÄÀÏÀ» ÀúÀåÇÏ´Â ÇÔ¼ö ---------------------------// if (bAddFile) { t_Dir = Motive_Dir + String("Temp\\"); if (!DirectoryExists(t_Dir)) { if (!CreateDirectory(t_Dir.c_str(), NULL)) { Application->MessageBox(L"The Directory can not be created.", L"Warning", MB_OK);; END_LOG; return false; } } } PMotifItem TempItem; RECT Range; for (i = 0; i < MotifItemList->Count; i++) { TempItem = (PMotifItem) MotifItemList->Items[i]; Range.left=0; Range.top=0; Range.right=TempItem->pBitmap->Width; Range.bottom=TempItem->pBitmap->Height; if (bAddFile) FileName = t_Dir + String("motive")+ String(i); else FileName = Motive_Dir + String("motive")+ String(i); if (TempItem->tpfh.BitsPerPixel == 8) FileName += String(".tex"); else FileName += String(".tfc"); if ((hFile = CreateFile(FileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); CloseHandle(hFile); continue; } if (!SaveToTexpiaFile(hFile, TempItem->pPalette, TempItem->tpfh, TempItem->tag, TempItem->pBitmap, &Range)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; } //------------------------------------------------------- for (int i = 0;i< MotifItemList->Count;) { tempItem = (PMotifItem) MotifItemList->Items[0]; delete tempItem; MotifItemList->Delete(0); } delete MotifItemList; if (bAddFile) { SearchFilesInDirectory(t_Dir, 3); SearchFilesInDirectory(t_Dir, 1); RemoveDirectory(t_Dir.c_str()); } if (check_ec == EC_FILE_NOT_OPEN_NEWERVERSION) { if (!bReturn) EXCEPTION_MESSAGE_OK(check_ec); } else { if (!bReturn) EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } END_LOG; return bReturn; } //--------------------------------------------------------------------------- /** kind: 0 - MotiveImageList¿¡ Preview image Ãß°¡ kind: 1 - Æú´õ ¾È¿¡ ¸ðµç ÆÄÀÏ »èÁ¦ kind: 2 - Æú´õ ¾È¿¡ Motive ÆÄÀÏÀÇ °³¼ö ¸®ÅÏ kind: 3 - Àӽà Æú´õ¿¡¼­ Motive_Dir·Î ÆÄÀÏ Ãß°¡ kind: 4 - stringList Æú´õ¾È¿¡ ÆÄÀÏ ¸ðµÎ À̸§À» ³Ö´Â´Ù. kind: 5 - Æú´õ ¾È¿¡ ¸ðµç Æú´õ, ÆÄÀÏ ¸ðµÎ »èÁ¦ */ //int __fastcall TMotiveLibForm::SearchFilesInDirectory(String path, int kind, TStringList* stringList) int __fastcall TMotiveLibForm::SearchFilesInDirectory(String path, int kind, TStringList* stringList) { BEGIN_LOG(""); //String dir, fn, ext, n_fn; String dir, fn, ext, n_fn; HANDLE hSrch; //WIN32_FIND_DATA wfd; WIN32_FIND_DATAW wfd; bool bResult = true; int motiveCount = 0; int length = path.Length(); if (path.c_str()[length-1] != L'\\') path += String("\\"); dir = path + String("*.*"); hSrch = FindFirstFile(dir.c_str(), &wfd); while(bResult) { fn = String(wfd.cFileName); if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (kind == 5) RemoveDirectory((path+fn).c_str()); }//directory else { // file switch(kind) { case 0: // MotiveImageList¿¡ Preview image Ãß°¡ if (fn.SubString(1, 6) == String("motive")) InitLargeData(path+fn); break; case 1: // Motive Æú´õ¾È¿¡ ÆÄÀÏ »èÁ¦ case 5: // Motive Æú´õ¾È¿¡ ÆÄÀÏ »èÁ¦ DeleteFile(path+fn); break; case 2: // Æú´õ¾È¿¡ motive ÆÄÀÏÀÇ °³¼ö¸¦ ¸®ÅÏ if (fn.SubString(1, 6) == String("motive")) motiveCount++; break; case 3: // Àӽà Æú´õ¿¡¼­ Motive_Dir·Î ÆÄÀÏ Ãß°¡ if (fn.SubString(1, 6) != String("motive")) break; ext = ExtractFileExt(fn); n_fn = Motive_Dir + String("motive"); n_fn += String(totalMotiveNum + motiveCount); n_fn += ext; CopyFile((path+fn).c_str(), n_fn.c_str(), false); motiveCount++; break; case 4: if (!stringList) break; if (fn.SubString(1, 6) != String("motive")) break; stringList->Add(fn); break; } } bResult = FindNextFile(hSrch, &wfd); } FindClose(hSrch); END_LOG; return motiveCount; } //--------------------------------------------------------------------------- /** Tag Image¸¦ ¸¸µå´Â ÇÔ¼ö */ //void __fastcall TMotiveLibForm::InitLargeData(String Filename) void __fastcall TMotiveLibForm::InitLargeData(String Filename) { BEGIN_LOG("::"); TFileInfor *fi = NULL; TTexVersion *ver = NULL; TListItem *pItem = NULL; Graphics::TBitmap *newer_ver_icon = NULL; HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; TEXPIAFILEHEADER tpfh; DWORD dwRead; Word useColor; TGraphicFileFormat gff = FindExtension(ExtractFileExt(Filename)); int ColorCnt = 8; int wid, hei, dpi; String strwid, strhei; if ((fi = new TFileInfor)==NULL) goto fail; if ((fi->Bitmap = new Graphics::TBitmap)==NULL) goto fail; if ((hFile = CreateFile(Filename.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } ver = new TTexVersion; gff = FindExtension(ExtractFileExt(Filename)); if ((ec = LoadFromTexpiaTag(hFile, fi, gff, ver)) != EC_NONE){ if (ec == EC_FILE_NOT_OPEN_NEWERVERSION){ if ((newer_ver_icon = new Graphics::TBitmap) == NULL) goto fail; newer_ver_icon->Width = 80; newer_ver_icon->Height = 100; UnabledImageList->GetBitmap(1, newer_ver_icon); fi->Bitmap->PixelFormat = pf24bit; fi->Bitmap->Width = 80; fi->Bitmap->Height = 100; if (fi->Bitmap->Empty) goto fail; fi->Bitmap->Canvas->Brush->Color = clWhite; fi->Bitmap->Canvas->FillRect(Rect(0, 0, 80, 100)); SetStretchBltMode(fi->Bitmap->Canvas->Handle, COLORONCOLOR); StretchBlt(fi->Bitmap->Canvas->Handle, 0, 0, 80, 100, newer_ver_icon->Canvas->Handle, 0, 0, 80, 100, SRCCOPY); if(newer_ver_icon != NULL) { delete newer_ver_icon; newer_ver_icon = NULL; } } else goto fail; } if (ver) delete ver; ver = NULL; MotiveImageList->Add(fi->Bitmap, NULL); pItem = MotiveListView->Items->Add(); if (hFile == INVALID_HANDLE_VALUE) { if ((hFile = CreateFile(Filename.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } } if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN)==0xFFFFFFFF) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(hFile, &tpfh, sizeof(TEXPIAFILEHEADER), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } wid = tpfh.CanvasInfor.Width; hei = tpfh.CanvasInfor.Height; if(MainImageForm){ dpi = MainImageForm->CanvasInfor.DotsPerInch; switch (MainImageForm->CurrentUnit) { case uDot : strwid = String(wid); strhei = String(hei); break; case uInch : strwid = Format("%.2f", OPENARRAY(TVarRec, ((double)wid / dpi))); strhei = Format("%.2f", OPENARRAY(TVarRec, ((double)hei / dpi))); break; case uCm : strwid = Format("%.2f", OPENARRAY(TVarRec, ((double)wid / dpi * 2.54))); strhei = Format("%.2f", OPENARRAY(TVarRec, ((double)hei / dpi * 2.54))); break; } } //colorCnt´Â »ç¿ëµÇ´Â Ä÷¯ÀÇ °³¼öÀÌ´Ù. if (!ReadFile(hFile, &useColor, sizeof(Word), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } ColorCnt = useColor - 1; if (fi->Bitmap->PixelFormat == pf8bit) { pItem->Caption = String(strwid + "X" + strhei + " (" + ColorCnt + ")"); }else { pItem->Caption = String(strwid + "X" + strhei + " (F)"); } pItem->SubItems->Add(Filename); if(fi) delete fi; fi = NULL; if (hFile) CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; pItem->ImageIndex = totalMotiveNum; totalMotiveNum += 1; END_LOG; return; fail: if (ver) delete ver; ver = NULL; if(fi) delete fi; fi = NULL; if (hFile) CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; END_LOG; } //--------------------------------------------------------------------------- /** RepaintÇÏ´Â ÇÔ¼ö */ void __fastcall TMotiveLibForm::InvalidateMotiveListView() { BEGIN_LOG("::"); totalMotiveNum = 0; if (MotiveListView->Items->Count) MotiveListView->Items->Clear(); if (MotiveImageList->Count) MotiveImageList->Clear(); MotiveListView->Items->BeginUpdate(); //SearchFilesInDirectory(Motive_Dir); //ÆÄÀÏ¿¡¼­ ÀÐ¾î ¿Â ¼ø¼­´ë·Î add Çϸé ÀÔ·ÂÇÑ ¼ø¼­´ë·Î È­¸é¿¡ º¸ÀÌÁö ¾Ê°Ô µÈ´Ù. //motive10ÀÌ Á¸ÀçÇϸé motive1 ´ÙÀ½¿¡ 󸮵DZ⠶§¹®ÀÌ´Ù. //µû¶ó¼­ ¾Æ·¡¿Í °°ÀÌ ±âº» Á¤·Ä·Î ¼ø¼­´ë·Î È­¸é¿¡ º¸À̵µ·Ï ó¸®Çß´Ù. //Æú´õ ¾È¿¡´Â Ç×»ó ¼ø¼­´ë·Î ÆÄÀÏÀÌ Á¸ÀçÇϱ⠶§¹®¿¡ ¾Æ·¡¿Í °°Àº ¹æ½ÄÀÌ °¡´ÉÇØÁø´Ù. //TStringList *stringList = new TStringList; //String t_sort_string; TStringList *stringList = new TStringList; String t_sort_string; SearchFilesInDirectory(Motive_Dir, 4, stringList); for (int i = 0; i < stringList->Count; i++) { t_sort_string = String("motive"); t_sort_string += String(i); t_sort_string += String("."); for (int j = 0; j < stringList->Count; j++) { if ((stringList->Strings[j]).Pos(t_sort_string) > 0) { InitLargeData(Motive_Dir+stringList->Strings[j]); break; } } } delete stringList; if (MotiveListView->Items->Count != totalMotiveNum) { totalMotiveNum = MotiveListView->Items->Count; } MotiveListView->Items->EndUpdate(); Label1->Caption = IDS_NUMBER + IntToStr(totalMotiveNum); MotiveListView->Invalidate(); END_LOG; } //---------------------------------------------------------------------------