I agree with Lin, I meeted this problem too. NOT MDI , check other code.
在生成MDIChild子窗体前应判断此窗体是否存在,我一直这样做,从未出现过问题。 下面是程序的代码: {MDIMainForm是主窗体;IMRegisterForm是子窗体}if MDIMainForm.MDIChildCount=0 then begin ChildIndex:=0; while (ChildIndex<MDIMainForm.MDIChildCount) and (MDIMainForm.MDIChildren[ChildIndex].Name<>IMRegisterForm.Name) do Inc(ChildIndex); if ChildIndex = MDIMainForm.MDIChildCount then {create new child here} begin Application.CreateForm(TIMRegisterForm,IMRegisterForm); end else {child form already exists so just bring it to the top} MDIMainForm.MDIChildren[ChildIndex].BringToFront;
UseForm:=TUseForm.create(self);无关。问题应该出在StringGrid之类的控件中。
Field的长度与实际的字符串长度不符导致的。
下面是程序的代码:
{MDIMainForm是主窗体;IMRegisterForm是子窗体}if MDIMainForm.MDIChildCount=0 then
begin
ChildIndex:=0;
while (ChildIndex<MDIMainForm.MDIChildCount) and
(MDIMainForm.MDIChildren[ChildIndex].Name<>IMRegisterForm.Name) do
Inc(ChildIndex);
if ChildIndex = MDIMainForm.MDIChildCount then
{create new child here}
begin
Application.CreateForm(TIMRegisterForm,IMRegisterForm);
end
else
{child form already exists so just bring it to the top}
MDIMainForm.MDIChildren[ChildIndex].BringToFront;