在关闭form时,怎样让用户选择退出或者不退出?
我在form的close事件里写的MessageDlg不行,无论怎么选都退出了form。
是不是在closeQuery里面写询问的代码?

解决方案 »

  1.   

    OnClose事件中有一个参数:Action:TCloseAction;把它设置成caNone,窗口就不会关闭,你可以在MessageDlg中加入一句:Action:=caNone;
      

  2.   

    OnClose事件中有一个参数:Action:TCloseAction;把它设置成caNone
      

  3.   

    //在OnClose加入
      if messagedlg('确认退出吗?',mtconfirmation,[mbyes,mbno],0)=mryes then
        Application.Terminate
      else
        Action:=caNone;
      

  4.   

    //在OnClose加入
      if messagedlg('确认退出吗?',mtconfirmation,[mbyes,mbno],0)=mryes then
        Action:=caFree   
      else
        Action:=caNone;
      

  5.   

    在CloseQuery事件里加入:
    if MessageDlg('确认退出吗?',mtconfirmation,[mbyes,mbno],0)=mryes  then
      Action:=cafree
    else
      abort;