写了一个可以自动保存窗口位置状态的组件,本来觉得很简单,现在却碰到了点小问题,调试不过去,麻烦大家帮我看看。// 为了在装入组件的时设置窗口位置,重载了TComponent的loaded方法
procedure TFormState.Loaded;
begin
inherited Loaded;
if not (csDesigning in Componentstate) then begin
ReadFormPos(Owner as TForm); // 读取上次保存的窗口参数
FOnDestroy := (Owner as TForm).OnDestroy; // 一执行到此句便出错,非法访问
(Owner as TForm).OnDestroy := FormDestroy;
end;
end;
procedure TFormState.Loaded;
begin
inherited Loaded;
if not (csDesigning in Componentstate) then begin
ReadFormPos(Owner as TForm); // 读取上次保存的窗口参数
FOnDestroy := (Owner as TForm).OnDestroy; // 一执行到此句便出错,非法访问
(Owner as TForm).OnDestroy := FormDestroy;
end;
end;
解决方案 »
- 多线程与数据库,困扰我好几天,我都快疯,请高手给指点一下!
- 用WebBrowser控件写自动登陆网页的程序遇到提交按钮是图片怎么办?
- 怎样用execSQL保存日期字段,谢谢 本人刚学用Delphi改写程序,请路过的前辈帮下忙.
- 一人简单的问题
- 郁无可郁的问题:改变一个UpDown控件的某个属性,就绘不出图了
- 关于webbrowser下载的一个问题-------->>>>>>>
- 如何让这些代码在DELPHI中运行起来。关于软件时间限制和注册的。
- 1K价格诚招DELPHI编写考试系统,管理员请勿删除
- delphi越来越没人气了
- dd
- 关于postmessage的问题
- 请问如何关闭某个程序启动时打开的浏览器?
constructor TFormState.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;应该设置了啊
begin
inherited Create(AOwner);
Owner:=AOwner;
end;
我记得Loaded是在Create之前发生的,所以Owner为nil。
我细查了一下delphi的帮助文档,Loaded应该是在Create之后发生的吧?When the streaming system loads a form or data module from its form file, it first constructs the form component by calling its constructor, then reads its property values from the form file. After reading all the property values for all the components, the streaming system calls the Loaded methods of each component in the order the components were created. This gives the components a chance to initialize any data that depends on the values of other components or other parts of itself.
你总得有创建时间吧?
FormState := TFromState.Create(nil)?
那就是nil了
Create(self)呢?》
Application.Create(TF,F);
这样的话,不是该组件被拖放到窗口就会执行Create了吗?在运行期,create也同样会执行的。