在Delphi中当点击Button组件时,代码执行的是ModalResult := mrCancel;
经过Debug发现,这是系统会调用写注册表的程序,向注册表中写入东西,有时能正常写入,有时候会保持‘Unable to write to ...',请问有人知道这是什么原因吗?即使把ModalResult := mrCancel;换成Close;仍旧会发生这种问题。请大家帮忙讲解什么原因。
经过Debug发现,这是系统会调用写注册表的程序,向注册表中写入东西,有时能正常写入,有时候会保持‘Unable to write to ...',请问有人知道这是什么原因吗?即使把ModalResult := mrCancel;换成Close;仍旧会发生这种问题。请大家帮忙讲解什么原因。
procedure TFormPlacement.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Assigned(FSaveFormCloseQuery) then
FSaveFormCloseQuery(Sender, CanClose);
if CanClose and Active and (Owner is TCustomForm) and (Form.Handle <> 0) then
try
SaveFormPlacement; //这个地方报错,它又调用其它的函数
except
Application.HandleException(Self);
end;
end;//下面的是rxAppUtils.pas中的内容.
procedure IniWriteInteger(IniFile: TObject; const Section, Ident: string;
Value: Longint);
begin
{$IFDEF WIN32}
if IniFile is TRegIniFile then
TRegIniFile(IniFile).WriteInteger(Section, Ident, Value)
else
{$ENDIF}
if IniFile is TIniFile then
TIniFile(IniFile).WriteInteger(Section, Ident, Value); //写注册表时不能成功
end;
procedure TfmTransList.btCloseClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
这个窗口是有用到Rx控件中FormStorage控件,在FormCreate时,用到FormStorage.IniFileName :=‘注册表路径’; 这样是否表示已经写入注册表。为什么关闭后还要写注册表呢?
执行完上面的代码后,程序跳入
procedure TFormPlacement.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
这是安装控件用的.pas文件rxPlacemnt.pas中的一段代码,不明吧为什么会跳入到这个地方?