//--------------------------------------------------------------------------- #include #pragma hdrstop #include "ImportTransactionParameters.h" #include //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "AdvDirectoryEdit" #pragma link "AdvEdBtn" #pragma link "AdvEdit" #pragma link "FlCtrlEx" #pragma resource "*.dfm" TImportTransactionParametersForm *ImportTransactionParametersForm; const char * TImportTransactionParametersForm::g_importKey = "Software\\ERG\\TxnTestManager\\Import"; //--------------------------------------------------------------------------- __fastcall TImportTransactionParametersForm::TImportTransactionParametersForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TImportTransactionParametersForm::FormShow(TObject *Sender) { TRegistry * registry = 0; try { registry = new TRegistry(); registry->RootKey = HKEY_CURRENT_USER; // Create the key if it doesn't exist. registry->OpenKey( g_importKey, true ); AnsiString profile; profile = registry->ReadString( "Profile" ); if ( profile.IsEmpty() ) { profile = "TDS"; } ImportProfileComboBox->Text = profile; ImportProfileComboBox->ItemIndex = -1; for ( int index = 0; index < ImportProfileComboBox->Items->Count; ++index ) { if ( ImportProfileComboBox->Items->Strings[ index ] == profile ) { ImportProfileComboBox->ItemIndex = index; break; } } readProfile( *registry, profile ); } __finally { delete registry; } } //--------------------------------------------------------------------------- void __fastcall TImportTransactionParametersForm::OKClick(TObject *Sender) { TRegistry * registry = 0; try { registry = new TRegistry(); registry->RootKey = HKEY_CURRENT_USER; // Create the key if it doesn't exist. registry->OpenKey( g_importKey, true ); writeProfile( *registry, ImportProfileComboBox->Text ); } __finally { delete registry; } } //--------------------------------------------------------------------------- void __fastcall TImportTransactionParametersForm::readProfile( TRegistry & registry, const AnsiString & profile ) { if ( registry.OpenKey( profile, true ) ) { AnsiString folder = registry.ReadString( "Folder" ); if ( folder.IsEmpty() ) { folder = GetCurrentDir(); } ImportFolderDirectoryEdit->Text = folder; ImportFileListBox->ApplyFilePath( folder ); } } //--------------------------------------------------------------------------- void __fastcall TImportTransactionParametersForm::writeProfile( TRegistry & registry, const AnsiString & profile ) { registry.WriteString( "Profile", profile ); if ( registry.OpenKey( profile, true ) ) { registry.WriteString( "Folder", ImportFolderDirectoryEdit->Text ); } } //--------------------------------------------------------------------------- void __fastcall TImportTransactionParametersForm::ImportFolderDirectoryEditChange( TObject *Sender) { ImportFileListBox->ApplyFilePath( ImportFolderDirectoryEdit->Text ); } //--------------------------------------------------------------------------- void __fastcall TImportTransactionParametersForm::ImportProfileComboBoxChange( TObject *Sender) { TRegistry * registry = 0; try { registry = new TRegistry(); registry->RootKey = HKEY_CURRENT_USER; // Create the key if it doesn't exist. registry->OpenKey( g_importKey, true ); readProfile( *registry, ImportProfileComboBox->Text ); } __finally { delete registry; } } //---------------------------------------------------------------------------