News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

WM_KEYFIRST and WM_KEYDOWN

Started by shaikkareem, February 16, 2016, 10:50:03 PM

Previous topic - Next topic

shaikkareem

hi fellows,
while monitoring window messages through a window hook procedure, i faced this situation. the window procedure being called by the system when WM_KEYFIRST(0x0100) and WM_KEYDOWN(0x0100) messages are in the  thread message queue. i don't know how to distinguish between them because they both have same hex number that's why two time invocation of Hook procedure, which on comes earlier and later. please can someone help me to overcome this problem.

jj2007

WM_KEYFIRST is not a message, it is the start of an enumeration. What you see is WM_KEYDOWN defined as WM_KEYFIRST+0.

WM_KEYFIRST                          equ 100h
WM_KEYDOWN                           equ 100h
WM_KEYUP                             equ 101h
WM_CHAR                              equ 102h
WM_DEADCHAR                          equ 103h
WM_SYSKEYDOWN                        equ 104h
WM_SYSKEYUP                          equ 105h
WM_SYSCHAR                           equ 106h
WM_SYSDEADCHAR                       equ 107h
WM_KEYLAST                           equ 108h

shaikkareem

here, when i press a key on keyboard, as i said, called two times the callback (hook procedure). so i have to always ignore the first one ( as assumed it as WM_KEYFIRST) and consider the second one . or completely misunderstanding. please explain....and one more thing i want to know about specifying the range (because we talking about WM_KEYFIRST & WM_KEYLAST) in GetMessage and PeekMessage. what they actually means in all contexts.

dedndave

WM_KEYFIRST is the first value associated with low-level keyboard messages
WM_KEYLAST is the last value associated with low-level keyboard messages

they are not actually valid message constant names
they are used to filter low-level keyboard messages as a group

dedndave

the hook procedure is called when the key is pressed and again when it is released
if you wanted to provide complete support, you would need to examine both to provide auto-repeat

shaikkareem

still unclear on how i can distinguish them, they both have same lParam. the only changing bits are 0-15 -> the repeat count is always 1 if i keep pressed down and 30- the previous key state which is set on long press.

dedndave