在设计的时候,我想按窗体的关闭按钮出现退出对话框,按OK按钮,退出程序,
按Cancel按钮,继续程序。该程序怎么写。

解决方案 »

  1.   

    if messagedlg('是否退出程,mtConfirmation,[mbYes, mbNo],0)=mrno then
        exit
    else
        close;
    end;
      

  2.   

    在ok的button的onclick事件中些这句代码:Application.Terminate
    在Cancel的button的onclick事件中些你的程序要继续执行的代码就可以了。
      

  3.   

    procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      if MessageBox(Handle, '是否退出?' , '提示', MB_YESNO  + MB_ICONQUESTION) = IDNO then
        CanClose := false;
    end;
      

  4.   

    if messagedlg('是否退出程,mtConfirmation,[mbYes, mbNo],0)=mryes then
         application.Terminate;
    end;
      

  5.   

    hch_45(HCH ~ahong.net~) 的方法比较好用。
      

  6.   

    在窗体的onClose事件中:if messagedlg('是否退出?',mtInformation,[mbYes,mbNo],0)=mrNo then action:=caNone;