SetWindowsHookEx回调函数 ( 积分: 30 )

  • 主题发起人 主题发起人 Angell1124
  • 开始时间 开始时间
A

Angell1124

Unregistered / Unconfirmed
GUEST, unregistred user!
在使用SetWindowsHookEx中使用的回调函数中的wParam和lParam中的类型可以赋给什么类型和它们的具体含意。谢谢,本人分数不多。
 
在使用SetWindowsHookEx中使用的回调函数中的wParam和lParam中的类型可以赋给什么类型和它们的具体含意。谢谢,本人分数不多。
 
看看这个例子<br>http://www.2ccc.com/article.asp?articleid=1845
 
HOOK类型很多,不知你用哪一种,全说须大篇幅<br>MSDN中有<br>找Win32 Hooks<br>再找你用的那一种
 
我说的是直接用setwindowshookex设置钩子,然后在这个函数里不是要用到一个回调函数吗, 我想怎么把wparam和lparam读出来但不知道怎么设置类型来读这个。我设的是键盘钩子具体说一下。
 
From MSDN:<br><br>code <br>Specifies a code the hook procedure uses to determine how to process the message. This parameter can be one of the following values: Value Meaning <br>HC_ACTION The wParam and lParam parameters contain information about a keystroke message. <br>HC_NOREMOVE The wParam and lParam parameters contain information about a keystroke message, and the keystroke message has not been removed from the message queue. (An application called the PeekMessage function, specifying the PM_NOREMOVE flag.) <br><br><br>If code is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx. <br><br>wParam <br>Specifies the virtual-key code of the key that generated the keystroke message. <br>lParam <br>Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. This parameter can be a combination of the following values: Value Description <br>0–15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's holding down the key. <br>16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM). <br>24 Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0. <br>25–28 Reserved. <br>29 Specifies the context code. The value is 1 if the alt key is down; otherwise, it is 0. <br>30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up. <br>31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released.
 
谁给我一份setwindowshookex回调函数中aParam的转换函数。设的是键盘钩子,我想得到我按下的是什么键。
 
下载<br>http://www.2ccc.com/article.asp?articleid=2067<br>由于匆忙,这个包中带的控件有点问题,我更新了。升级后的控件明天可以下载了。
 
干嘛要转换啊<br>查一查Windows头文件<br><br> &nbsp;{$EXTERNALSYM VK_LBUTTON}<br> &nbsp;VK_LBUTTON = 1;<br> &nbsp;{$EXTERNALSYM VK_RBUTTON}<br> &nbsp;VK_RBUTTON = 2;<br> &nbsp;{$EXTERNALSYM VK_CANCEL}<br> &nbsp;VK_CANCEL = 3;<br> &nbsp;{$EXTERNALSYM VK_MBUTTON}<br> &nbsp;VK_MBUTTON = 4; &nbsp;{ NOT contiguous with L &amp; RBUTTON }<br> &nbsp;{$EXTERNALSYM VK_BACK}<br> &nbsp;VK_BACK = 8;<br> &nbsp;{$EXTERNALSYM VK_TAB}<br> &nbsp;VK_TAB = 9;<br> &nbsp;{$EXTERNALSYM VK_CLEAR}<br> &nbsp;VK_CLEAR = 12;<br> &nbsp;{$EXTERNALSYM VK_RETURN}<br> &nbsp;VK_RETURN = 13;<br> &nbsp;{$EXTERNALSYM VK_SHIFT}<br> &nbsp;VK_SHIFT = $10;<br> &nbsp;{$EXTERNALSYM VK_CONTROL}<br> &nbsp;VK_CONTROL = 17;<br> &nbsp;{$EXTERNALSYM VK_MENU}<br> &nbsp;VK_MENU = 18;<br> &nbsp;{$EXTERNALSYM VK_PAUSE}<br> &nbsp;VK_PAUSE = 19;<br> &nbsp;{$EXTERNALSYM VK_CAPITAL}<br> &nbsp;VK_CAPITAL = 20;<br> &nbsp;{$EXTERNALSYM VK_KANA }<br> &nbsp;VK_KANA = 21;<br> &nbsp;{$EXTERNALSYM VK_HANGUL }<br> &nbsp;VK_HANGUL = 21;<br> &nbsp;{$EXTERNALSYM VK_JUNJA }<br> &nbsp;VK_JUNJA = 23;<br> &nbsp;{$EXTERNALSYM VK_FINAL }<br> &nbsp;VK_FINAL = 24;<br> &nbsp;{$EXTERNALSYM VK_HANJA }<br> &nbsp;VK_HANJA = 25;<br> &nbsp;{$EXTERNALSYM VK_KANJI }<br> &nbsp;VK_KANJI = 25;<br> &nbsp;{$EXTERNALSYM VK_CONVERT }<br> &nbsp;VK_CONVERT = 28;<br> &nbsp;{$EXTERNALSYM VK_NONCONVERT }<br> &nbsp;VK_NONCONVERT = 29;<br> &nbsp;{$EXTERNALSYM VK_ACCEPT }<br> &nbsp;VK_ACCEPT = 30;<br> &nbsp;{$EXTERNALSYM VK_MODECHANGE }<br> &nbsp;VK_MODECHANGE = 31;<br> &nbsp;{$EXTERNALSYM VK_ESCAPE}<br> &nbsp;VK_ESCAPE = 27;<br> &nbsp;{$EXTERNALSYM VK_SPACE}<br> &nbsp;VK_SPACE = $20;<br> &nbsp;{$EXTERNALSYM VK_PRIOR}<br> &nbsp;VK_PRIOR = 33;<br> &nbsp;{$EXTERNALSYM VK_NEXT}<br> &nbsp;VK_NEXT = 34;<br> &nbsp;{$EXTERNALSYM VK_END}<br> &nbsp;VK_END = 35;<br> &nbsp;{$EXTERNALSYM VK_HOME}<br> &nbsp;VK_HOME = 36;<br> &nbsp;{$EXTERNALSYM VK_LEFT}<br> &nbsp;VK_LEFT = 37;<br> &nbsp;{$EXTERNALSYM VK_UP}<br> &nbsp;VK_UP = 38;<br> &nbsp;{$EXTERNALSYM VK_RIGHT}<br> &nbsp;VK_RIGHT = 39;<br> &nbsp;{$EXTERNALSYM VK_DOWN}<br> &nbsp;VK_DOWN = 40;<br> &nbsp;{$EXTERNALSYM VK_SELECT}<br> &nbsp;VK_SELECT = 41;<br> &nbsp;{$EXTERNALSYM VK_PRINT}<br> &nbsp;VK_PRINT = 42;<br> &nbsp;{$EXTERNALSYM VK_EXECUTE}<br> &nbsp;VK_EXECUTE = 43;<br> &nbsp;{$EXTERNALSYM VK_SNAPSHOT}<br> &nbsp;VK_SNAPSHOT = 44;<br> &nbsp;{$EXTERNALSYM VK_INSERT}<br> &nbsp;VK_INSERT = 45;<br> &nbsp;{$EXTERNALSYM VK_DELETE}<br> &nbsp;VK_DELETE = 46;<br> &nbsp;{$EXTERNALSYM VK_HELP}<br> &nbsp;VK_HELP = 47;<br>{ VK_0 thru VK_9 are the same as ASCII '0' thru '9' ($30 - $39) }<br>{ VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' ($41 - $5A) }<br> &nbsp;{$EXTERNALSYM VK_LWIN}<br> &nbsp;VK_LWIN = 91;<br> &nbsp;{$EXTERNALSYM VK_RWIN}<br> &nbsp;VK_RWIN = 92;<br> &nbsp;{$EXTERNALSYM VK_APPS}<br> &nbsp;VK_APPS = 93;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD0}<br> &nbsp;VK_NUMPAD0 = 96;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD1}<br> &nbsp;VK_NUMPAD1 = 97;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD2}<br> &nbsp;VK_NUMPAD2 = 98;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD3}<br> &nbsp;VK_NUMPAD3 = 99;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD4}<br> &nbsp;VK_NUMPAD4 = 100;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD5}<br> &nbsp;VK_NUMPAD5 = 101;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD6}<br> &nbsp;VK_NUMPAD6 = 102;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD7}<br> &nbsp;VK_NUMPAD7 = 103;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD8}<br> &nbsp;VK_NUMPAD8 = 104;<br> &nbsp;{$EXTERNALSYM VK_NUMPAD9}<br> &nbsp;VK_NUMPAD9 = 105;<br> &nbsp;{$EXTERNALSYM VK_MULTIPLY}<br> &nbsp;VK_MULTIPLY = 106;<br> &nbsp;{$EXTERNALSYM VK_ADD}<br> &nbsp;VK_ADD = 107;<br> &nbsp;{$EXTERNALSYM VK_SEPARATOR}<br> &nbsp;VK_SEPARATOR = 108;<br> &nbsp;{$EXTERNALSYM VK_SUBTRACT}<br> &nbsp;VK_SUBTRACT = 109;<br> &nbsp;{$EXTERNALSYM VK_DECIMAL}<br> &nbsp;VK_DECIMAL = 110;<br> &nbsp;{$EXTERNALSYM VK_DIVIDE}<br> &nbsp;VK_DIVIDE = 111;<br> &nbsp;{$EXTERNALSYM VK_F1}<br> &nbsp;VK_F1 = 112;<br> &nbsp;{$EXTERNALSYM VK_F2}<br> &nbsp;VK_F2 = 113;<br> &nbsp;{$EXTERNALSYM VK_F3}<br> &nbsp;VK_F3 = 114;<br> &nbsp;{$EXTERNALSYM VK_F4}<br> &nbsp;VK_F4 = 115;<br> &nbsp;{$EXTERNALSYM VK_F5}<br> &nbsp;VK_F5 = 116;<br> &nbsp;{$EXTERNALSYM VK_F6}<br> &nbsp;VK_F6 = 117;<br> &nbsp;{$EXTERNALSYM VK_F7}<br> &nbsp;VK_F7 = 118;<br> &nbsp;{$EXTERNALSYM VK_F8}<br> &nbsp;VK_F8 = 119;<br> &nbsp;{$EXTERNALSYM VK_F9}<br> &nbsp;VK_F9 = 120;<br> &nbsp;{$EXTERNALSYM VK_F10}<br> &nbsp;VK_F10 = 121;<br> &nbsp;{$EXTERNALSYM VK_F11}<br> &nbsp;VK_F11 = 122;<br> &nbsp;{$EXTERNALSYM VK_F12}<br> &nbsp;VK_F12 = 123;<br> &nbsp;{$EXTERNALSYM VK_F13}<br> &nbsp;VK_F13 = 124;<br> &nbsp;{$EXTERNALSYM VK_F14}<br> &nbsp;VK_F14 = 125;<br> &nbsp;{$EXTERNALSYM VK_F15}<br> &nbsp;VK_F15 = 126;<br> &nbsp;{$EXTERNALSYM VK_F16}<br> &nbsp;VK_F16 = 127;<br> &nbsp;{$EXTERNALSYM VK_F17}<br> &nbsp;VK_F17 = 128;<br> &nbsp;{$EXTERNALSYM VK_F18}<br> &nbsp;VK_F18 = 129;<br> &nbsp;{$EXTERNALSYM VK_F19}<br> &nbsp;VK_F19 = 130;<br> &nbsp;{$EXTERNALSYM VK_F20}<br> &nbsp;VK_F20 = 131;<br> &nbsp;{$EXTERNALSYM VK_F21}<br> &nbsp;VK_F21 = 132;<br> &nbsp;{$EXTERNALSYM VK_F22}<br> &nbsp;VK_F22 = 133;<br> &nbsp;{$EXTERNALSYM VK_F23}<br> &nbsp;VK_F23 = 134;<br> &nbsp;{$EXTERNALSYM VK_F24}<br> &nbsp;VK_F24 = 135;<br> &nbsp;{$EXTERNALSYM VK_NUMLOCK}<br> &nbsp;VK_NUMLOCK = 144;<br> &nbsp;{$EXTERNALSYM VK_SCROLL}<br> &nbsp;VK_SCROLL = 145;<br>{ VK_L &amp; VK_R - left and right Alt, Ctrl and Shift virtual keys.<br> &nbsp;Used only as parameters to GetAsyncKeyState() and GetKeyState().<br> &nbsp;No other API or message will distinguish left and right keys in this way. }<br> &nbsp;{$EXTERNALSYM VK_LSHIFT}<br> &nbsp;VK_LSHIFT = 160;<br> &nbsp;{$EXTERNALSYM VK_RSHIFT}<br> &nbsp;VK_RSHIFT = 161;<br> &nbsp;{$EXTERNALSYM VK_LCONTROL}<br> &nbsp;VK_LCONTROL = 162;<br> &nbsp;{$EXTERNALSYM VK_RCONTROL}<br> &nbsp;VK_RCONTROL = 163;<br> &nbsp;{$EXTERNALSYM VK_LMENU}<br> &nbsp;VK_LMENU = 164;<br> &nbsp;{$EXTERNALSYM VK_RMENU}<br> &nbsp;VK_RMENU = 165;<br> &nbsp;{$EXTERNALSYM VK_PROCESSKEY}<br> &nbsp;VK_PROCESSKEY = 229;<br> &nbsp;{$EXTERNALSYM VK_ATTN}<br> &nbsp;VK_ATTN = 246;<br> &nbsp;{$EXTERNALSYM VK_CRSEL}<br> &nbsp;VK_CRSEL = 247;<br> &nbsp;{$EXTERNALSYM VK_EXSEL}<br> &nbsp;VK_EXSEL = 248;<br> &nbsp;{$EXTERNALSYM VK_EREOF}<br> &nbsp;VK_EREOF = 249;<br> &nbsp;{$EXTERNALSYM VK_PLAY}<br> &nbsp;VK_PLAY = 250;<br> &nbsp;{$EXTERNALSYM VK_ZOOM}<br> &nbsp;VK_ZOOM = 251;<br> &nbsp;{$EXTERNALSYM VK_NONAME}<br> &nbsp;VK_NONAME = 252;<br> &nbsp;{$EXTERNALSYM VK_PA1}<br> &nbsp;VK_PA1 = 253;<br> &nbsp;{$EXTERNALSYM VK_OEM_CLEAR}<br> &nbsp;VK_OEM_CLEAR = 254;
 
谢谢各位,但hxb_leiyuan的控件我好像下不了了。
 
hxb_leiyuan someset 我都加分了。谢谢。
 
后退
顶部