一个主窗体,多个子窗体,将子窗体放入projects->options->forms->Available forms, 在主窗体的菜单中加入
1. procedure TMainForm.N2Click(Sender: TObject);
2. var
3. LayoutInfoMaintenaceForm : TLayoutInfoMaintenaceForm;
4. begin
5. if not Assigned(LayoutInfoMaintenaceForm) then
6. begin
7. LayoutInfoMaintenaceForm := TLayoutInfoMaintenaceForm.Create(nil);
8. LayoutInfoMaintenaceForm.Show;
9. end
10. else
11. LayoutInfoMaintenaceForm.BringToFront;
end;
可是无法打开子窗体,在第5行处设一断点,发现程序直接从第5行跳到第11行,没有执行6至9行的代码,请问问题出在什么地方?
1. procedure TMainForm.N2Click(Sender: TObject);
2. var
3. LayoutInfoMaintenaceForm : TLayoutInfoMaintenaceForm;
4. begin
5. if not Assigned(LayoutInfoMaintenaceForm) then
6. begin
7. LayoutInfoMaintenaceForm := TLayoutInfoMaintenaceForm.Create(nil);
8. LayoutInfoMaintenaceForm.Show;
9. end
10. else
11. LayoutInfoMaintenaceForm.BringToFront;
end;
可是无法打开子窗体,在第5行处设一断点,发现程序直接从第5行跳到第11行,没有执行6至9行的代码,请问问题出在什么地方?
LayoutinfoMaintenaceForm.Show
else
begin
LayoutinfoMaintenaceForm:=TLayoutinfoMaintenaceForm(nil);
LayoutinfoMaintenaceForm.show;
end;
去掉
2. var
3. LayoutInfoMaintenaceForm : TLayoutInfoMaintenaceForm;
在子窗体的关闭时间里写
LayoutInfoMaintenaceForm:=nil;
Action:=cafree;
Project MDIAPP.exe raised exception class EAccessViolation with message 'Access violation at address 00456BA2 in module 'MDIAPP.exe'. read of address 0000002F4',Process stoped.