对于关闭:
//点击主窗口的关闭按钮所触发的关闭事件,对应窗体的Closing事件
private void Main_closingclick(object sender, System.ComponentModel.CancelEventArgs e)
{
// Initializes the variables to pass to the MessageBox.Show method. string message = "您确定要退出本程序吗?";
string caption = "关闭程序信息提示";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result; // Displays the MessageBox. result = MessageBox.Show(this, message, caption, buttons,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 
MessageBoxOptions.RtlReading); if(result == DialogResult.Yes)
{ // Closes the parent form. Application.Exit();

               //back the parent form
}
if (result == DialogResult.No)
{
e.Cancel = true ;
      
  
}
}

解决方案 »

  1.   

    重载窗体的 WndProc方法,具体参考下面: private const int SC_MINIMIZE = 0xF020;
    private const int SC_CLOSE    = 0xF060; protected override void WndProc(ref Message m)
    { switch(m.WParam.ToInt32())
    {
    case SC_MINIMIZE:
    //点击最小化;
    MessageBox.Show("Min");
    m.Result = IntPtr.Zero;
    break;
    case SC_CLOSE:
    //关闭
    MessageBox.Show("Close");
    m.Result = IntPtr.Zero;
    break;
    default:
    base.WndProc(ref m);
    break;
    }
    }
      

  2.   

    楼上兄弟能不能说明下这两个呢,不懂,:(
    private const int SC_MINIMIZE = 0xF020;//对应的值表示什么意思,还是自定义的
    private const int SC_CLOSE    = 0xF060;
      

  3.   

    原来如此,不过看上去好头疼呢,都涉及到底层定义了,:(
    #define  SC_MINIMIZE   0xF020 
    #define  SC_MAXIMIZE   0xF030 参考:
    http://canada.landoleet.org/docs/pub/public_sdk/html/platform_8h.html
    http://canada.landoleet.org/docs/pub/public_sdk/html/platform_8h-source.html
      

  4.   

    简单的,就是在你close 或closeing 事件中,写你要的特效代码TheAres斑竹的是使用消息的一种方法.不算底层,只是没有封装的SDK消息通讯,是真正做WINFORM开发的必备知识,建议如果要做WINFORM开发看看,要不做到后来要吃亏的.