unit CnRS232Dialog;
{ TCnRS232Dlg }
// 窗体创建
procedure TCnRS232Dlg.FormCreate(Sender: TObject);
begin
FCommConfig := TCnRS232Config.Create;
FTimeouts := TCnRS232Timeouts.Create;
//是否应该删除下面两行呢?
WriteCommConfig;
WriteCommTimeouts;
end;
不知道是不是我的调用方法不正确,如果不删除这两行,用下面的代码时,设置界面显示的是缺省值:
CnRS232.CommName := 'COM1';
CnRS232.ReadFromIni('.\CommPort.ini', CnRS232.CommName);
CnRS232Dialog.CommConfig := CnRS232.CommConfig;
CnRS232Dialog.Timeouts := CnRS232.Timeouts;
if CnRS232Dialog.Execute then
begin
CnRS232.CommConfig := CnRS232Dialog.CommConfig;
CnRS232.Timeouts := CnRS232Dialog.Timeouts;
end;
CnRS232.WriteToIni('.\CommPort.ini', CnRS232.CommName);