zoukankan      html  css  js  c++  java
  • winform的messagebox自动关闭的解决办法

    1、引包

         [DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
            private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
         
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
         
        public const int WM_CLOSE = 0x10;

    2、方法

    MessageBox.Show(“测试一下”,“error”);

      IntPtr ptr = FindWindow(null, "error");
      if (ptr != IntPtr.Zero)
      {
        PostMessage(ptr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
      }

     

  • 相关阅读:
    java 28
    java 28
    java 27
    java 27
    java 27
    java 27
    java 27
    java 27
    java 27
    java 27
  • 原文地址:https://www.cnblogs.com/mokongzei/p/10881089.html
Copyright © 2011-2022 走看看