想设计点击一个按钮弹出一个表单窗口,为什么用showmodal和show总出现错误??例程如下:procedure TForm1.Button1Click(Sender: TObject);
begin
SIMON.Show;//或者showmodal
end;
运行代码后有如下错误提示:project project1.exe raised exception class EAccessViolation with message
'AccessViolation at address 00462A7E in module 'project1.exe '.Read of adree '000000'
process......以下代码是可以正确执行的:procedure TForm1.Button1Click(Sender: TObject);
begin
Application.CreateForm(TSIMON,SIMON);
SIMON.ShowModal;
SIMON.free;
end;
begin
SIMON.Show;//或者showmodal
end;
运行代码后有如下错误提示:project project1.exe raised exception class EAccessViolation with message
'AccessViolation at address 00462A7E in module 'project1.exe '.Read of adree '000000'
process......以下代码是可以正确执行的:procedure TForm1.Button1Click(Sender: TObject);
begin
Application.CreateForm(TSIMON,SIMON);
SIMON.ShowModal;
SIMON.free;
end;
begin
if SIMON = nil then SIMON := TSIMON.Create(Application);
SIMON.Show;//或者showmodal
end;
一般MDI的窗体都用show
begin
if not Assigned(SIMON) then
SIMON := TSIMON.Create(Application);
SIMON.Show;//或者showmodal
end;