C#判断根据消息判断窗体的事件(WINFROM)

26 篇文章 0 订阅

直接在form加入下面代码 更改switch里的判断

 

 

  1.  public enum SysParam
  2.         {
  3.             MaxSize = 61488,
  4.             MinSize = 61472,
  5.             Close = 61536,
  6.             Restore=61728,
  7.             Top = 61443,
  8.             Down = 61446,
  9.             Left = 61441,
  10.             Right = 61442,
  11.             TitleClick = 61458,
  12.             TitleDoubleClick = 61490,
  13.             IconMenu=61587,
  14.             TopLeft=61444,
  15.             TopRight=61445,
  16.             DownLeft=61447,
  17.             DownRight=61448,
  18.             ScroolX=61574,
  19.             ScroolY=61559
  20.         }
  21.     
  22.         /// <summary>
  23.         /// 消息处理
  24.         /// </summary>
  25.         /// <param name="m"></param>
  26.         protected override void WndProc(ref Message m)
  27.         {
  28.             if (m.Msg == 0x0112)  //系统消息
  29.             {
  30.                 switch (m.WParam.ToInt32())
  31.                 {
  32.                     case (int)SysParam.Close:
  33.                         break;
  34.                     case (int)SysParam.MaxSize:
  35.                         break;
  36.                     case (int)SysParam.MinSize:
  37.                         break;
  38.                     case (int)SysParam.Restore:
  39.                         break;
  40.                     case (int)SysParam.Top:
  41.                         break;
  42.                     case (int)SysParam.Down:
  43.                         break;
  44.                     case (int)SysParam.Left:
  45.                         break;
  46.                     case (int)SysParam.Right:
  47.                         break;                    
  48.                     case (int)SysParam.TitleClick:
  49.                         break;
  50.                     case (int)SysParam.TitleDoubleClick:
  51.                         break;
  52.                     case (int)SysParam.IconMenu:
  53.                         break;
  54.                     case (int)SysParam.TopLeft:
  55.                         break;
  56.                     case (int)SysParam.TopRight:                      
  57.                         break;
  58.                     case (int)SysParam.DownLeft:                  
  59.                         break;
  60.                     case (int)SysParam.DownRight:                    
  61.                         break;
  62.                     case (int)SysParam.ScroolX:
  63.                         break;
  64.                     case (int)SysParam.ScroolY:
  65.                         break;
  66.                     default:
  67.                         listView1.Items.Add(m.WParam.ToInt32().ToString());
  68.                         break;
  69.                 }                
  70.             }
  71.             base.WndProc(ref m);
  72.         }        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值