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

网站推广关键词排名app开发大概要多少钱

网站推广关键词排名,app开发大概要多少钱,小学网站源码,西安制作网站公司哪家好写在前面 介绍一个验证过的热键注册工具类,使用系统类库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/214359/

相关文章:

  • 福田莲花北网站建设七牛云存储 wordpress 没用
  • 基于php做的网站下载网站建设相关资讯
  • 厦门网站的制作三种常见的网络营销方式
  • 高性能网站建设进阶指南制作微信小程序
  • 做网页网站怎么样辽宁做网站的公司
  • 怎样查看网站是否被百度收录企业网站建设相关书籍在线阅读
  • 可以做推广的网站wordpress 太原
  • 网站确定关键词 如何做网页源代码搜索关键字
  • 广东网站开发建设哪个网站做美食视频网站好
  • 网站用不用备案百度 营销推广是做什么的
  • 企业适合用模板网站一级域名指向wordpress页面
  • 5m带宽做视频网站wordpress中修改链接
  • 做网站端口内容无法替换js制作简单的公司首页
  • 如何自学做网站wordpress 导出表单
  • 好用的ppt模板免费下载网站seo页面优化技术
  • 亳州电商网站建设园区做网站
  • 做网站好公司哪家好高校门户网站建设问题
  • C2C电子商务网站管理系统网站建设需要学习什么
  • 江西网站建设上海本地app推荐
  • 智能商标logo设计aso优化什么意思
  • 电子商务网站经营特色分析的主要内容包括手机软件网站
  • 百度网站排名搜行者seo中华网军事网
  • 天津电商网站开发怎么自己建设一个网站
  • 网站制作新手通桥小学的网站建设
  • 做ppt的网站有哪些内容中职计算机专业主要学什么
  • 学做网站需要懂什么网站做充值和提现
  • 在哪做网站好建设项目咨询公司网站
  • 广州网站营销推广设计wordpress首页js怎么添加
  • 苏州网站优化哪家好东华网站开发
  • 西宁北京网站建设专业公司网站 南通