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_KEYDOWN: repeatcount

Started by gelatine1, June 19, 2014, 05:10:50 AM

Previous topic - Next topic

gelatine1

I wanted to test the repeatcount part of the lparam parameter when the message loop found a WM_KEYDOWN. In the Msdn reference i read that bits 0-15 of lparam contain this:

Quote
The repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.

I tried to write the value of this lower word of lparam to my file like this:


mov ebx,lParam

mov ecx,[pmem]  ;[pmem] contains the address, [[pmem]] contains the value at that address
mov word ptr [ecx],bx 

;I write the contents of the [pmem] buffer to my file


Everything compiles and my program doesn't crash but although I have some issues with the output. Whenever I tried holding my key down (for 5 seconds). I simply got the output 01 in my file, several times although. Instead it should've been just a single 1C (for example) or am I wrong ?

Thanks in advance,
Jannes




dedndave

as i recall, the count indicates "it has repeated"   :P
try WM_CHAR, which is sent for each char, repeatedly

gelatine1

Whats in fact the difference between WM_CHAR and WM_KEYDOWN ?

What if my function is like this (pseudocode)

if uMsg==WM_KEYDOWN
print 2
else if uMsg==WM_CHAR
print 4


the output will always be 2 no matter which key is pressed ? (which would mean both messages are sent at the same moment) or could we expect an output like 24 (or 42) somehow ? (which would mean 2 different messages are sent)

Thanks in advance

qWord

Quote from: gelatine1 on June 20, 2014, 12:12:12 AM
Whats in fact the difference between WM_CHAR and WM_KEYDOWN ?
WM_CHAR is produced by TranslateMessage when receiving WM_KEYDOWN. Commonly this function is called in the message loop after GetMessage().
MREAL macros - when you need floating point arithmetic while assembling!