码迷,mamicode.com
首页 > Windows程序 > 详细

C# 实现无焦点窗体(转载)

时间:2017-02-03 18:31:13      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:ice   extern   win   new   set   div   stat   sharp   int   

#region 无焦点窗体

[System.Runtime.InteropServices.DllImport("user32.dll")]
 private extern static IntPtr SetActiveWindow(IntPtr handle);
 private const int WM_ACTIVATE = 0x006;
 private const int WM_ACTIVATEAPP = 0x01C;
 private const int WM_NCACTIVATE = 0x086;
 private const int WA_INACTIVE = 0;
 private const int WM_MOUSEACTIVATE = 0x21;
 private const int MA_NOACTIVATE = 3;
 protected override void WndProc(ref Message m)
 {
 if (m.Msg == WM_MOUSEACTIVATE)
 {
 m.Result = new IntPtr(MA_NOACTIVATE);
 return;
 }
 else if (m.Msg == WM_NCACTIVATE)
 {
 if (((int)m.WParam & 0xFFFF) != WA_INACTIVE)
 {
 if (m.LParam != IntPtr.Zero)
 {
 SetActiveWindow(m.LParam);
 }
 else
 {
 SetActiveWindow(IntPtr.Zero);
 }
 }
 }
 base.WndProc(ref m);
 }

#endregion

 

C# 实现无焦点窗体(转载)

标签:ice   extern   win   new   set   div   stat   sharp   int   

原文地址:http://www.cnblogs.com/xiangxiong/p/6363149.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!