ygm8611 2016-03-17 13:36 采纳率: 0%
浏览 1561

Delphi中我在Form里新建了一个Button用来关闭exe应用程序。

Delphi中我在Form里新建了一个Button用来关闭exe应用程序。
然后我要求点击按钮有提示问是否要删除,另外点击Form上的关闭按钮也要有一样的提示
如何做?

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-03-17 15:20
    关注
    procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      case Application.MessageBox('确定退出系统?','询问',35) of
        6:
          begin
            ShowMessage('按了是,窗口关闭');
            CanClose:=True;
          end;
        7:
          begin
            ShowMessage('按了否,返回登陆窗口');
            CanClose:=True;
            //这里写上你的登陆窗口调用代码
            ShowMessage('登陆窗口出现了');
          end;
        2:
          begin
            ShowMessage('按了取消,窗口不关闭');
            CanClose:=False;
          end;
      end;
    end; 
    

    在你的按钮上也写form.Close();

    评论

报告相同问题?