PDA

View Full Version : WinAPI WM_KEYDOWN how to detect Alt of left



lordzero
03-04-2008, 11:08 PM
Hello

I'm using WinAPI...



wm_keydown:
begin


if &#40;GetKeyState&#40;&#40;VK_MENU&#41;&#41; <> 0&#41; and &#40;wParam = VK_RETURN&#41; then
begin
//code here
end;


how to detect the alt of left?

i tried VK_LMENU but dont get sucess...

suggestions?

Greetings

JernejL
04-04-2008, 06:49 PM
on wm_keydown call GetKeyboardState and figure out which key was pressed / depressed from that structure.

noeska
04-04-2008, 07:06 PM
http://www.delphifaq.com/faq/delphi_windows_API/f359.shtml

VK_MENU should be the alt. Also available in L and R version.

Mirage
04-04-2008, 08:35 PM
You may check the value of lParam. Especially the following bits:
16-23 - Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
24 - Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.

lordzero
05-04-2008, 04:37 AM
I've changed to this:

If (GetAsyncKeyState ((VK_SHIFT)) <> 0) and (Key = VK_RETURN) then

and is working...

the problem is not with VK_LMENU...

the problem is when i press Alt of Left on my windowed window.. it set focus to windows properties... such as a submenu..

how to disable this "option" on a Window with pure WinAPI?

doing this i will get the desired result..

suggestions?

JernejL
05-04-2008, 10:10 AM
So, why are you all ignoring the GetKeyboardState solution? that thing gives you a nice byte array, 1 byte for each key, which you can even use to detect multimedia keys as they are all separate in the structure.

lordzero
05-04-2008, 04:45 PM
So, why are you all ignoring the GetKeyboardState solution? that thing gives you a nice byte array, 1 byte for each key, which you can even use to detect multimedia keys as they are all separate in the structure.

can you show some sample? actually this is not much clear... :?

JernejL
05-04-2008, 05:20 PM
So, why are you all ignoring the GetKeyboardState solution? that thing gives you a nice byte array, 1 byte for each key, which you can even use to detect multimedia keys as they are all separate in the structure.

can you show some sample? actually this is not much clear... :?

http://msdn2.microsoft.com/en-us/library/ms646299(VS.85).aspx

what you do, is fetch the array, and then check the array entry of say
VK_LCONTROL or VK_RCONTROL number to see if key is pressed or not.

lordzero
05-04-2008, 05:48 PM
thanks for all answers :)