www.pudn.com > fbdelphisw > ComSelect.pas
unit ComSelect;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,INIFIles;
type
TfmSelectComPort = class(TForm)
grpComSelect: TGroupBox;
cmboComport: TComboBox;
btnOK: TButton;
procedure btnOKClick(Sender: TObject);
Procedure Change;
private
{ Private declarations }
public
{ Public declarations }
end;
var
fmSelectComPort: TfmSelectComPort;
implementation
{$R *.DFM}
procedure TfmSelectComPort.btnOKClick(Sender: TObject);
var
fIniFile :TIniFile;
iPort:integer;
begin
if cmboComport.ItemIndex>-1 then
begin
iPort:=cmboComport.ItemIndex;
fIniFile :=TIniFile.create(extractFilePath(GetCurrentDir+'\')+'fbus.ini');
fINIFile.writeInteger('COMPORT','PORT',iPort);
fINIFile.free;
self.Close;
end
else
MessageDlg('Please Select a Comport',mtWarning,[mbOk],0);
end;
Procedure TfmSelectComPort.Change;
var
fIniFile :TIniFile;
iPort:integer;
begin
iPort:=cmboComport.ItemIndex;
fIniFile :=TIniFile.create(extractFilePath(GetCurrentDir+'\')+'fbus.ini');
iPort:=fINIFile.ReadInteger('COMPORT','PORT',iPort);
fINIFile.free;
cmboComport.ItemIndex:=iPort;
Showmodal;
end;
end.