SoFunction
Updated on 2025-03-07

C# Disable the method of closing a form by double-clicking the form icon

This article describes how C# disables the double-click form icon to close a form. Share it for your reference. The specific implementation method is as follows:

[DllImport("")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
protected override void WndProc(ref Message m)
{
 if ( == 0x112)
 {
  if (.ToInt32() == 61539 || .ToInt32() == 61587)
  {
   return;
  }
 }
 (ref m);
}

I hope this article will be helpful to everyone's C# programming.