function test(AHandle: THandle):wordbool; begin AHandle := Application.Handle; form1:=tform1.Create(application); try form1.ShowModal; if form1.ModalResult=mrOk then result:=true else result:=false; finally form1.Free; end; end;调用的时候 if test(Application.Handle)=true then showmessage('true') else showmessage('false'); try it!
function test(AHandle: THandle):wordbool; begin
AHandle := Application.Handle;
form1:=tform1.Create(application);
try
form1.ShowModal;
if form1.ModalResult=mrOk then
result:=true
else
result:=false;
finally
form1.Free;
end;
end;调用的时候
if test(Application.Handle)=true then
showmessage('true')
else
showmessage('false');
try it!
var
Form1: TForm1;放到工程文件里面的Test函数里面声明;
试了一下yoic的方法。
传参数的方法不行。
至于第二种方法,那么form1是个局部变量,应该也是不成的。