﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Forcus on C++</title><link>http://www.cppblog.com/daiwei920/</link><description>Make everything as simple as possible, but not simpler. by Albert Einstein</description><language>zh-cn</language><lastBuildDate>Tue, 09 Jun 2026 17:48:53 GMT</lastBuildDate><pubDate>Tue, 09 Jun 2026 17:48:53 GMT</pubDate><ttl>60</ttl><item><title>测试按钮按键事件</title><link>http://www.cppblog.com/daiwei920/archive/2011/04/15/144326.html</link><dc:creator>CyberC++</dc:creator><author>CyberC++</author><pubDate>Fri, 15 Apr 2011 12:02:00 GMT</pubDate><guid>http://www.cppblog.com/daiwei920/archive/2011/04/15/144326.html</guid><wfw:comment>http://www.cppblog.com/daiwei920/comments/144326.html</wfw:comment><comments>http://www.cppblog.com/daiwei920/archive/2011/04/15/144326.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/daiwei920/comments/commentRss/144326.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/daiwei920/services/trackbacks/144326.html</trackback:ping><description><![CDATA[今天在工作中，需要检查内存泄漏，所以临时需要关闭应用程序 nicely . <br>我们设计游戏的Kernel 一般不要关闭它，它是一个不可见的APP，所以在程序的Framemove中加入了下面这个，快速解决了我的问题, 查到了这篇文章<br><br>To check if a key was pressed when you process a mouse message,<br>(GetKeyState(key) &amp; 0x8000) /* for example, key=VK_SHIFT */<br><br>This will get the state of the key *when the current message was<br>generated*. If you need to know whether it is pressed right now, use<br>GetAsyncKeyState().<br><br>If you need instead to check the state of the mouse button(s) when<br>processing keyboard messages, you can use:<br>(GetKeyState(VK_LBUTTON) &amp; 0x8000)<br>(GetKeyState(VK_RBUTTON) &amp; 0x8000)<br><br>Note: these will return the state of the *physical* left and right<br>buttons, which will be reversed if the user has switched them in the<br>mouse control panel.<br><br>I define macros to avoid scattering code with constants, and to get a<br>1 or 0 result:<br><br>#define WAS_PRESSED(key) ((GetKeyState(key) &amp; 0x8000) != 0)<br>#define IS_PRESSED(Key) ((GetAysncKeyState(key) &amp; 0x8000) != 0)<br>
<img src ="http://www.cppblog.com/daiwei920/aggbug/144326.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/daiwei920/" target="_blank">CyberC++</a> 2011-04-15 20:02 <a href="http://www.cppblog.com/daiwei920/archive/2011/04/15/144326.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>