Method for C to realize WinForm prohibition of maximizing minimizing double clicking title bar double clicking icon and other operations

  • 2021-07-26 08:46:19
  • OfStack

In this paper, an example of C # to achieve WinForm prohibition maximization, minimization, double-click title bar, double-click icon and other operations. Share it for your reference. The specific implementation method is as follows:


protected override void WndProc(ref Message m)
{   
 if (m.Msg==0x112)
 {
  switch ((int) m.WParam)
  {
   // Disable double-clicking the title bar to close the form 
   case 0xF063:
   case 0xF093:
    m.WParam = IntPtr.Zero;
    break;
   // Disable dragging and dropping the title bar to restore the form 
   case 0xF012:
   case 0xF010:
    m.WParam = IntPtr.Zero;
    break;
   // Do not double-click the title bar 
   case 0xf122:
    m.WParam = IntPtr.Zero;
    break;
   // Disable Close Button 
   case 0xF060:
    m.WParam = IntPtr.Zero;
    break;
   // Disable Maximize Button 
   case 0xf020:
    m.WParam = IntPtr.Zero;
    break;
   // Disable Minimize Button 
   case 0xf030:
    m.WParam = IntPtr.Zero;
    break;
   // Disable Restore Button 
   case 0xf120:
    m.WParam = IntPtr.Zero;
    break;
   }
 }   
 base.WndProc(ref m);
}

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


Related articles: