OVH Cloud OVH Cloud

Capture des touches clavier

1 réponse
Avatar
Jean Saint Jalmes
Bonjour,

Comment masquer la touche TAB pour que l'utilisateur ne=20
puisse pas l'utiliser ?

j'ai essay=E9 la solution suivante qui ne marche pas

--------------------------------------------------------
(Form.keypreview =3D true)

Private sub Form_KeyDown(KeyCode as integer.....)
if KeyCode =3D vbKeyTab then keycode =3D 0
end sub

--------------------------------------------------------

j'ai essay=E9 de placer un hook comme suit mais cela ne=20
marche pas. l'indicateur LockTab est positionn=E9 =E0 True=20
lorsque la saisie doit =EAtre bloqu=E9e puis =E0 False=20
lorsqu'elle est autoris=E9e

---------------------------------------------------------
Private Sub Form_Load()
HookForm Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
UnHookForm Me
End Sub

Public LockTab as boolean
private PrevDoc as long

Public Sub HookForm(F As Form)
PrevProc =3D SetWindowLong(F.hwnd, GWL_WNDPROC,=20
AddressOf WindowProc)
End Sub

Public Sub UnHookForm(F As Form)
SetWindowLong F.hwnd, GWL_WNDPROC, PrevProc
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg=20
As Long, ByVal wParam As Long, ByVal lParam As Long) As=20
Long
If LockTab Then Exit Function
WindowProc =3D CallWindowProc(PrevProc, hwnd, uMsg,=20
wParam, lParam)
End Function

1 réponse

Avatar
le_troll
Bonjour, il me semble que justement la touche TAB n'est pas redirigeable,
alors ce que tu peux faire c'est tester le focus de ce qui se trouve où tu
ne veux pas qu'on aille...
--
Merci, @+, bye, Joe

------------------------------------------
Avec une hache, celui qui tient le manche a toujours raison !
------------------------------------------


"Jean Saint Jalmes" a écrit dans le
message de news: e80801c43cbe$a1556ec0$
Bonjour,

Comment masquer la touche TAB pour que l'utilisateur ne
puisse pas l'utiliser ?

j'ai essayé la solution suivante qui ne marche pas

--------------------------------------------------------
(Form.keypreview = true)

Private sub Form_KeyDown(KeyCode as integer.....)
if KeyCode = vbKeyTab then keycode = 0
end sub

--------------------------------------------------------

j'ai essayé de placer un hook comme suit mais cela ne
marche pas. l'indicateur LockTab est positionné à True
lorsque la saisie doit être bloquée puis à False
lorsqu'elle est autorisée

---------------------------------------------------------
Private Sub Form_Load()
HookForm Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
UnHookForm Me
End Sub

Public LockTab as boolean
private PrevDoc as long

Public Sub HookForm(F As Form)
PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC,
AddressOf WindowProc)
End Sub

Public Sub UnHookForm(F As Form)
SetWindowLong F.hwnd, GWL_WNDPROC, PrevProc
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg
As Long, ByVal wParam As Long, ByVal lParam As Long) As
Long
If LockTab Then Exit Function
WindowProc = CallWindowProc(PrevProc, hwnd, uMsg,
wParam, lParam)
End Function