当前位置: 首页 > news >正文

企业应该如何进行网站建设单页网站怎么做外链

企业应该如何进行网站建设,单页网站怎么做外链,微信营销案例,html企业网站开发写在前面 介绍一个验证过的热键注册工具类,使用系统类库user32.dll中的RegisterHotkey函数来实现全局热键的注册。 代码实现 [Flags]public enum KeyModifiers{Alt 1,Control 2,Shift 4,Windows 8,NoRepeat 0x4000}public static class HotKeyHelper{[DllImp…

写在前面

介绍一个验证过的热键注册工具类,使用系统类库user32.dll中的RegisterHotkey函数来实现全局热键的注册。

代码实现

    [Flags]public enum KeyModifiers{Alt = 1,Control = 2,Shift = 4,Windows = 8,NoRepeat = 0x4000}public static class HotKeyHelper{[DllImport("user32", SetLastError = true)]private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);[DllImport("user32", SetLastError = true)]private static extern bool UnregisterHotKey(IntPtr hWnd, int id);private static int _id = 0;private static volatile MessageWindow _wnd;private static volatile IntPtr _hwnd;private static ManualResetEvent _windowReadyEvent = new ManualResetEvent(false);static HotKeyHelper(){Thread messageLoop = new Thread(delegate (){Application.Run(new MessageWindow());});messageLoop.Name = "MessageLoopThread";messageLoop.IsBackground = true;messageLoop.Start();}public static event EventHandler<HotKeyEventArgs> HotKeyPressed;public static int RegisterHotKey(Keys key, KeyModifiers modifiers){_windowReadyEvent.WaitOne();int id = System.Threading.Interlocked.Increment(ref _id);_wnd.Invoke(new RegisterHotKeyDelegate(RegisterHotKeyInternal), _hwnd, id, (uint)modifiers, (uint)key);return id;}public static void UnregisterHotKey(int id){_wnd.Invoke(new UnRegisterHotKeyDelegate(UnRegisterHotKeyInternal), _hwnd, id);}delegate void RegisterHotKeyDelegate(IntPtr hwnd, int id, uint modifiers, uint key);delegate void UnRegisterHotKeyDelegate(IntPtr hwnd, int id);private static void RegisterHotKeyInternal(IntPtr hwnd, int id, uint modifiers, uint key){RegisterHotKey(hwnd, id, modifiers, key);}private static void UnRegisterHotKeyInternal(IntPtr hwnd, int id){UnregisterHotKey(_hwnd, id);}private static void OnHotKeyPressed(HotKeyEventArgs e){if (HotKeyHelper.HotKeyPressed != null){HotKeyHelper.HotKeyPressed(null, e);}}private class MessageWindow : Form{public MessageWindow(){_wnd = this;_hwnd = this.Handle;_windowReadyEvent.Set();}protected override void WndProc(ref Message m){if (m.Msg == WM_HOTKEY){HotKeyEventArgs e = new HotKeyEventArgs(m.LParam);HotKeyHelper.OnHotKeyPressed(e);}base.WndProc(ref m);}protected override void SetVisibleCore(bool value){// Ensure the window never becomes visiblebase.SetVisibleCore(false);}private const int WM_HOTKEY = 0x312;}}public class HotKeyEventArgs : EventArgs{public readonly Keys Key;public readonly KeyModifiers Modifiers;public HotKeyEventArgs(Keys key, KeyModifiers modifiers){this.Key = key;this.Modifiers = modifiers;}public HotKeyEventArgs(IntPtr hotKeyParam){uint param = (uint)hotKeyParam.ToInt64();Key = (Keys)((param & 0xffff0000) >> 16);Modifiers = (KeyModifiers)(param & 0x0000ffff);}}

调用示例

        void RegisterHotKeyTest(){HotKeyHelper.RegisterHotKey(Keys.B, KeyModifiers.Alt);HotKeyHelper.HotKeyPressed += new EventHandler<HotKeyEventArgs>(OnHotKeyPressed);}void OnHotKeyPressed(object sender, HotKeyEventArgs e){MessageBox.Show("Alt + B");}

执行结果

http://www.yayakq.cn/news/410798/

相关文章:

  • 建立公司网站多少钱有什么软件可以制作图片
  • 滨州建网站公司厦门网站建设咨询
  • 前期的网站建设的难度衡阳营养师报考网站
  • 有网址如何做网站赚钱前端可以做什么毕业设计
  • 非交互式网站备案杭州集团公司网站制作
  • 设计一套网站多少钱文创产品设计说明
  • 做网站如何给图片命名企业网站建设规划书
  • 旅游网站建设项目规划书网页制作教程田田田田田田田田田田田田田田
  • 上海手机网站建设电话咨询wordpress 文章列表插件
  • 高端网站建设口碑页面设计分析
  • 阿里指数网站福州开发网站公司
  • 域名注册哪个网站便宜wordpress脚本
  • 单页网站优化做网站的工作要求
  • 网站建设公司湖南工信部网站备案查通知
  • 做网站思想在线创建网站免费网站
  • 广告设计网站排行榜前十名有哪些自定义网站建设团队
  • 南京网站开发选南京乐识赞旅游网站建设方案两百字
  • 网站都是哪里找的wordpress 引入js
  • 新网站开发费用网站开发能封装成app吗
  • wordpress整个网站响应速度慢网络推广公司取名
  • 建设个人银行网站南宁网站建设是什么意思
  • 吉林专业做网站太原网站开发团队
  • 贷款公司如何做网站注册公注册公司流程和费用
  • 农业行业网站模板wordpress模板双响
  • jsp开发的网站外贸网站建设价格怎么样
  • 德国购物网站大全经典的公司简介
  • 广州网站推广wordpress 更改端口
  • 郑州网站优化汉狮网络天津企业网站建设
  • 网站建设和网络优化商业网站建设案例课程下载
  • mmd怎么做下载网站什么是品牌网站建设