主窗口过程。。。。
begin
Form2 :=Tform2.Create(nil);
try
if Form2.ShowModal=1 then
.....
finally
Form2.Free;
end;
子窗口
procedure ONButton1.Click(sender as object);
begin
ModalResult :=1;//返回值为1;
end;
一般我会这样做:
主窗口:
GetUser(username);
子窗口:
function GetUserName(Var username:string):boolean;
begin
with TDlgGetUser.Create(Application) do
try
result:=showmodal=mrOK;
if result then username:=edtUserName.text;
finally
free;
end;
end;