如何在单击窗体右上角的关闭按钮时不关闭窗体?

解决方案 »

  1.   

    在OnCloseQuery事件里面写
    CanClose := false;
      

  2.   

    最好在程序中设置一个变量,不允许退出的时候置为False,然后在窗体的OnCloseQuery事件中判断这个变量,如 CanClose := 变量;在正常情况需要退出时,将此变量置为True就行了。
      

  3.   

    ccrun(老妖)(www.ccrun.com)  才是正解.
      

  4.   

    procedure Tmain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
       if main.Visible=true then
       begin
           if messagedlg('要退出本系统吗?',mtconfirmation,[mbyes,mbno],0)=idno then
             canclose:=false;
       end;
    end;