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

建材网站制作自媒体营销方式有哪些

建材网站制作,自媒体营销方式有哪些,免费注册企业邮箱域名,成都网站seo写在前面 介绍一个验证过的热键注册工具类,使用系统类库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.hkea.cn/news/309606/

相关文章:

  • 徐州有哪些做网站苏州网站建设费用
  • 统一企业信息管理系统网站直通车怎么开效果最佳
  • 武汉外贸网站建设公司外链相册
  • java做网站的权限管理seo描述是什么
  • 招聘网最新招聘信息网武汉seo计费管理
  • 直播软件开发源码重庆seo顾问
  • 公司网站如何做宣传百度视频推广怎么收费
  • 淄博市 网站建设报价郑州seo外包阿亮
  • 网络服务商是指什么网站优化排名工具
  • 网站优化的分析比较好的品牌策划公司有哪些
  • 国外比较好的资源网站电商运营推广是做什么的
  • 佛山房地产网站建设seo实战培训王乃用
  • 如何做可以赚钱的网站关键词如何快速排名
  • 深圳品牌做网站公司有哪些百度app推广
  • 重庆建设行业信息网站搜狗登录入口
  • 同仁行业网站建设报价北京做的好的seo公司
  • 陕西自助建站做网站郑州外语网站建站优化
  • 小型企业网站系统cilimao磁力猫最新版地址
  • 铁岭网站建设移动网站广东网站seo
  • 网站模板插件sem和seo
  • 用wordpress制作网站模板沈阳seo
  • 优化一个网站多少钱宜昌网站seo
  • 刚做的网站怎么才能搜索到枸橼酸西地那非片功效效及作用
  • 罗湖区网站公司专业模板建站
  • 哪有备案好的网站国产系统2345
  • 网站开发怎么让别人看到最新营销模式有哪些
  • ssm网站开发源码百度推广多少钱一个月
  • 手游门户网站建设appstore关键词优化
  • 齐河网站开发seo服务内容
  • 北京微信网站建设费用想卖产品怎么推广宣传