//--------------------------------------------------------------------------- void __fastcall CIniFile::StoreHistory(int nYear,int nMonth,int nDate,AnsiString strMessage) { AnsiString strFileName; TIniFile *pIniFile; int nFileMonth,nIndex; strFileName.sprintf("%s\\Message History\\%4d_%02d_%02d.ini",IniFile_Dir,nYear,nMonth,nDate); pIniFile = new TIniFile(strFileName); nFileMonth=pIniFile->ReadInteger("Control","Month",1); nIndex=pIniFile->ReadInteger("Control","Index",1); if(nFileMonth!=nMonth) { nIndex=1; pIniFile->WriteInteger("Control","Month",nMonth); } AnsiString strID; strID.sprintf("No%08d",nIndex); pIniFile->WriteString("History",strID,strMessage); nIndex++; strID.sprintf("No%08d",nIndex); pIniFile->WriteString("History",strID,"//-------------以下做作廢--------------------//"); pIniFile->WriteInteger("Control","Index",nIndex); delete pIniFile; }
//--------------------------------------------------------------------------- void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *ini; ini = new TIniFile(ChangeFileExt( Application->ExeName, ".INI " ) ); ini->WriteInteger( "Form ", "Top ", Top ); ini->WriteInteger( "Form ", "Left ", Left ); ini->WriteString ( "Form ", "Caption ", Caption ); ini->WriteString ( "Form ", "DefaultDir ", Edit1->Text ); delete ini; }
//--------------------------------------------------------------------------- void __fastcall TTcpSrvForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; IniFile = new TIniFile(FIniFileName); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); delete IniFile; }
//--------------------------------------------------------------------------- void __fastcall CIniFile::StoreHistoryNew() { AnsiString strFileName; TIniFile *pIniFile; int nFileMonth,nIndex; time_t timer; struct tm *tblock; int nSize=m_vecMsg.size(); if(nSize==0) return; AnsiString strMsg; strMsg.sprintf("訊息共有 %d 筆\n每筆花費時間約 10 ms\n是否要儲存訊息??",nSize); if(Application->MessageBoxA(strMsg.c_str(),"Confirm",MB_ICONQUESTION|MB_OKCANCEL)!=IDOK) return; /* gets time of day */ timer = time(NULL); /* converts date/time to a structure */ tblock = localtime(&timer); int nMonth=tblock->tm_mon; int nDate=tblock->tm_mday; strFileName.sprintf("%s\\Message History\\%d.ini",IniFile_Dir,nDate); pIniFile = new TIniFile(strFileName); nFileMonth=pIniFile->ReadInteger("Control","Month",1); nIndex=pIniFile->ReadInteger("Control","Index",1); if(nFileMonth!=nMonth) { DeleteFile(strFileName); nIndex=1; pIniFile->WriteInteger("Control","Month",nMonth); } AnsiString strID; for(int nSz=0;nSz<nSize;nSz++) { strID.sprintf("No%08d",nIndex); pIniFile->WriteString("History",strID,m_vecMsg[nSz]); nIndex++; } m_vecMsg.clear(); strID.sprintf("No%08d",nIndex); pIniFile->WriteString("History",strID,"//-------------以下做作廢--------------------//"); pIniFile->WriteInteger("Control","Index",nIndex); delete pIniFile; }
//--------------------------------------------------------------------------- void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose) { TIniFile *IniFile; IniFile = new TIniFile(FIniFileName); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); IniFile->WriteString(SectionData, KeyPort, PortEdit->Text); IniFile->WriteString(SectionData, KeyServer, ServerEdit->Text); delete IniFile; }
//--------------------------------------------------------------------------- void __fastcall TDllTestForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; IniFile = new TIniFile(FIniFileName); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); delete IniFile; if (DllHandle) { FreeLibrary(DllHandle); DllHandle = 0; } }
//--------------------------------------------------------------------------- void __fastcall THttpTestForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; IniFile = new TIniFile(FIniFileName); IniFile->WriteString(SectionData, KeyUserID, UserIDEdit->Text); IniFile->WriteString(SectionData, KeyProxy, ProxyEdit->Text); IniFile->WriteString(SectionData, KeyMessage, MessageEdit->Text); IniFile->WriteString(SectionData, KeyEMail, EMailEdit->Text); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); delete IniFile; }
//--------------------------------------------------------------------------- void __fastcall TClientForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; IniFile = new TIniFile(IniFileName); IniFile->WriteInteger("Window", "Top", Top); IniFile->WriteInteger("Window", "Left", Left); IniFile->WriteInteger("Window", "Width", Width); IniFile->WriteInteger("Window", "Height", Height); IniFile->WriteString("Data", "Server", ServerEdit->Text); IniFile->WriteString("Data", "Port", PortEdit->Text); IniFile->WriteString("Data", "Command", SendEdit->Text); delete IniFile; }
// sets the default user settings void PREFERENCES::SetDefaultSettings() { TIniFile* storage = new TIniFile( ExtractFilePath( Application->ExeName ) + INIFILENAME_PREFERENCES ); try { storage->WriteInteger( "Various", "DefaultUserLevel", UserLevel ); #define WRITE_SCRIPT( name ) \ if( !mCmdlineSpecified[ name ] ) \ storage->WriteString( "Scripts", #name, Script[ name ] ); WRITE_SCRIPT( AfterModulesConnected ); WRITE_SCRIPT( OnExit ); WRITE_SCRIPT( OnSetConfig ); WRITE_SCRIPT( OnResume ); WRITE_SCRIPT( OnSuspend ); WRITE_SCRIPT( OnStart ); #define WRITE_BUTTON( number ) \ storage->WriteString( "Buttons", "Button" #number "Name", Buttons[ number ].Name ); \ storage->WriteString( "Buttons", "Button" #number "Cmd", Buttons[ number ].Cmd ); WRITE_BUTTON( 1 ); WRITE_BUTTON( 2 ); WRITE_BUTTON( 3 ); WRITE_BUTTON( 4 ); } catch(...) {} delete storage; }
//--------------------------------------------------------------------------- // Сохраняю установки измерения в файл bool SaveSettings(MeasurInfo& measurInfo) { if (access(lpIniFileName.c_str(), 0) == 0) { // TIniFile *Ini = new TIniFile(lpIniFileName); // try { if (Ini->SectionExists("History")) { Ini->WriteInteger("History", "type_check_watt", measurInfo.type_check_watt); Ini->WriteFloat("History", "begin_lw", measurInfo.begin_lw); Ini->WriteFloat("History", "end_lw", measurInfo.end_lw); Ini->WriteFloat("History", "step_lw", measurInfo.step_lw); Ini->WriteFloat("History", "calc_lw", measurInfo.calc_lw); Ini->WriteFloat("History", "time_accumulation", measurInfo.time_accumulation); Ini->WriteBool("History", "makeKorK_bw", measurInfo.makeKorK_bw); Ini->WriteBool("History", "makeKorK_cw", measurInfo.makeKorK_cw); Ini->WriteBool("History", "makeSetZero", measurInfo.makeSetZero); return true; } } __finally { delete Ini; Ini = NULL; } }
//--------------------------------------------------------------------------- void __fastcall TDesign::Button1Click(TObject *Sender) { EventColor = ColorBox1->Selected; SelectColor = ColorBox2->Selected; if(FileExists(ExtractFilePath(Application->ExeName) + "\\settings.ini")) { TIniFile *inifile; inifile = new TIniFile(ExtractFilePath(Application->ExeName) + "\\settings.ini"); inifile->WriteInteger("Color", "EventColor", EventColor); inifile->WriteInteger("Color", "SelectColor", SelectColor); inifile->UpdateFile(); inifile->Free(); } Close(); MainForm->Draw(); }
void TForm1::SaveIniSettings() { TIniFile* ini = new TIniFile(ChangeFileExt(Application->ExeName, ".INI")); try { // view menu ini->WriteBool("General", "Exists", true); ini->WriteBool("View", "CSize", AbZipOutline1->Attributes.Contains(zaCompressedSize)); ini->WriteBool("View", "CMethod", AbZipOutline1->Attributes.Contains(zaCompressionMethod)); ini->WriteBool("View", "CRatio", AbZipOutline1->Attributes.Contains(zaCompressionRatio)); ini->WriteBool("View", "CRC", AbZipOutline1->Attributes.Contains(zaCRC)); ini->WriteBool("View", "EFA", AbZipOutline1->Attributes.Contains(zaExternalFileAttributes)); ini->WriteBool("View", "IFA", AbZipOutline1->Attributes.Contains(zaInternalFileAttributes)); ini->WriteBool("View", "Encryption", AbZipOutline1->Attributes.Contains(zaEncryption)); ini->WriteBool("View", "TimeStamp", AbZipOutline1->Attributes.Contains(zaTimeStamp)); ini->WriteBool("View", "USize", AbZipOutline1->Attributes.Contains(zaUncompressedSize)); ini->WriteBool("View", "MadeBy", AbZipOutline1->Attributes.Contains(zaVersionMade)); ini->WriteBool("View", "Needed", AbZipOutline1->Attributes.Contains(zaVersionNeeded)); ini->WriteBool("View", "Comment", AbZipOutline1->Attributes.Contains(zaComment)); ini->WriteBool("View", "Hierarchy", AbZipOutline1->Hierarchy); // ini->WriteInteger("View", "OutlineStyle", AbZipOutline1->OutlineStyle); // preferences menu ini->WriteString("Preferences", "BaseDirectory", AbZipOutline1->BaseDirectory); ini->WriteBool("Preferences", "Confirmations", Confirmations1->Checked); ini->WriteInteger("Preferences", "CompressionMethodToUse", AbZipOutline1->CompressionMethodToUse); ini->WriteInteger("Preferences", "DeflationOption", AbZipOutline1->DeflationOption); ini->WriteBool("Preferences", "CreateDirs", AbZipOutline1->ExtractOptions.Contains(eoCreateDirs)); ini->WriteBool("Preferences", "RestorePath", AbZipOutline1->ExtractOptions.Contains(eoRestorePath)); ini->WriteBool("Preferences", "StripPath", AbZipOutline1->StoreOptions.Contains(soStripPath)); ini->WriteBool("Preferences", "RemoveDots", AbZipOutline1->StoreOptions.Contains(soRemoveDots)); ini->WriteBool("Preferences", "Recurse", AbZipOutline1->StoreOptions.Contains(soRecurse)); } catch (...) { delete ini; return; } delete ini; }
void __fastcall TMailSndForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; IniFile = new TIniFile(FIniFileName); IniFile->WriteString(SectionData, KeyHost, HostEdit->Text); IniFile->WriteString(SectionData, KeyPort, PortEdit->Text); IniFile->WriteString(SectionData, KeyFrom, FromEdit->Text); IniFile->WriteString(SectionData, KeyTo, ToEdit->Text); IniFile->WriteString(SectionData, KeySubject, SubjectEdit->Text); IniFile->WriteString(SectionData, KeySignOn, SignOnEdit->Text); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); delete IniFile; }
void TSettings::SaveToFile() { TSettings *Settings = TSettings::Instance(); TIniFile *ini = new TIniFile(".\\settings.cfg"); ini->WriteBool("Global", "FullScreen", Settings->Fullscreen); ini->WriteInteger("Global", "Width", Settings->FormsWidth); ini->WriteInteger("Global", "Height", Settings->FormsHeight); ini->WriteInteger("Global", "Left", Settings->FormsLeft); ini->WriteInteger("Global", "Top", Settings->FormsTop); ini->WriteBool("Global", "Sound", Settings->SoundEnabled); ini->WriteInteger("Global", "SoundVolume", Settings->SoundVolume); ini->WriteBool("Global", "Music", Settings->MusicEnabled); ini->WriteInteger("Global", "MusicVolume", Settings->MusicVolume); ini->WriteBool("Global", "HostMode", Settings->HostMode); ini->WriteString("Global", "LastBase", Settings->LastBase); for (int i = 1; i <= 5; i++) { ini->WriteString("Players", "Player" + IntToStr(i), Settings->PlayerNames[i - 1]); ini->WriteInteger("Players", "PlayerType" + IntToStr(i), (int) Settings->PlayerType[i - 1]); } int i = 0; for (std::map <String, String> ::iterator it = BaseFiles.begin(); it != BaseFiles.end(); ++it) { ini->WriteString("Bases", "basename" + IntToStr(i), it->first); ini->WriteString("Bases", "base" + IntToStr(i), ExtractFileName(it->second)); ++i; } ini->Free(); }
//--------------------------------------------------------------------------- void __fastcall TFtpServerForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; int Minim; try { StopServer(); Minim = StartMinimizedCheckBox->Checked; IniFile = new TIniFile(FIniFileName); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); IniFile->WriteInteger(SectionWindow, KeyMinim, Minim); IniFile->WriteString(SectionData, KeyPort, FPort); IniFile->Free(); } __except (TRUE) { // Ignore any exception when we are closing } }
//--------------------------------------------------------------------------- void __fastcall THttpTestForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; IniFile = new TIniFile(FIniFileName); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); IniFile->WriteString(SectionData, KeyUrl, URLEdit->Text); IniFile->WriteString(SectionData, KeySocksServer, SocksServerEdit->Text); IniFile->WriteString(SectionData, KeySocksPort, SocksPortEdit->Text); IniFile->WriteString(SectionData, KeyProxyHost, ProxyHostEdit->Text); IniFile->WriteString(SectionData, KeyProxyPort, ProxyPortEdit->Text); IniFile->WriteBool(SectionData, KeyVerifyPeer, VerifyPeerCheckBox->Checked); IniFile->WriteString(SectionData, KeyDoc, DocEdit->Text); IniFile->WriteString(SectionData, KeyCertFile, CertFileEdit->Text); IniFile->WriteString(SectionData, KeyPrivKeyFile, PrivKeyFileEdit->Text); IniFile->WriteString(SectionData, KeyPassPhrase, PassPhraseEdit->Text); IniFile->WriteString(SectionData, KeyCAFile, CAFileEdit->Text); IniFile->WriteString(SectionData, KeyCAPath, CAPathEdit->Text); IniFile->WriteString(SectionData, KeyAcceptableHosts, AcceptableHostsEdit->Text); IniFile->WriteInteger(SectionData, KeySocksLevel, SocksLevelComboBox->ItemIndex); IniFile->WriteInteger(SectionData, KeyHttpVer, HttpVersionComboBox->ItemIndex); IniFile->WriteBool(SectionData, KeySessCache, SessCacheCheckBox->Checked); IniFile->WriteBool(SectionData, KeyDebugEvent, DebugEventCheckBox->Checked); IniFile->WriteBool(SectionData, KeyDebugOutput, DebugOutputCheckBox->Checked); IniFile->WriteBool(SectionData, KeyDebugFile, DebugFileCheckBox->Checked); delete IniFile; }
void __fastcall TFrmMain::btTxtTypeClick(TObject *Sender) { if(OpenOk==true){ AnsiString iniSetFile=ExtractFilePath(Application->ExeName)+"BcdEditer.ini"; AnsiString SectionName=ExtractFileName(CurrentOpenFile); TIniFile *ini; ini = new TIniFile( iniSetFile ); ini->WriteInteger(SectionName,"ColType"+IntToStr(sgEdit->Col),2); delete ini; thOpen->ColType[sgEdit->Col]=2; OpenFileCol(CurrentOpenFile,sgEdit->Col,2); } }
//--------------------------------------------------------------------------- void __fastcall TPrefsForm::DefaultColorClick(TObject* Sender) { CheckPrefsInterOpt(); CheckReadonlyOpt(PrefFileOpt); if (ColorDialog1->Execute()) { TIniFile* Ini = new TIniFile(PrefFileOpt); try { Ini->WriteInteger("Options", "DefaultColor", ColorDialog1->Color); } catch (...) { Application->MessageBoxA(LMessagesOpt.WritePrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } delete Ini; } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose){ CTrayIcon->Minimize(); if (MessageDlg("请确认要退出系统吗?或是取消可转到后台运行。", mtConfirmation ,mbOKCancel ,0) ==1){ controller->fileDataDealer->Stop(); //if (MessageDlg("要将所有彩票机全部自动关机吗?", mtConfirmation ,mbOKCancel ,0) ==1) ShutDown(true); try{// 保存一些设置到本地配置文件,如窗口大小等 TIniFile *ini = new TIniFile(GetCurrentDir() + "\\app.ini"); ini->WriteTime("Center", "ShutdownTime", DateTimePicker->Time); ini->WriteString("FormSize", "Width", MainForm->Width); ini->WriteString("FormSize", "Height", MainForm->Height); for (int i = 0; i <controller->terminalGroup->Count; i++) { CTerminal *terminal =(CTerminal *)controller->terminalGroup->Objects[i]; ini->WriteInteger(terminal->xmlConfig->TerminalID , "KeyboardInterval", terminal->panel->TrackBarKey->Position); } delete ini; }catch(...){} //关闭窗口 CanClose =true; }else CanClose =false; }
//--------------------------------------------------------------------------- void __fastcall TfrmMain::SaveSetting() { TIniFile* ini = new TIniFile( String(LoginerPath) +"\\Data\\"+ GameAccount + "\\Setting.ini"); ini->WriteInteger("AutoGuagi","X",AutoGuagi_X); ini->WriteInteger("AutoGuagi","Y",AutoGuagi_Y); ini->WriteInteger("AutoGuagi","MapId",AutoGuagi_MapId); ini->WriteBool("Setting","godmode",this->ck_func_godmode->IsChecked); ini->WriteBool("Setting","dingua",this->ck_func_dingua->IsChecked); ini->WriteBool("Setting","csx",this->ck_func_csx->IsChecked); ini->WriteBool("Setting","autolr",this->ck_func_autolr->IsChecked); ini->WriteBool("Setting","chardir",this->ck_func_chardir->IsChecked); ini->WriteBool("Setting","chardir_v",this->sw_func_chardir->IsChecked); ini->WriteBool("Setting","dingwei",this->ck_func_dingwei->IsChecked); ini->WriteBool("Setting","hidebk",this->ck_func_hidebk->IsChecked); ini->WriteBool("Setting","hidedmg",this->ck_func_hidedmg->IsChecked); ini->WriteBool("Setting","hideskill",this->ck_func_hideskill->IsChecked); ini->WriteBool("Setting","itemvac",this->ck_func_itemvac->IsChecked); ini->WriteBool("Setting","jmp",this->ck_func_jmp->IsChecked); ini->WriteBool("Setting","stupid",this->ck_func_stupid->IsChecked); ini->WriteBool("Protect","hp",this->ck_hp->IsChecked); ini->WriteBool("Protect","mp",this->ck_mp->IsChecked); ini->WriteBool("Protect","att",this->ck_att->IsChecked); ini->WriteBool("Protect","pick",this->ck_pick->IsChecked); ini->WriteBool("Protect","key1",this->ck_key1->IsChecked); ini->WriteBool("Protect","key2",this->ck_key2->IsChecked); ini->WriteBool("Protect","key3",this->ck_key3->IsChecked); ini->WriteBool("Protect","key4",this->ck_key4->IsChecked); ini->WriteString("Protect","hp_v",this->txt_hp->Text); ini->WriteString("Protect","mp_v",this->txt_mp->Text); ini->WriteString("Protect","att_v",this->txt_att->Text); ini->WriteString("Protect","pick_v",this->txt_pick->Text); ini->WriteString("Protect","key1_v",this->txt_key1->Text); ini->WriteString("Protect","key2_v",this->txt_key2->Text); ini->WriteString("Protect","key4_v",this->txt_key3->Text); ini->WriteString("Protect","key3_v",this->txt_key4->Text); ini->WriteInteger("Protect","att_k",this->cb_att->ItemIndex); ini->WriteInteger("Protect","pick_k",this->cb_pick->ItemIndex); ini->WriteInteger("Protect","key1_k",this->cb_key1->ItemIndex); ini->WriteInteger("Protect","key2_k",this->cb_key2->ItemIndex); ini->WriteInteger("Protect","key4_k",this->cb_key3->ItemIndex); ini->WriteInteger("Protect","key3_k",this->cb_key4->ItemIndex); }
//--------------------------------------------------------------------------- void __fastcall TSocksTestForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile; IniFile = new TIniFile(FIniFileName); IniFile->WriteInteger(SectionWindow, KeyTop, Top); IniFile->WriteInteger(SectionWindow, KeyLeft, Left); IniFile->WriteInteger(SectionWindow, KeyWidth, Width); IniFile->WriteInteger(SectionWindow, KeyHeight, Height); IniFile->WriteString(SectionData, KeyTargetHost, Trim(TargetHostEdit->Text)); IniFile->WriteString(SectionData, KeyTargetPort, Trim(TargetPortEdit->Text)); IniFile->WriteString(SectionData, KeySocksServer, Trim(SocksServerEdit->Text)); IniFile->WriteString(SectionData, KeySocksPort, Trim(SocksPortEdit->Text)); IniFile->WriteString(SectionData, KeySocksUsercode, Trim(SocksUsercodeEdit->Text)); IniFile->WriteString(SectionData, KeySocksPassword, Trim(SocksPasswordEdit->Text)); IniFile->WriteInteger(SectionData, KeySocksAuth, SocksAuthCheckBox->Checked); IniFile->WriteInteger(SectionData, KeySocks5, Socks5RadioButton->Checked); IniFile->WriteInteger(SectionData, KeySocks4, Socks4RadioButton->Checked); delete IniFile; }
//--------------------------------------------------------------------------- void __fastcall TPrefsForm::ApplyButtonClick(TObject* Sender) { CheckPrefsInterOpt(); CheckReadonlyOpt(PrefFileOpt); TRegistry* Reg = new TRegistry; TIniFile* Ini = new TIniFile(PrefFileOpt); try { Ini->WriteBool("Options", "FadeShow", FadeShow->Checked); Ini->WriteBool("Options", "URLDetect", URLDetect->Checked); Ini->WriteBool("Options", "MinOnClose", MinOnClose->Checked); Ini->WriteBool("Options", "StartWithWindows", StartWithWindows->Checked); Ini->WriteBool("Options", "TopPages", TopPages->Checked); Ini->WriteBool("Options", "Transparency", Transparency->Checked); Ini->WriteInteger("Options", "TransValue", TransValue->Position); Ini->WriteBool("Options", "MultiLines", MultiLines->Checked); Ini->WriteBool("Options", "WorkMode", NormalMode->Checked); Ini->WriteInteger("Options", "FadeSpeed", StrToInt(FadeSpeed->Text)); Ini->WriteString("Options", "DefaultFont", FontComboBox1->FontName); Ini->WriteInteger("Options", "DefaultFontSize", StrToInt(DefaultSize->Text)); Ini->WriteBool("Options", "FadeHide", FadeHide->Checked); Ini->WriteBool("Options", "XPEffects", XPEffects->Checked); Ini->WriteInteger("Options", "Style", StyleBox->ItemIndex); Ini->WriteBool("Options", "TaskbarIcon", TaskbarCheck->Checked); Ini->WriteBool("Options", "TrayIcon", IconInTray->Checked); Ini->WriteBool("Options", "HideWindow", HideWind->Checked); Ini->WriteInteger("Options", "HideTimeout", HideTimePosition->Position); Ini->WriteBool("Options", "AskOnFormatChange", AskFormat->Checked); if (FormatPageBox->ItemIndex == 0) Ini->WriteString("Options", "DefaultPageFormat", "RTF"); else Ini->WriteString("Options", "DefaultPageFormat", "TXT"); Reg->RootKey = HKEY_CURRENT_USER; Reg->OpenKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (StartWithWindows->Checked) { AnsiString Path = Application->ExeName; Reg->WriteString("SimpleNotes", Path ); } else { if (Reg->ValueExists("SimpleNotes") && (Reg->ReadString("SimpleNotes") == Application->ExeName)) Reg->DeleteValue("SimpleNotes"); } if (TopPages->Checked) SNotesXMForm->AllTabs->TabPosition = tpTop; else SNotesXMForm->AllTabs->TabPosition = tpBottom; SNotesXMForm->AllTabs->MultiLine = MultiLines->Checked; SNotesXMForm->RichEdit1->AutoURLDetect = URLDetect->Checked; if ((OSopt == "Win2K") || (OSopt == "WinXP") || (OSopt == "Win2003")) { SNotesXMForm->AlphaBlend = Transparency->Checked; SNotesXMForm->AlphaBlendValue = TransValue->Position; } else SNotesXMForm->AlphaBlend = false; switch (StyleBox->ItemIndex) { case 0: SNotesXMForm->TBXSwitcher1->Theme = "Default"; break; case 1: SNotesXMForm->TBXSwitcher1->Theme = "OfficeXP"; break; default: SNotesXMForm->TBXSwitcher1->Theme = "OfficeXP"; break; } SNotesXMForm->TBXSwitcher1->EnableXPStyles = XPEffects->Checked; Ini->WriteString("Options", "BackUpPath", BackupPath->Text); WasTop = TopPages->Checked; WasXPEffects = SNotesXMForm->TBXSwitcher1->EnableXPStyles; WasMultiLine = SNotesXMForm->AllTabs->MultiLine; WasTrayIcon = SNotesXMForm->CoolTray->IconVisible; WasTrans = SNotesXMForm->AlphaBlend; TransIs = SNotesXMForm->AlphaBlendValue; StyleIs = StyleBox->ItemIndex; ApplyButton->Enabled = false; } catch (...) { Application->MessageBoxA(LMessagesOpt.WritePrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } delete Ini; delete Reg; }
//--------------------------------------------------------------------------- void __fastcall TPrefsForm::SetHotkeyButtonClick(TObject* Sender) { CheckPrefsInterOpt(); CheckReadonlyOpt(PrefFileOpt); TIniFile* Ini = new TIniFile(PrefFileOpt); long int HotKey = HotKeyComb->HotKey; int Mods = 0; int Key = 0; if (HotKeyComb->Modifiers.Contains(hkShift)) HotKey -= 8192; if (HotKeyComb->Modifiers.Contains(hkAlt)) HotKey -= 32768; if (HotKeyComb->Modifiers.Contains(hkCtrl)) HotKey -= 16384; try { if (HotKeyComb->Modifiers.Contains(hkShift)) Ini->WriteBool("Options", "Mod_Shift", 1); else Ini->WriteBool("Options", "Mod_Shift", 0); if (HotKeyComb->Modifiers.Contains(hkAlt)) Ini->WriteBool("Options", "Mod_Alt", 1); else Ini->WriteBool("Options", "Mod_Alt", 0); if (HotKeyComb->Modifiers.Contains(hkCtrl)) Ini->WriteBool("Options", "Mod_Ctrl", 1); else Ini->WriteBool("Options", "Mod_Ctrl", 0); Ini->WriteInteger("Options", "HotKey", HotKey); } catch (...) { Application->MessageBoxA(LMessagesOpt.WritePrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } try { if (Ini->ReadBool("Options", "Mod_Shift", 0)) Mods += MOD_SHIFT; if (Ini->ReadBool("Options", "Mod_Alt", 0)) Mods += MOD_ALT; if (Ini->ReadBool("Options", "Mod_Ctrl", 0)) Mods += MOD_CONTROL; Key = Ini->ReadInteger("Options", "HotKey", 165); } catch (...) { Application->MessageBoxA(LMessagesOpt.ReadPrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } try { Ini->WriteInteger("Options", "Hot2", HotKeyComb->HotKey); } catch (...) { Application->MessageBoxA(LMessagesOpt.WritePrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } if (HotKeyComb->HotKey != 0) { UnregisterHotKey(Application->Handle, 1); bool HotKey2 = RegisterHotKey(Application->Handle, 1, Mods, Key); if (!HotKey2) Application->MessageBoxA(LMessagesOpt.HotExists, LMessagesOpt.Error, MB_OK + MB_ICONWARNING); } delete Ini; SetHotkeyButton->Enabled = false; }