In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

How to Trap key in Alt Combination ?

Xailer professional forum in English
Responder
Milan Mehta
Mensajes: 132
Registrado: Dom Dic 27, 2009 9:54 am

How to Trap key in Alt Combination ?

Mensaje 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.
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: How to Trap key in Alt Combination ?

Mensaje 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
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Re: How to Trap key in Alt Combination ?

Mensaje 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
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Re: How to Trap key in Alt Combination ?

Mensaje 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
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: How to Trap key in Alt Combination ?

Mensaje 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
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder