﻿<?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>IT博客-Keep Faith-随笔分类-window编程</title><link>http://www.cnitblog.com/sardis/category/5519.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 04 Oct 2011 23:08:15 GMT</lastBuildDate><pubDate>Tue, 04 Oct 2011 23:08:15 GMT</pubDate><ttl>60</ttl><item><title>捕捉键盘输入的简单办法</title><link>http://www.cnitblog.com/sardis/archive/2007/06/02/Capture_Keyboard.html</link><dc:creator>sardis</dc:creator><author>sardis</author><pubDate>Sat, 02 Jun 2007 14:18:00 GMT</pubDate><guid>http://www.cnitblog.com/sardis/archive/2007/06/02/Capture_Keyboard.html</guid><wfw:comment>http://www.cnitblog.com/sardis/comments/27943.html</wfw:comment><comments>http://www.cnitblog.com/sardis/archive/2007/06/02/Capture_Keyboard.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/sardis/comments/commentRss/27943.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/sardis/services/trackbacks/27943.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;">比较有效的键盘输入捕捉方法为使用hook函数，然后这种方法比较复杂，今天在网上早到一种新的简单的捕捉方法。<br>
即可以在PreTranslateMessage(MSG* pMsg)中进行处理：<br>
如： <br>{<br>&nbsp;&nbsp; &nbsp;// TODO: Add your specialized code here and/or call the base class<br>&nbsp;&nbsp; &nbsp;if(pMsg-&gt;message == WM_KEYDOWN) {<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;switch(pMsg-&gt;wParam) {<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case VK_LEFT:<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*Command=0x01;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SendSocket.SendTo(Command,1,LINKPORT,videoconfig.m_ipaddress);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;break;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case VK_RIGHT:<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*Command=0x02;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SendSocket.SendTo(Command,1,LINKPORT,videoconfig.m_ipaddress);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;break;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case VK_DOWN:<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*Command=0x04;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SendSocket.SendTo(Command,1,LINKPORT,videoconfig.m_ipaddress);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;break;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case VK_UP:<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*Command=0x03;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SendSocket.SendTo(Command,1,LINKPORT,videoconfig.m_ipaddress);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;break;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case VK_SPACE:<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*Command=0x05;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SendSocket.SendTo(Command,1,LINKPORT,videoconfig.m_ipaddress);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return TRUE;<br>&nbsp;&nbsp; &nbsp;}
<br></span><img src ="http://www.cnitblog.com/sardis/aggbug/27943.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/sardis/" target="_blank">sardis</a> 2007-06-02 22:18 <a href="http://www.cnitblog.com/sardis/archive/2007/06/02/Capture_Keyboard.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>