惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 我是程序员

Kubernetes集群安全概述 EventStore .NET API Client在使用线程池线程同步写入Event导致EventStore连接中断的问题研究 Silverlight下实现Windows8风格的进度条 如何确保Silverlight按照区域设定自动加载对应区域的资源 查看进程的启动参数 (转) 如何在Access2007中打开加密的Access2003数据库 业务流程不是需求(ZT) 如何取消ActiveReport的打印任务 开源license总结(转) 如何将文本文件读入到DataSet中 利用Eclipse调试JSP XML文件的DOCTYPE定义(转) - 我是程序员 - 博客园 如何定制Acegi验证框架的验证错误信息 别让Hibernate偷走了您的身份(转) Firefox下强制页面缓存失效的设置方法 - 我是程序员 - 博客园 有关Struts标签<html:cancel>使用的一点提示 - 我是程序员 - 博客园 Struts Commons-validator的validation.xml验证文件的配置指南(转) - 我是程序员 - 博客园 大型Web2.0站点构建技术初探(转) 面向对象分析设计的六十一条经验原则(转贴)
在WPF中如何注册热键
我是程序员 · 2009-07-09 · via 博客园 - 我是程序员

不说废话,直接看代码吧,其关键就是 System.Windows.Interop.HwndSource类。

第一步:注册热键,需要使用API函数,具体的参照网上的其它文章。唯一需要注意的是需要使用KeyInterop.VirtualKeyFromKey函数将

WPF的Key枚举转化为API函数可以使用的VirtualKeyCode :

注册热键API函数定义

 第二步:注册热键处理函数,主要的难点就在这里,在.NET的WinForm程序中一般使用重写Form的WinProc方法或者注册IMessageFilter来实现的,

但是在WPF中以上两种方式都无法获得热键消息的处理机会,除非是在WPF程序中隐藏一个常规的Form(最开始就是这么弄得,后来觉得实在是太丑陋了)

注册热键处理函数

 以上代码在Windows2008下测试通过。