procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Application.MessageBox('您确定退出吗?','提示',MB_OKCANCEL)=2 then
 Exit;
end;当我关闭窗体的时候  出现对话框  ,我点取消他也退出窗体
  怎么回事啊?

解决方案 »

  1.   

    Procedure TForm1.FormCloseQuery(Sender: TObject; Var CanClose: Boolean);
    begin
    if Application.MessageBox('您确定退出吗?','提示',MB_OKCANCEL)=IDCANCEL then
     canclose:=false;
    end;
      

  2.   

    procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
    if Application.MessageBox('您确定退出吗?','提示',MB_OKCANCEL)=mrOK then
     Action := caFree
    else
     Action := caNone;
    end;
      

  3.   

    写快了mrOK改idOK(或者1) -_- 不过mrOK好像也行.
      

  4.   

    if Application.MessageBox('您确定退出吗?','提示',MB_OKCANCEL)=idok then
    begin
      action:=cafree;
    end else
    begin
      action:=canone;
    end;