zoukankan      html  css  js  c++  java
  • 如何禁用双击窗体图标关闭窗体

    这个问题来自论坛提问,.Net由于对WindowsAPI的透明度增强,很多Winform开发者都不太了解经典的win32消息方面的知识。

    所有窗体上的鼠标反映都可以用WndProc拦截,除了系统菜单、标题栏、系统按纽还包括客户区。

    1. using  System;
    2. using  System.Windows.Forms;
    3. using  System.Runtime.InteropServices;
    4. namespace  WindowsApplication1
    5. {
    6.      public  partial  class  Form1 : Form
    7.     {
    8.          public  Form1()
    9.         {
    10.             InitializeComponent();
    11.             
    12.         }
    13.         [DllImport( "user32.dll" )]
    14.          private   static   extern  IntPtr GetSystemMenu(IntPtr hWnd,  bool  bRevert);
    15.          protected   override   void  WndProc( ref    Message m)
    16.         {
    17.              if  (m.Msg == 0x112)
    18.             {
    19.                  if  (m.WParam.ToInt32() == 61539 || m.WParam.ToInt32() == 61587)
    20.                 {
    21.                     Console.WriteLine(m.WParam);
    22.                      return ;
    23.                 }
    24.             }
    25.              base .WndProc( ref    m);
    26.         }  
    27.     }
    28. }
  • 相关阅读:
    pytest-html报告自定义字段
    Python SMTP发送邮件
    IE浏览器兼容测试工具 IETester
    全局ID生成--雪花算法改进版
    全局ID生成--雪花算法
    spring-cloud-sleuth/zipkin
    14.跑批到某个点突然所有批都断批
    13.分布式锁在不同环境引发的坑
    spring-cloud-gateway
    spring-cloud-netflix-config
  • 原文地址:https://www.cnblogs.com/cl1024cl/p/6204870.html
Copyright © 2011-2022 走看看