//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "Define.h" #include "Exception.h" #include "ShortCutsForm.h" #include "ShortcutDefine.h" #include "MainMenu.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzTabs" #pragma link "RzCmboBx" #pragma resource "*.dfm" TShortCutForm *ShortCutForm; //--------------------------------------------------------------------------- #define IDS_SC_MSGBOX1 StringTable[2] //Exist it now #define IDS_SC_MSGBOX2 StringTable[3] //Do you want to overwrite? #define IDS_SC_MSGBOX3 StringTable[4] //Default File can't be changed! #define IDS_SC_MSGBOX4 StringTable[5] //Can't find the file! #define IDS_SC_MSGBOX5 StringTable[6] //Do you want to delete? #define IDS_SC_MSGBOX6 StringTable[7] //Not exist the file!! Can't Delete! //--------------------------------------------------------------------------- __fastcall TShortCutForm::TShortCutForm(TComponent* Owner) : TForm(Owner) { TRegIniFile *RegIniFile; String DirectoryBin; StringTable.Create(DirectoryItem, Language, "ShortcutsForm"); CaptionStringTable.Create(DirectoryItem, Language, "Shortcuts_Caption"); FileStringTable.Create(DirectoryItem, Language, "Shortcuts_File"); EditStringTable.Create(DirectoryItem, Language, "Shortcuts_Edit"); NomalStringTable.Create(DirectoryItem, Language, "Shortcuts_Normal"); MenuOpenStringTable.Create(DirectoryItem, Language, "Shortcuts_MenuOpen"); WindowStringTable.Create(DirectoryItem, Language, "Shortcuts_Window"); MoveCopyStringTable.Create(DirectoryItem, Language, "Shortcuts_MoveCopy"); ColorChangeStringTable.Create(DirectoryItem, Language, "Shortcuts_ColorChange"); ClearStringTable.Create(DirectoryItem, Language, "Shortcuts_Clear"); GroupingStringTable.Create(DirectoryItem, Language, "Shortcuts_Grouping"); RepeatStringTable.Create(DirectoryItem, Language, "Shortcuts_Repeat"); DrawStringTable.Create(DirectoryItem, Language, "Shortcuts_Draw"); ProportionStringTable.Create(DirectoryItem, Language, "Shortcuts_Proportion"); FillStringTable.Create(DirectoryItem, Language, "Shortcuts_Fill"); VectorStringTable.Create(DirectoryItem, Language, "Shortcuts_Vector"); EtcStringTable.Create(DirectoryItem, Language, "Shortcuts_Etc"); #ifndef LOCK_USB RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); DirectoryBin = RegIniFile->ReadString("Directory", "Bin", DefaultDir + "\\Bin"); delete RegIniFile; #else DirectoryBin = DefaultDir + "\\Bin"; #endif DirectoryName = String(DirectoryBin + "\\Textile\\Shortcuts\\"); downAlt=false, downShift=false, downCtrl=false; downDone=false; StringForShortCut=""; LoadDataToArrary(); LoadStringByNumber(); } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::FormCreate(TObject *Sender) { Caption = StringTable[0]; Label1->Caption = StringTable[1]; //TabControl1->Tabs->Clear(); for (int i=0; i<3; i++){ TabControl1->Tabs->Items[i]->Caption = CaptionStringTable[i]; } //TabControl2->Tabs->Clear(); for (int i=0; i<3; i++){ TabControl2->Tabs->Items[i]->Caption = CaptionStringTable[i+3]; } //TabControl3->Tabs->Clear(); for (int i=0; i<11; i++){ TabControl3->Tabs->Items[i]->Caption = CaptionStringTable[i+6]; } TabControl1->TabIndex = 0; TabControl2->Visible = true; TabControl3->Visible = false; TabControl2->BringToFront(); TabControl2->TabIndex = 0; MainValueListEditor->BringToFront(); int comboIndex = 0; TIniFile *IniFile=NULL; IniFile = new TIniFile(AppDataItem + "\\ShortCuts.ini"); if (IniFile) { comboIndex = IniFile->ReadInteger("ShortCuts", "Index", 0); delete IniFile; } FindShortCutFiles(); if (FileComboBox->Items->Count > comboIndex) FileComboBox->ItemIndex = comboIndex; else FileComboBox->ItemIndex = 0; /* CopyFileW((DirectoryName + WideString("ShortCuts.lt")).c_bstr(), (DirectoryName + WideString("BackupShortCuts.lt")).c_bstr(), false); */ } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::TabControl1Change(TObject *Sender) { if (TabControl1->TabIndex == 0) { TabControl2->Visible = true; TabControl3->Visible = false; TabControl2->BringToFront(); TabControl2->TabIndex = 0; MainValueListEditor->BringToFront(); } else if (TabControl1->TabIndex == 1) { TabControl2->Visible = false; TabControl3->Visible = true; TabControl3->BringToFront(); TabControl3->TabIndex = 0; MenuOpenValueListEditor->BringToFront(); } else { TabControl2->Visible = false; TabControl3->Visible = false; EtcValueListEditor->BringToFront(); } } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::TabControl2Change(TObject *Sender) { if (TabControl2->TabIndex == 0) { MainValueListEditor->BringToFront(); } else if (TabControl2->TabIndex == 1) { EditValueListEditor->BringToFront(); } else { NomalValueListEditor->BringToFront(); } } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::MainValueListEditorKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { String cells; TValueListEditor *tValueEditor; tValueEditor = (TValueListEditor *)Sender; cells=tValueEditor->Cells[tValueEditor->Col][tValueEditor->Row]; ShortcutKey=0; if (Key == VK_DELETE || Key == VK_BACK) { if (_tcscmp(tValueEditor->Name.c_str(), L"EditValueListEditor")==0) return; if (_tcscmp(tValueEditor->Name.c_str(), L"MainValueListEditor")==0) return; if (_tcscmp(tValueEditor->Name.c_str(), L"EtcValueListEditor")==0) return; if (_tcscmp(tValueEditor->Name.c_str(), L"NomalValueListEditor")==0 && tValueEditor->Row >= 3) { return; } StringForShortCut=""; ShortcutKey = 0; downAlt=false, downShift=false, downCtrl=false; downDone=true; } else if (Key == VK_ESCAPE) { // ESC == 27 } else if (cells.Length()>0 || downDone) { downAlt=false, downShift=false, downCtrl=false; downDone=false; return; } if (Shift.Contains(ssShift) && !downShift && !downDone) { downShift=true; } else if (Shift.Contains(ssCtrl) && !downCtrl && !downDone) { downCtrl=true; } else if (Shift.Contains(ssAlt) && !downAlt && !downDone) { downAlt=true; } else if ('0' <= Key && Key <= '9' && !downDone) { // 0 ~ 9 StringForShortCut = IntToStr(Key-'0'); ShortcutKey = (int)Key; downDone=true; } else if ('A' <= Key && Key <= 'Z' && !downDone) { // A ~ Z StringForShortCut = (Char)Key; ShortcutKey = (int)Key; downDone=true; } else if (VK_F1 <= Key && Key <= VK_F12 && !downDone) { // F1 ~ F12 StringForShortCut = ("F" + IntToStr(Key-111)); ShortcutKey = (int)Key; downDone=true; } else if (Key == 189) { // _ : 189 StringForShortCut = "\"-\""; ShortcutKey = (int)Key; downDone=true; } else if (Key == 187) { // = : 187 StringForShortCut = "\"+\""; ShortcutKey = (int)Key; downDone=true; } else if (Key == VK_ESCAPE) { // Esc StringForShortCut = "Esc"; ShortcutKey = (int)Key; downDone=true; } } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::MainValueListEditorKeyPress(TObject *Sender, wchar_t &Key) { // } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::MainValueListEditorKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { String temp; int *tArray, checkNum=0; TValueListEditor *tValueEditor; tValueEditor = (TValueListEditor *)Sender; if (downDone) { if (downAlt) { temp += "Alt + "; checkNum += 100000; } if (downShift) { temp += "Shift + "; checkNum += 10000; } if (downCtrl) { temp += "Ctrl + "; checkNum += 1000; } if ((tArray = ArraryName(tValueEditor))!=NULL) { checkNum += ShortcutKey; if (checkNum != 0 && CheckAnyExist(checkNum)) { tArray[tValueEditor->Row-1]=0; Application->MessageBox(IDS_SC_MSGBOX1.c_str(), L"Warning", MB_ICONINFORMATION); } else { tArray[tValueEditor->Row-1]=checkNum; tValueEditor->Cells[tValueEditor->Col][tValueEditor->Row] = temp+StringForShortCut; } } StringForShortCut=""; } downAlt=false, downShift=false, downCtrl=false; downDone=false; ShortcutKey=0; } //--------------------------------------------------------------------------- int* __fastcall TShortCutForm::ArraryName(TValueListEditor *tValueEditor) { if (_tcscmp(tValueEditor->Name.c_str(),L"MainValueListEditor")==0) return MainValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"EditValueListEditor")==0) return EditValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"NomalValueListEditor")==0) return NomalValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"MenuOpenValueListEditor")==0) return MenuOpenValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"WindowValueListEditor")==0) return WindowValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"MoveValueListEditor")==0) return MoveValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"ColorChangeValueListEditor")==0) return ColorChangeValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"ClearValueListEditor")==0) return ClearValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"GroupingValueListEditor")==0) return GroupingValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"RepeatValueListEditor")==0) return RepeatValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"DrawValueListEditor")==0) return DrawValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"ProportionValueListEditor")==0) return ProportionValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"FillValueListEditor")==0) return FillValueArrary; else if (_tcscmp(tValueEditor->Name.c_str(),L"VectorValueListEditor")==0) return VectorValueArrary; return NULL; } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::spSaveFileBtnClick(TObject *Sender) { TCursor cur; String filename, sfilename; HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE shFile = INVALID_HANDLE_VALUE; cur = Screen->Cursor; int FileNameLength; if(Application->MessageBox(IDS_SC_MSGBOX2.c_str(), L"File Save", MB_OKCANCEL) == IDOK) { Screen->Cursor = crHourGlass; filename = DirectoryName + String("\\") + FileComboBox->Text + String(".tsf"); if ((hFile = CreateFile(filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } SaveDataToFile(hFile); CloseHandle(hFile); Screen->Cursor = cur; return; } /* spBgSaveFileBtn->Brush->Color = clRed; filename = SaveDialog1->InitialDir + WideString("\\") + FileComboBox->Text + WideString(".tsf"); if (FileComboBox->Items->IndexOf(FileComboBox->Text) < 0) { spBgSaveFileBtn->Brush->Color = clBlue; return; } else if (WideFileExists(filename) && FileComboBox->Items->IndexOf(FileComboBox->Text) > 0) { if(Application->MessageBox(IDS_SC_MSGBOX2.c_str(), "File Save", MB_OKCANCEL) == IDOK) { Screen->Cursor = crHourGlass; if ((hFile = CreateFileW(filename.c_bstr(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } SaveDataToFile(hFile); CloseHandle(hFile); //sfilename = SaveDialog1->InitialDir + WideString("\\ShortCuts.lt"); //if ((shFile = CreateFileW(sfilename.c_bstr(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, // FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { // goto fail; //} //SaveCurrentNameToFile(shFile); //CloseHandle(shFile); //FileComboBoxChange(FileComboBox); Screen->Cursor = cur; spBgSaveFileBtn->Brush->Color = clBlue; return; } } next: */ SaveDialog1->InitialDir = DirectoryName; if (SaveDialog1->Execute()) { filename = SaveDialog1->FileName; if (ExtractFileExt(filename) != ".tsf") filename + ".tsf"; sfilename = SaveDialog1->InitialDir + String("\\Default.tsf"); if (filename == sfilename) { Application->MessageBox(IDS_SC_MSGBOX3.c_str(), L"Information", MB_ICONINFORMATION); spBgSaveFileBtn->Brush->Color = clBlue; return; } Screen->Cursor = crHourGlass; FileNameLength = SaveDialog1->FileName.Length(); for (int i=FileNameLength; i>0; i--) { if (SaveDialog1->FileName[i] == L'\\') { sfilename = SaveDialog1->FileName.SubString(i+1,FileNameLength-i-4); break; } } if (FileExists(filename) && FileComboBox->Items->IndexOf(FileComboBox->Text) > 0) { if(Application->MessageBox(IDS_SC_MSGBOX2.c_str(), L"File Save", MB_OKCANCEL) == IDCANCEL) { spBgSaveFileBtn->Brush->Color = clBlue; Screen->Cursor = cur; return; } } if ((hFile = CreateFile(filename.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } SaveDataToFile(hFile); CloseHandle(hFile); FindShortCutFiles(); for (int i = 0; i < FileComboBox->Items->Count; i++){ String wstrItem = FileComboBox->Items->Strings[i]; //FileComboBox->Items[i].Text; if (sfilename == wstrItem){ FileComboBox->ItemIndex = i; break; } } if (FileComboBox->ItemIndex < 0) FileComboBox->ItemIndex = 0; //FileComboBox->Text = sfilename; //FileComboBox->AddItem(sfilename, NULL); /* sfilename = SaveDialog1->InitialDir + WideString("\\ShortCuts.lt"); if ((shFile = CreateFileW(sfilename.c_bstr(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } SaveCurrentNameToFile(shFile); CloseHandle(shFile); FileComboBoxChange(FileComboBox); */ } Screen->Cursor = cur; spBgSaveFileBtn->Brush->Color = clBlue; return; fail: spBgSaveFileBtn->Brush->Color = clBlue; EXCEPTION_MESSAGE_OK(EC_FORM_NOT_CREATE); } //--------------------------------------------------------------------------- bool __fastcall TShortCutForm::SaveCurrentNameToFile(HANDLE fh) { int count, length; String temp; DWORD dwWrite; length = FileComboBox->Text.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, FileComboBox->Text.c_str(), length * sizeof(Char), &dwWrite, NULL)) goto fail; count = FileComboBox->Items->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iItems->Strings[i]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), length * sizeof(Char), &dwWrite, NULL)) goto fail; } return true; fail: return false; } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::SaveStringToFile(HANDLE fh) { int count, length; String temp; DWORD dwWrite; count = MainValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = EditValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = NomalValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } //------------------------------------------------------------------------- count = MenuOpenValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = WindowValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = MoveValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = ColorChangeValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = ClearValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = GroupingValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = RepeatValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = DrawValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = ProportionValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = FillValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } count = VectorValueListEditor->Strings->Count; if (!WriteFile(fh, &count, sizeof(int), &dwWrite, NULL)) goto fail; for (int i=0; iCells[1][i+1]; length = temp.Length(); if (!WriteFile(fh, &length, sizeof(int), &dwWrite, NULL)) goto fail; if (!WriteFile(fh, temp.c_str(), temp.Length() * sizeof(Char), &dwWrite, NULL)) goto fail; } fail: } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::LoadStringToFile(HANDLE fh) { int count, length; Char tchar; DWORD dwRead; if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iItems->Strings[i] += tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1] += tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } //------------------------------------------------------------------------- if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } if (!ReadFile(fh, &count, sizeof(int), &dwRead, NULL)) goto fail; for (int i=0; iCells[1][i+1]+=tchar; } } fail: } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::SaveDataToFile(HANDLE fh) { String temp; DWORD dwWrite; temp = "[File]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(MainValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(MainValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Edit]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(EditValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(EditValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Nomal]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(NomalValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(NomalValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } //------------------------------------------------------------------------- temp = "\n[MenuOpen]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(MenuOpenValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(MenuOpenValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Window]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(WindowValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(WindowValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[MoveCopy]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(MoveValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(MoveValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[ColorChange]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(ColorChangeValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(ColorChangeValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Clear]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(ClearValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(ClearValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Grouping]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(GroupingValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(GroupingValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Repeat]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(RepeatValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(RepeatValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Draw]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(DrawValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(DrawValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Proportion]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(ProportionValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(ProportionValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Fill]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(FillValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(FillValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } temp = "\n[Vector]\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; temp = "Length="+IntToStr(VectorValueListEditor->Strings->Count)+"\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; for (int i=0; iStrings->Count; i++) { temp = IntToStr(i)+"="+IntToStr(VectorValueArrary[i]) + "\n"; if (!WriteFile(fh, temp.c_str(), temp.Length(), &dwWrite, NULL)) goto fail; } fail: } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::TabControl3Change(TObject *Sender) { switch(TabControl3->TabIndex) { case 0: MenuOpenValueListEditor->BringToFront(); break; case 1: WindowValueListEditor->BringToFront(); break; case 2: MoveValueListEditor->BringToFront(); break; case 3: ColorChangeValueListEditor->BringToFront(); break; case 4: ClearValueListEditor->BringToFront(); break; case 5: GroupingValueListEditor->BringToFront(); break; case 6: RepeatValueListEditor->BringToFront(); break; case 7: DrawValueListEditor->BringToFront(); break; case 8: ProportionValueListEditor->BringToFront(); break; case 9: FillValueListEditor->BringToFront(); break; case 10: VectorValueListEditor->BringToFront(); break; } } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::LoadDataToArrary() { for (int i=0; iStrings->Count; i++) { MainValueArrary[i] = StrToInt(FileShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { EditValueArrary[i] = StrToInt(EditShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { NomalValueArrary[i] = StrToInt(NomalShortcutTable[i]); } //------------------------------------------------------------------------- for (int i=0; iStrings->Count; i++) { MenuOpenValueArrary[i] = StrToInt(MenuOpenShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { WindowValueArrary[i] = StrToInt(WindowShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { MoveValueArrary[i] = StrToInt(MoveCopyShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { ColorChangeValueArrary[i] = StrToInt(ColorChangeShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { ClearValueArrary[i] = StrToInt(ClearShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { GroupingValueArrary[i] = StrToInt(GroupingShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { RepeatValueArrary[i] = StrToInt(RepeatShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { DrawValueArrary[i] = StrToInt(DrawShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { ProportionValueArrary[i] = StrToInt(ProportionShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { FillValueArrary[i] = StrToInt(FillShortcutTable[i]); } for (int i=0; iStrings->Count; i++) { VectorValueArrary[i] = StrToInt(VectorShortcutTable[i]); } EtcValueArrary[0]='Z'; EtcValueArrary[1]='X'; EtcValueArrary[2]=10000+'Z'; EtcValueArrary[3]=10000+'X'; EtcValueArrary[4]='Q'; // 'Q' º¤ÅÍ¿¡¼­ »ç¿ëµÈ´Ù°í ÇÔ~ EtcValueArrary[5]=1000+'T'; // 'T' Ctrl + T (07.03.15) } //--------------------------------------------------------------------------- bool __fastcall TShortCutForm::CheckAnyExist(int num) { if (num==0) return false; for (int i=0; i<29; i++) { if (i<5 && num==StrToInt(MainValueArrary[i])) return true; else if (i<3 && num==StrToInt(EditValueArrary[i])) return true; else if (i<10 && num==StrToInt(NomalValueArrary[i])) return true; else if (i<12 && num==StrToInt(MenuOpenValueArrary[i])) return true; else if (i<12 && num==StrToInt(WindowValueArrary[i])) return true; else if (i<14 && num==StrToInt(MoveValueArrary[i])) return true; else if (i<5 && num==StrToInt(ColorChangeValueArrary[i])) return true; else if (i<4 && num==StrToInt(ClearValueArrary[i])) return true; else if (i<5 && num==StrToInt(GroupingValueArrary[i])) return true; else if (i<10 && num==StrToInt(RepeatValueArrary[i])) return true; else if (i<7 && num==StrToInt(DrawValueArrary[i])) return true; else if (i<4 && num==StrToInt(ProportionValueArrary[i])) return true; else if (i<3 && num==StrToInt(FillValueArrary[i])) return true; else if (i<29 && num==StrToInt(VectorValueArrary[i])) return true; else if (i<6 && num==EtcValueArrary[i]) return true; } return false; } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::spCreateKeyBtnClick(TObject *Sender) { String FileName; if (InputQuery("Input Box", "Input File Name", FileName)) { // FileName has been changed by the user, who clicked ok if (FileName.Length()) { if (FileComboBox->Items->IndexOf(FileName) >= 0) { Application->MessageBox(IDS_SC_MSGBOX1.c_str(), L"Warning", MB_ICONINFORMATION); return; } FileComboBox->Items->Add(FileName); FileComboBox->Text = FileName; } } } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::LoadComboBoxItems() { String FileName; Char tchar; HANDLE hFile = INVALID_HANDLE_VALUE; int count=0, length=0, i, j, error_detect=0; DWORD dwRead; FileName = DirectoryName + "ShortCuts.lt"; if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0 , NULL, OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL)) == INVALID_HANDLE_VALUE) { goto fail; } FileComboBox->Items->Clear(); FileName = ""; if (!ReadFile(hFile, &length, sizeof(int), &dwRead, NULL)) goto fail; for (j=0; j100) goto fail; if (!ReadFile(hFile, &tchar, sizeof(Char), &dwRead, NULL)) goto fail; FileName += tchar; error_detect++; } FileComboBox->Text = FileName; error_detect = 0; if (!ReadFile(hFile, &count, sizeof(int), &dwRead, NULL)) goto fail; for (i=0; i1000) goto fail; if (!ReadFile(hFile, &length, sizeof(int), &dwRead, NULL)) goto fail; FileName = ""; for (j=0; j1000) goto fail; if (!ReadFile(hFile, &tchar, sizeof(Char), &dwRead, NULL)) goto fail; FileName += tchar; error_detect++; } FileComboBox->Items->Add(FileName); error_detect++; } CloseHandle(hFile); hFile = NULL; return; fail: if (hFile) CloseHandle(hFile); hFile=NULL; /* FileName = DirectoryName + "ShortCuts.lt"; AnsiString ca = DirectoryName + "Origin\\ShortCuts.lt"; CopyFile(ca.c_str(), FileName.c_str(), false); SetFileAttributes(FileName.c_str(), FILE_ATTRIBUTE_NORMAL); FileName = DirectoryName + "Default.tsf"; AnsiString cb = DirectoryName + "Origin\\Default.tsf"; CopyFile(cb.c_str(), FileName.c_str(), false); SetFileAttributes(FileName.c_str(), FILE_ATTRIBUTE_NORMAL); */ FileName = DirectoryName + String("ShortCuts.lt"); CopyFile((DirectoryName + String("Origin\\ShortCuts.lt")).c_str(), FileName.c_str(), false); SetFileAttributes(FileName.c_str(), FILE_ATTRIBUTE_NORMAL); FileName = DirectoryName + String("Default.tsf"); CopyFile((DirectoryName + String("Origin\\Default.tsf")).c_str(), FileName.c_str(), false); SetFileAttributes(FileName.c_str(), FILE_ATTRIBUTE_NORMAL); EXCEPTION_MESSAGE_OK(EC_NOT_AVAILABLE_SHORTCUT_FILE); Application->Terminate(); } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::LoadStringByNumber() { Char temp[40]; for (int i=0; iStrings->Count; i++) { MakeStringByNumber(MainValueArrary[i], temp); MainValueListEditor->Cells[1][i+1] = temp; MainValueListEditor->Cells[0][i+1] = FileStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(EditValueArrary[i], temp); EditValueListEditor->Cells[1][i+1] = temp; EditValueListEditor->Cells[0][i+1] = EditStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(NomalValueArrary[i], temp); NomalValueListEditor->Cells[1][i+1] = temp; NomalValueListEditor->Cells[0][i+1] = NomalStringTable[i]; } //------------------------------------------------------------------------- for (int i=0; iStrings->Count; i++) { MakeStringByNumber(MenuOpenValueArrary[i], temp); MenuOpenValueListEditor->Cells[1][i+1] = temp; MenuOpenValueListEditor->Cells[0][i+1] = MenuOpenStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(WindowValueArrary[i], temp); WindowValueListEditor->Cells[1][i+1] = temp; WindowValueListEditor->Cells[0][i+1] = WindowStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(MoveValueArrary[i], temp); MoveValueListEditor->Cells[1][i+1] = temp; MoveValueListEditor->Cells[0][i+1] = MoveCopyStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(ColorChangeValueArrary[i], temp); ColorChangeValueListEditor->Cells[1][i+1] = temp; ColorChangeValueListEditor->Cells[0][i+1] = ColorChangeStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(ClearValueArrary[i], temp); ClearValueListEditor->Cells[1][i+1] = temp; ClearValueListEditor->Cells[0][i+1] = ClearStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(GroupingValueArrary[i], temp); GroupingValueListEditor->Cells[1][i+1] = temp; GroupingValueListEditor->Cells[0][i+1] = GroupingStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(RepeatValueArrary[i], temp); RepeatValueListEditor->Cells[1][i+1] = temp; RepeatValueListEditor->Cells[0][i+1] = RepeatStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(DrawValueArrary[i], temp); DrawValueListEditor->Cells[1][i+1] = temp; DrawValueListEditor->Cells[0][i+1] = DrawStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(ProportionValueArrary[i], temp); ProportionValueListEditor->Cells[1][i+1] = temp; ProportionValueListEditor->Cells[0][i+1] = ProportionStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(FillValueArrary[i], temp); FillValueListEditor->Cells[1][i+1] = temp; FillValueListEditor->Cells[0][i+1] = FillStringTable[i]; } for (int i=0; iStrings->Count; i++) { MakeStringByNumber(VectorValueArrary[i], temp); VectorValueListEditor->Cells[1][i+1] = temp; VectorValueListEditor->Cells[0][i+1] = VectorStringTable[i]; } for (int i=0; iStrings->Count; i++) EtcValueListEditor->Cells[0][i+1] = EtcStringTable[i]; fail: } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::FileComboBoxChange(TObject *Sender) { if (FileComboBox->Items->IndexOf(FileComboBox->Text) < 0) return; String FileName; FileName = DirectoryName + FileComboBox->Text + String(".tsf"); if (FileExists(FileName) == false) { Application->MessageBox(IDS_SC_MSGBOX4.c_str(), L"Warning", MB_ICONINFORMATION); return; } FileShortcutTable.Create(FileName, "File"); EditShortcutTable.Create(FileName, "Edit"); NomalShortcutTable.Create(FileName, "Nomal"); MenuOpenShortcutTable.Create(FileName, "MenuOpen"); WindowShortcutTable.Create(FileName, "Window"); MoveCopyShortcutTable.Create(FileName, "MoveCopy"); ColorChangeShortcutTable.Create(FileName, "ColorChange"); ClearShortcutTable.Create(FileName, "Clear"); GroupingShortcutTable.Create(FileName, "Grouping"); RepeatShortcutTable.Create(FileName, "Repeat"); DrawShortcutTable.Create(FileName, "Draw"); ProportionShortcutTable.Create(FileName, "Proportion"); FillShortcutTable.Create(FileName, "Fill"); VectorShortcutTable.Create(FileName, "Vector"); LoadDataToArrary(); LoadStringByNumber(); // TODO : HotKey Å×½ºÆ® Àӽà ÁÖ¼® ó¸® - by monkman (2010.07.02) /* if (MainMenuForm) MainMenuForm->MakeMenuHintByShortcut(); */ } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::spDeleteKeyBtnClick(TObject *Sender) { int index; String filename; HANDLE hFile = INVALID_HANDLE_VALUE; index = FileComboBox->Items->IndexOf(FileComboBox->Text); spBgDeleteKeyBtn->Brush->Color = clRed; filename = DirectoryName + FileComboBox->Text + String(".tsf"); if (FileExists(filename)) { if (Application->MessageBox(IDS_SC_MSGBOX5.c_str(), L"Information", MB_OKCANCEL) == IDOK) DeleteFile(filename); else { spBgDeleteKeyBtn->Brush->Color = clBlue; return; } } else { Application->MessageBox(IDS_SC_MSGBOX6.c_str(), L"Warning", MB_ICONINFORMATION); } FindShortCutFiles(); FileComboBox->ItemIndex = 0; spBgDeleteKeyBtn->Brush->Color = clBlue; return; fail: spBgDeleteKeyBtn->Brush->Color = clBlue; EXCEPTION_MESSAGE_OK(EC_FORM_NOT_CREATE); } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::FileComboBoxKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (FileComboBox->Items->IndexOf(FileComboBox->Text) < 0 && Key == VK_RETURN) { FileComboBox->ItemIndex = 0; FileComboBoxChange(this); } } //--------------------------------------------------------------------------- // 07.03.05 - ´ÜÃàŰ ¿¡·¯¸¦ ¹æÁöÇϱâ À§Çؼ­ ¸¸µê void __fastcall TShortCutForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile=NULL; IniFile = new TIniFile(AppDataItem + "\\ShortCuts.ini"); if (IniFile) { IniFile->WriteInteger("ShortCuts", "Index", FileComboBox->ItemIndex); delete IniFile; } /* WideString filename; HANDLE hFile = INVALID_HANDLE_VALUE; try { filename = DirectoryName + WideString("ShortCuts.lt"); if ((hFile = CreateFileW(filename.c_bstr(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { goto fail; } if (!SaveCurrentNameToFile(hFile)) goto fail; CloseHandle(hFile); hFile = NULL; return; fail: if (hFile) CloseHandle(hFile); hFile = NULL; if (WideFileExists(DirectoryName + WideString("BackupShortCuts.lt"))) { CopyFileW((DirectoryName + WideString("BackupShortCuts.lt")).c_bstr(), (DirectoryName + WideString("ShortCuts.lt")).c_bstr(), false); } } catch (...) { if (hFile) CloseHandle(hFile); hFile = NULL; if (WideFileExists(DirectoryName + WideString("BackupShortCuts.lt"))) { CopyFileW((DirectoryName + WideString("BackupShortCuts.lt")).c_bstr(), (DirectoryName + WideString("ShortCuts.lt")).c_bstr(), false); } } */ } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::FormDestroy(TObject *Sender) { //DeleteFileW((DirectoryName + WideString("BackupShortCuts.lt"))); } //--------------------------------------------------------------------------- void __fastcall TShortCutForm::FindShortCutFiles() { HANDLE hSrch = INVALID_HANDLE_VALUE; WIN32_FIND_DATA fd; BOOL bResult = TRUE; FileComboBox->Clear(); String wPath = DirectoryName + "\\*.tsf"; hSrch=FindFirstFile(wPath.c_str(),&fd); if (hSrch != INVALID_HANDLE_VALUE){ while(bResult){ if (fd.dwFileAttributes && !(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && !(fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && !(fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)){ //&& !(fd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY)){ String* tempName = new String(fd.cFileName); String fileName = *tempName; fileName = fileName.SubString(0, fileName.Length()-4) ; FileComboBox->Items->Add(fileName); } bResult = FindNextFile(hSrch,&fd); } } FindClose(hSrch); } //---------------------------------------------------------------------------