I created this window from the parent window. I don’t want to create it every time, so I change the closing action to hide the window every time.
Just show it every time you want to use it.
namespace BiDaLock57L
{
public partial class MakeCardForm : Form
{
public MakeCardForm()
{
InitializeComponent();
}
//遍历msg,确定是x掉的,类似MFC
protected override void WndProc(ref Message m)
{
var WM_SYSCOMMAND = 0X112;
var SC_CLOSE = 0XF060;
if (m.Msg == WM_SYSCOMMAND && m.WParam == (IntPtr)SC_CLOSE)
{
MessageBox.Show("X 被按下了");
//this.Hide();
return;
}
base.WndProc(ref m);
}
}
}