在关闭窗口时有一个提示框,用户点确定再关闭,点取消就不关闭。怎么写?

解决方案 »

  1.   

    if(MessageBox("真的要关闭吗?",WB_IDYESNO)==IDNO)
         return;
    OnOK();
      

  2.   

    在窗体closequery事件中写上这个代码:
    if(MessageBox("真的要关闭吗?",WB_IDYESNO)==IDNO)
         CanClose:=false
     else CanClose:=true;
      

  3.   

    procedure TFrmMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      if mrNo = MessageDlg('现在要退出吗?', mtConfirmation, [mbYes, mbNo], 0) then
        Abort
      else
      begin
        CloseForm();
      end;
    end;