以前就发现过这个问题,但一直没有在意。昨天一个窗体FORMSHOW执行了两次,对数据有影响,于是搜索了一下这个问题的答案。
Since your other thread finally gave your situation, it was very easy to find the problem:
AForm.Position := poMainFormCenter;
This calls Perform(CM_RECREATEWND, 0, 0); which will execute an immediate recreate of the form.
这种情况多发生在MDI的窗体中。
解决的办法:
如果你不能干掉AForm.Position语句,那么可以设置一个变量来记录执行次数。
var iFirstExecute:boolean;
formCreate{
iFirstExecute:=true;
}
formShow{
if not iFirstExecute then exit;
// code of do sth.
iFirstExecute:=false;
}