Página 1 de 1
How to Trap key in Alt Combination ?
Publicado: Jue Sep 15, 2016 7:03 am
por Milan Mehta
I wish to use Alt+W key in FormKeyUp Event of the Form (using VK_ combination).
I could See Control+ or Menu+ Combination but not Alt+ Combination.
I am including WinUser.api.
Is it possible or is there any work around ?
TIA
Milan.
Re: How to Trap key in Alt Combination ?
Publicado: Jue Sep 15, 2016 9:56 am
por ignacio
Hello,
Try this:
Código: Seleccionar todo
METHOD KeyDown( oSender, nKey, nFlags ) CLASS TForm
IF nKey == Asc( "W" ) .AND. lGetKeyState( VK_MENU )
Whatever()
RETURN 0
ENDIF
RETURN NIL
Re: How to Trap key in Alt Combination ?
Publicado: Vie Sep 16, 2016 2:16 pm
por ChrisGillard
Thank you both .... trapping ALT + is very interesting to me at the moment.
Next, I am trying to trap the 'cursor' keys UpArrow, DownArrow etc.
I dont see them in the Form KeyDown method, so I am hoping there is somewhere else?
Thanks
Chris
Re: How to Trap key in Alt Combination ?
Publicado: Vie Sep 16, 2016 3:54 pm
por ChrisGillard
More info on trying to capture the Cursor/Arrow keys.
When I had a TBevel somewhere on the form ........... The Form onKeyDown DID NOT not appear to see the Cursor/Arrrow keys
When I removed the TBevel and had an empty form ... The Form onKeyDown DID appear to see the Cursor/Arrrow keys
Is that how it should be .... its a bit confusing where the different types of keys do or don't get processed.
Chris
Re: How to Trap key in Alt Combination ?
Publicado: Vie Sep 16, 2016 5:15 pm
por ignacio
Hello Chris,
The problem arises because some controls trap those keys for their own user. When this happens, the event is stopped and not propagated to its parent.
Regards