Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Activacion de Teclas (https://www.clubdelphi.com/foros/showthread.php?t=16801)

Gustavo Gowdak 12-12-2004 23:26:31

Activacion de Teclas
 
Como saber si estan activadas las teclas MAY, BLOQ, NUM, y luego mostrarlas si estan en el StatusBar....

roman 13-12-2004 02:17:57

Usa la función GetKeyState:

Código Delphi [-]
var
  KeyState: SmallInt;

begin
  KeyState := GetKeyState(VK_CAPITAL);
  if KeyState and $1 <> 0
    then ShowMessage('MAY está encendido')
    else ShowMessage('MAY está apagado')

  KeyState := GetKeyState(VK_SCROLL);
  if KeyState and $1 <> 0
    then ShowMessage('SCROLL está encendido')
    else ShowMessage('SCROLL está apagado')

  KeyState := GetKeyState(VK_NUMLOCK);
  if KeyState and $1 <> 0
    then ShowMessage('NUMLOCK está encendido')
    else ShowMessage('NUMLOCK está apagado')
end;

También puedes usar GetKeyboardState para obtener todas al mismo tiempo:

Código Delphi [-]
var
  KeyboardState: TKeyboardState;

begin
  GetKeyboardState(KeyboardState);

  if KeyboardState[VK_CAPITAL] and $1 <> 0
    then ShowMessage('MAY está encendido')
    else ShowMessage('MAY está apagado')

  if KeyboardState[VK_SCROLL] and $1 <> 0
    then ShowMessage('SCROLL está encendido')
    else ShowMessage('SCROLL está apagado')

  if KeyboardState[VK_NUMLOCK] and $1 <> 0
    then ShowMessage('NUMLOCK está encendido')
    else ShowMessage('NUMLOCK está apagado')
end;

Quizá lo más conveniente sea incluir alguno de los dos códigos en el evento OnTimer de un Timer para actualizar en automático tu StatusBar.

// Saludos


La franja horaria es GMT +2. Ahora son las 08:32:49.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi