Alguien puede convertir este codigo a VFP9

04/04/2006 - 16:54 por Horacio Gimenez | Informe spam
Aparentemente este codigo es la solucion para deshabilitar la tecla de
Windows, Alt+tab, Alt+Esc, Ctrl+Esc, W+L,W+R,W+F,..etc., pero esta en
visual basic, talvez alguien del foro lo puede trasladar a vfp9

Private Declare Function MessageBeep Lib "user32" (ByVal wType As Long) As
Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
As Integer

Private WithEvents apiLink As EventVB.APIFunctions
Private WithEvents hook As EventVB.ApiSystemHook

Private Const vbKeyLWin As Integer = 91
Private Const vbKeyRWin As Integer = 92
Private Const vbKeyLCtrl As Integer = 162
Private Const vbKeyRCtrl As Integer = 163

Private Sub Form_Load()
Set apiLink = New EventVB.APIFunctions
Set hook = apiLink.System.Hooks

hook.StartHook WH_KEYBOARD_LL, HOOK_GLOBAL

End Sub

Private Sub Form_Unload(Cancel As Integer)
hook.StopHook WH_KEYBOARD_LL
Set hook = Nothing
Set apiLink = Nothing
End Sub

Private Sub hook_KeyDown(ByVal VKey As Long, ByVal scanCode _
As Long, ByVal ExtendedKey As Boolean, ByVal AltDown As _
Boolean, ByVal Injected As Boolean, Cancel As Boolean)

'Alt Tab
If AltDown And VKey = vbKeyTab Then
Cancel = True

'Alt Esc
ElseIf AltDown And VKey = vbKeyEscape Then
Cancel = True

'Ctrl Esc
ElseIf VKey = vbKeyEscape Then
'Check if a ctrl key down
If GetKeyState(vbKeyLCtrl) And &HF0000000 Or _
GetKeyState(vbKeyRCtrl) And &HF0000000 Then
Cancel = True
End If

'Windows key (L/R). Used to "disable" the start menu.
'Stops single keydown of a windows key
ElseIf VKey = vbKeyLWin Or VKey = vbKeyRWin Then
Cancel = True

'Windows + Any
'If there is a hotkey combination being pressed,
'the Windows key will not be stored in VKey,
'So I check the state of the windows keys.
'If they are down, cancel keys
Else
If GetKeyState(vbKeyLWin) And &HF0000000 Or _
GetKeyState(vbKeyRWin) And &HF0000000 Then
Cancel = True
End If
End If

'This is totally optional of course
If Cancel = True Then 'We have stopped some keystrokes. Beep
MessageBeep 0
End If
End Sub


-
PortalFox :: Nada corre como un zorr
http://www.portalfox.co

PortalFox - NNTP Forum Gatewa
 

Leer las respuestas

#1 Otto Pérez
19/04/2006 - 16:01 | Informe spam
Hola Horacio
Te servirá esto:

Hay una rutina para convertir codigos de VB a VFP solo que no recuerdo de
quien es. Por supuesto, hay cosas que definitivamente no funcionarán en
algunos casos


Private Declare Function Message? CHR(7) Lib "user32" (wType ) As Long
Private Declare Function GetKeyState Lib "user32" (nVirtKey )


Private WithEvents apiLink As EventVB.APIFunctions
Private WithEvents hook As EventVB.ApiSystemHook

#DEFINE vbKeyLWin 91
#DEFINE vbKeyRWin 92
#DEFINE vbKeyLCtrl 162
#DEFINE vbKeyRCtrl 163

PROCEDURE Form_Load()
apiLink = New EventVB.APIFunctions
hook = apiLink.System.Hooks

hook.StartHook WH_KEYBOARD_LL, HOOK_GLOBAL

ENDPROC

PROCEDURE Form_Unload(Cancel )
hook.StopHook WH_KEYBOARD_LL
hook = NULL
apiLink = NULL
ENDPROC

PROCEDURE hook_KeyDown(VKey , scanCode ;
, ExtendedKey , AltDown As ;
Boolean, Injected , Cancel )

*!*Alt Tab
DO CASE
CASE AltDown And VKey = vbKeyTab
Cancel = .T.

*!*Alt Esc
CASE AltDown And VKey = vbKeyEscape
Cancel = .T.

*!*Ctrl Esc
CASE VKey = vbKeyEscape
*!*Check DO CASE
CASE a ctrl key down
If GetKeyState(vbKeyLCtrl) And 0xF0000000 Or ;
GetKeyState(vbKeyRCtrl) And 0xF0000000 Then
Cancel = .T.
ENDIF

*!*Windows key (L/R). Used to "disable" the start menu.
*!*Stops single keydown of a windows key
CASE VKey = vbKeyLWin Or VKey = vbKeyRWin
Cancel = .T.

*!*Windows + Any
*!*If there is a hotkey combination being pressed,
*!*the Windows key will not be stored in VKey,
*!*So I check the state of the windows keys.
*!*If they are down, cancel keys
Else
If GetKeyState(vbKeyLWin) And 0xF0000000 Or ;
GetKeyState(vbKeyRWin) And 0xF0000000 Then
Cancel = .T.
ENDIF
ENDIF

*!*This is totally optional of course
If Cancel = .T. &&We have stopped some keystrokes. ? CHR(7)
Message? CHR(7) 0
ENDIF
ENDPROC



PortalFox :: Nada corre como un zorro
http://www.portalfox.com

PortalFox - NNTP Forum Gateway

Preguntas similares