Espero que les sirva para algo
Saludos a todos,
Claudio Soto.
SINTAXIS:
KBD_MOUSE IN WINDOW <cWindowName> LOCK // BLOQUEA el teclado y el mouse en la ventana <cWindowName>
KBD_MOUSE IN WINDOW <cWindowName> UNLOCK // DESBLOQUEA el teclado y el mouse en la ventana <cWindowName>
IS_ENABLE_KBD_MOUSE (<cWindowName>) // Retorna .T. si esta BLOQUEADO ---- Retorna .F. si esta DESBLOQUEADO
Code: Select all
****************************************************************************
* PROGRAMA: LOCK THE KEYBOARD AND MOUSE
* LENGUAJE: HARBOUR-MINIGUI 3.0.26
* FECHA: 28 MARZO 2010
* AUTOR: CLAUDIO SOTO
* PAIS: URUGUAY
* E-MAIL: srvet@adinet.com.uy
****************************************************************************
***************************************************************************************************
* SINTAXIS:
*
* KBD_MOUSE IN WINDOW <cWindowName> LOCK // BLOQUEA EL TECLADO Y EL MOUSE EN LA VENTANA <cWindowName>
*
* KBD_MOUSE IN WINDOW <cWindowName> UNLOCK // DESBLOQUEA EL TECLADO Y EL MOUSE EN LA VENTANA <cWindowName>
*
* IS_ENABLE_KBD_MOUSE (<cWindowName>) // Retorna .T. si esta BLOQUEADO
* // Retorna .F. si esta DESBLOQUEADO
*******************************************************************************************************
****************************************************************************************************
* DEFINICION DE LOS COMANDOS
****************************************************************************************************
#xcommand KBD_MOUSE IN WINDOW <cWindowName> LOCK;
=>;
LOCK_KBD_MOUSE (GetFormHandle(<cWindowName>), 0) // BLOQUEA
#xcommand KBD_MOUSE IN WINDOW <cWindowName> UNLOCK;
=>;
LOCK_KBD_MOUSE (GetFormHandle(<cWindowName>), 1) // DESBLOQUEA
#xtranslate IS_ENABLE_KBD_MOUSE (<cWindowName>);
=>;
ENABLE_KBD_MOUSE (GetFormHandle(<cWindowName>))
******************************************************************************************************
#include "minigui.ch"
Function Main
PRIVATE inicio
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 500 ;
TITLE 'Bloqueo de teclado y mouse' ;
MAIN
@ 10 , 10 LABEL Label_1
@ 50 , 10 LABEL Label_2 AUTOSIZE
@ 100, 100 BUTTON boton_1 CAPTION "Mensage" ACTION MsgInfo ("Hola usuario")
@ 100, 250 BUTTON boton_2 CAPTION "Bloquear" ACTION bloquear ()
@ 300 , 10 EDITBOX EB_1 WIDTH 200 HEIGHT 100 VALUE "Escribir" BACKCOLOR WHITE FONTCOLOR BLUE
Form_1.Label_2.Value := "Teclado y Mouse: "+IF (IS_ENABLE_KBD_MOUSE ("Form_1") = .F. ,"BLOQUEADO","DESBLOQUEADO")
END WINDOW
Form_1.Center
Form_1.Activate
Return
*********************************************************************************************************************
Procedure BLOQUEAR
MsgInfo ("El teclado y el mouse de esta ventana seran bloquedos por 30 segundos")
inicio := SECONDS ()
KBD_MOUSE IN WINDOW "Form_1" LOCK // BLOQUEADO
Form_1.Label_2.Value := "Teclado y Mouse: "+IF (IS_ENABLE_KBD_MOUSE ("Form_1") = .F. ,"BLOQUEADO","DESBLOQUEADO")
DEFINE TIMER timer_1 OF Form_1 INTERVAL 30000 action DESBLOQUEAR ()
DEFINE TIMER timer_2 OF Form_1 INTERVAL 100 action Form_1.Label_1.Value := str (SECONDS () - inicio)+" seg."
Return
***********************************************************************************************************************
Procedure DESBLOQUEAR
KBD_MOUSE IN WINDOW "Form_1" UNLOCK // DESBLOQUEADO
Form_1.Label_2.Value := "Teclado y Mouse: "+IF (IS_ENABLE_KBD_MOUSE ("Form_1") = .F. ,"BLOQUEADO","DESBLOQUEADO")
form_1.timer_1.release
form_1.timer_2.release
MsgInfo ("El teclado y el mouse han sido desbloqueados")
Return
*#########################################################################################################################
* FUNCIONES EN C
*#########################################################################################################################
#pragma begindump
#include <shlobj.h>
#include <winuser.h>
#include <windows.h>
#include "hbapi.h"
//*********************************************************************************
// Bloquea el teclado y el mouse de una determinada ventana
// LOCK_KBD_MOUSE (hWnd, bEnable)
// bEnable = FALSE (bloquea), bEnable = TRUE (activa)
HB_FUNC (LOCK_KBD_MOUSE)
{
EnableWindow( (HWND) hb_parnl (1), (BOOL) hb_parni (2));
}
//**********************************************************************************
// Retorna = 0 si el teclado y el mouse estan bloqueados
// Retorna <> 0 si el teclado y el mouse estan desbloqueados
// LOCK_KBD_MOUSE (hWnd, bEnable)
HB_FUNC (ENABLE_KBD_MOUSE)
{
hb_retl((int) IsWindowEnabled((HWND) hb_parnl (1)));
}
#pragma enddump