我得程序是:
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
  ch:integer;
begin
   ch:=messagedlg('Are you sure exit?',mtconfirmation,[mbYes,mbNo],0);
   if ch=mrNo then exit
   else if ch=mrYes then
        begin
          Application.Terminate;
        end;
end;
我点击'否'时,系统还是退出,为什么?有何办法?

解决方案 »

  1.   

    procedure TF_main.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
    if application.messagebox('您确定要退出工程管理系统吗?','系统提示',mb_yesno+mb_iconquestion)=id_yes then
       begin
       //Endlogin;//修改操作员登录历史数据
       canclose:=true;
       end
     else
      begin
      canclose:=false;
      end;
    end;我是这么写的,
      

  2.   

    在formcloseQuery事件中定
    var
      ch:integer;
    begin
       ch:=messagedlg('Are you sure exit?',mtconfirmation,[mbYes,mbNo],0);
       if ch=mrNo then canclose:=false
       else if ch=mrYes then
            begin
              Application.Terminate;
            end;
      

  3.   

    改成:
    procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
    var
      ch:integer;
    begin
       ch:=messagedlg('Are you sure exit?',mtconfirmation,[mbYes,mbNo],0);
       if ch=mrNo then Action := caFree   {修改的语句}
       else if ch=mrYes then
            begin
              Application.Terminate;
            end;
    end;
      

  4.   

    to: shockjoy
      if ch=mrNo then Action := caFree   {修改的语句}???
      

  5.   

    if ch=mrNo then Action := caNone   {修改的语句}