Ver Mensaje Individual
  #2  
Antiguo 13-12-2004
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
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
Responder Con Cita