{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% osCommerce Product Manager for Windows (oscpmwin). Copyright ©2003,2004,2005 by Mario A. Valdez-Ramirez. You can contact Mario A. Valdez-Ramirez by email at mario@mariovaldez.org or paper mail at Olmos 809, San Nicolas, NL. 66495, Mexico. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} unit configmod; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Spin, Buttons; type Topm_Form_ConfigMod = class(TForm) opm_BitBtn_ConfigModOk: TBitBtn; opm_BitBtn_ConfigModCancel: TBitBtn; opm_Label_ConfigModName: TLabel; opm_Edit_ConfigModName: TEdit; opm_Label_ConfigModFile: TLabel; opm_Edit_ConfigModCmd: TEdit; opm_BitBtn_ConfigModFile: TBitBtn; opm_Label_ConfigModPara: TLabel; opm_Edit_ConfigModPara: TEdit; opm_Label_ConfigModPort: TLabel; opm_SpinEdit_ConfigModPort: TSpinEdit; opm_CheckBox_ConfigModJustRun: TCheckBox; opm_CheckBox_ConfigModOnSelection: TCheckBox; opm_CheckBox_ConfigModRemote: TCheckBox; opm_Label_ConfigModIndex: TLabel; opm_ComboBox_ConfigModIndex: TComboBox; opm_Label_ConfigModResult: TLabel; opm_ComboBox_ConfigModResult: TComboBox; opm_OpenDialog_ConfigMod: TOpenDialog; procedure opm_BitBtn_ConfigModFileClick(Sender: TObject); procedure opm_BitBtn_ConfigModOkClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public MC_Name : STRING; MC_AddEdit : BOOLEAN; end; var opm_Form_ConfigMod: Topm_Form_ConfigMod; implementation {$R *.dfm} Uses gnugettext, oscpmdata, dataman, attention, balloons, modules; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} procedure Topm_Form_ConfigMod.opm_BitBtn_ConfigModFileClick (Sender: TObject); begin opm_OpenDialog_ConfigMod.DefaultExt := opmC_Def_LoadModExt; opm_OpenDialog_ConfigMod.FileName := ''; opm_OpenDialog_ConfigMod.Filter := _('Executable files') + ' (' + opmC_Def_LoadModFilter + ')|' + opmC_Def_LoadModFilter + '|' + _('All files (*.*)'); opm_OpenDialog_ConfigMod.Title := _('Choosing module file...'); opm_OpenDialog_ConfigMod.InitialDir := opm_ModuleDirectory; IF (opm_OpenDialog_ConfigMod.Execute = TRUE) THEN BEGIN opm_Edit_ConfigModCmd.Text := TRIM (ExtractFileName (opm_OpenDialog_ConfigMod.FileName)); END; end; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} procedure Topm_Form_ConfigMod.opm_BitBtn_ConfigModOkClick(Sender: TObject); begin opm_CurrentModuleRecord.Name := FNopm_CleanUploadName (TRIM (opm_Edit_ConfigModName.Text)); opm_CurrentModuleRecord.CommandFile := ExtractFileName (TRIM (opm_Edit_ConfigModCmd.Text)); opm_CurrentModuleRecord.CommandPara := TRIM (opm_Edit_ConfigModPara.Text); opm_CurrentModuleRecord.Port := opm_SpinEdit_ConfigModPort.Value; IF (opm_CheckBox_ConfigModRemote.Checked = TRUE) THEN opm_CurrentModuleRecord.Remote := 1 ELSE opm_CurrentModuleRecord.Remote := 0; IF (opm_CheckBox_ConfigModJustRun.Checked = TRUE) THEN opm_CurrentModuleRecord.JustRun := 1 ELSE opm_CurrentModuleRecord.JustRun := 0; IF (opm_CheckBox_ConfigModOnSelection.Checked = TRUE) THEN opm_CurrentModuleRecord.OnSelection := 1 ELSE opm_CurrentModuleRecord.OnSelection := 0; opm_CurrentModuleRecord.IndexData := TRIM (opm_ComboBox_ConfigModIndex.Text); opm_CurrentModuleRecord.ResultData := TRIM (opm_ComboBox_ConfigModResult.Text); IF (opm_FNSave_ModuleData (opm_CurrentModuleRecord) = FALSE) THEN BEGIN FNopm_Message (_('Missing or wrong data.'), mtError, [mbOK], opmG_UISilent); ModalResult := mrNone; END; end; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} procedure Topm_Form_ConfigMod.FormCreate(Sender: TObject); begin MC_Name := ''; MC_AddEdit := FALSE; opm_SpinEdit_ConfigModPort.MinValue := opmC_Min_ModPort; opm_SpinEdit_ConfigModPort.MaxValue := opmC_Max_ModPort; opm_ComboBox_ConfigModIndex.Sorted := FALSE; opm_ComboBox_ConfigModResult.Sorted := FALSE; opm_Edit_ConfigModName.MaxLength := opmC_Max_ModNameWidth; opm_Edit_ConfigModCmd.MaxLength := opmC_Max_ModCMDWidth; TranslateComponent (self); end; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} procedure Topm_Form_ConfigMod.FormShow(Sender: TObject); begin opm_Form_ConfigMod.Caption := _('Module configuration'); opm_ComboBox_ConfigModIndex.Items := opmG_ModIndexData_BoxList; opm_ComboBox_ConfigModResult.Items := opmG_ModResultData_BoxList; opm_Edit_ConfigModName.Enabled := MC_AddEdit; opm_CurrentModuleRecord := opm_FNLoad_ModuleData (MC_Name); IF (MC_AddEdit = TRUE) THEN BEGIN opm_Edit_ConfigModName.Text := ''; opm_Edit_ConfigModCmd.Text := ''; opm_Edit_ConfigModPara.Text := ''; opm_SpinEdit_ConfigModPort.Value := opmC_Def_ModPort; opm_CheckBox_ConfigModRemote.Checked := FALSE; opm_CheckBox_ConfigModJustRun.Checked := FALSE; opm_CheckBox_ConfigModOnSelection.Checked := TRUE; opm_ComboBox_ConfigModIndex.ItemIndex := 0; opm_ComboBox_ConfigModResult.ItemIndex := 0; END ELSE BEGIN opm_Edit_ConfigModName.Text := opm_CurrentModuleRecord.Name; opm_Edit_ConfigModCmd.Text := opm_CurrentModuleRecord.CommandFile; opm_Edit_ConfigModPara.Text := opm_CurrentModuleRecord.CommandPara; opm_SpinEdit_ConfigModPort.Value := opm_CurrentModuleRecord.Port; opm_CheckBox_ConfigModRemote.Checked := (opm_CurrentModuleRecord.Remote > 0); opm_CheckBox_ConfigModJustRun.Checked := (opm_CurrentModuleRecord.JustRun > 0); opm_CheckBox_ConfigModOnSelection.Checked := (opm_CurrentModuleRecord.OnSelection > 0); opm_ComboBox_ConfigModIndex.ItemIndex := opm_FNGetListIndexByString (opm_CurrentModuleRecord.IndexData, opmG_ModIndexData_BoxList); opm_ComboBox_ConfigModResult.ItemIndex := opm_FNGetListIndexByString (opm_CurrentModuleRecord.ResultData, opmG_ModResultData_BoxList); END; end; end.