对于关闭:
//点击主窗口的关闭按钮所触发的关闭事件,对应窗体的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 ;
}
}
//点击主窗口的关闭按钮所触发的关闭事件,对应窗体的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 ;
}
}
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;
}
}
private const int SC_MINIMIZE = 0xF020;//对应的值表示什么意思,还是自定义的
private const int SC_CLOSE = 0xF060;
#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