PDA

Ver la Versión Completa : Activacion de Teclas


Gustavo Gowdak
12-12-2004, 23:26:31
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:


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:


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