在一个窗体(非主窗体,后打开的)上放一个按钮,点击按钮关闭该窗体。我是设置 该按钮 modalresult 为 mrok/mrcancel
然后在 Tform.CloseQuery 中做关闭条件判断,警告对话框等 canclose:=true;有其他函数吗?

解决方案 »

  1.   

    比如提出退出,让用户 ok or cancel
      

  2.   

    模态窗可以设置 modalresult 且有用,非
    模态窗设置有用吗?其实也没什么大的用处,
    通过点击按钮来发送 关闭self 的消息。无非提示窗口需要关闭,让用户确定,或提示用户保存。
      

  3.   

    一个button1 modalresult 为 none button2 为 mrcancel
    procedure TForm1.button1Click(Sender:TObject);
    begin
         if true  then begin
             modalresult:=mrOk;
         end
         else begin 
             showmessage('条件有误');
         end;
    end;
      

  4.   

    就你题目的问题就是一行代码!DefWindowProc(Handle, WM_SYSCOMMAND, SC_CLOSE, 0);这样就关闭了。谢谢观赏。