[RESOLVED] Disabling f10 when form unloads
Hi,
I have this application when f10 is clicked it opens its own menus probably thru hotkey. Ive managed to position this app on top of my interface when a button is pushed. But when the button is released this application is then hidden and you could open other windows and stuff on the interface. But when f10 is clicked, it opens up that application menus. So I want to disable the f10 key when Ive hidden the application therefore it wont show when I look at other menus on my interface and if the user does not accidentally press f10. Ive found some threads on disabling ctrl-alt-del using registry. Should I be doing the same for function keys?
Or is there another way?
Thanks
Re: Disabling f10 when form unloads
Regardless of any answers that's realy unreasonable - functional key could be used by other application.
Re: Disabling f10 when form unloads
As RhinoBull said, its not good http://www.vbforums.com/images/icons/icon13.gif .
Does this program use a hotkey or is it using something like a keylogger to capture keys?
Re: Disabling f10 when form unloads
Quote:
Regardless of any answers that's realy unreasonable - functional key could be used by other application.
True.
Thats why I would like to disable the f10 key entirely while my vb app is running. And am wondering if theres any other way to do it or I have to edit the registry to do so
Quote:
Does this program use a hotkey or is it using something like a keylogger to capture keys
I think it uses f10 as a hotkey to open its menus.
Re: Disabling f10 when form unloads
This will set a system wide hotkey. Its from API Guide but i modified it a bit. when your program opens it will create the hotkey then when it closes it will return everything back to normal.
VB Code:
Private Const PM_REMOVE = &H1
Private Const WM_HOTKEY = &H312
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type Msg
hWnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
Private bCancel As Boolean
Private Sub ProcessMessages()
Dim Message As Msg
Do While Not bCancel
WaitMessage
If PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
MsgBox "F10 Key pressed"
End If
DoEvents
Loop
End Sub
Private Sub Form_Load()
Dim ret As Long
bCancel = False
ret = RegisterHotKey(Me.hWnd, &HBFFF&, 0, vbKeyF10)
Show
ProcessMessages
End Sub
Private Sub Form_Unload(Cancel As Integer)
bCancel = True
Call UnregisterHotKey(Me.hWnd, &HBFFF&)
End Sub
Re: Disabling f10 when form unloads