//form1
procedure TForm1.Button1Click(Sender: TObject);
var
f2 : TForm2;
begin
f2 := TForm2.Create(Self);
f2.ShowModal;
f2.Free;
end;
//form2
function DoEnableWindow(Window: HWnd; Data: Longint): Bool; stdcall;
begin
if IsWindowVisible(Window) and
(not IsWindowEnabled(Window)) then
begin
EnableWindow(Window, True);
end;
Result := True;
end;
procedure TForm2.Timer1Timer(Sender: TObject);
var
h : THandle;
WindowList : Pointer;
begin
EnumThreadWindows(GetCurrentThreadID,@DoEnableWindow,0);
Timer1.Enabled := False;
end;
把他关闭之后再用非模态窗体打开就行啦!
repeat
Application.HandleMessage;
if Application.FTerminate then ModalResult := mrCancel else
if ModalResult <> 0 then CloseModal;
until ModalResult <> 0;
ShowModal的其中一部分代码,你说他要怎么取消!