Results 1 to 6 of 6

Thread: [RESOLVED] Disabling f10 when form unloads

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Posts
    105

    Resolved [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
    Last edited by potatocake; Dec 19th, 2005 at 09:41 PM. Reason: Sorry was not clear before

  2. #2

  3. #3
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Disabling f10 when form unloads

    As RhinoBull said, its not good .

    Does this program use a hotkey or is it using something like a keylogger to capture keys?

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Posts
    105

    Re: Disabling f10 when form unloads

    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

    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.

  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    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:
    1. Private Const PM_REMOVE = &H1
    2. Private Const WM_HOTKEY = &H312
    3. Private Type POINTAPI
    4.     x As Long
    5.     y As Long
    6. End Type
    7. Private Type Msg
    8.     hWnd As Long
    9.     Message As Long
    10.     wParam As Long
    11.     lParam As Long
    12.     time As Long
    13.     pt As POINTAPI
    14. End Type
    15. Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
    16. Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long
    17. 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
    18. Private Declare Function WaitMessage Lib "user32" () As Long
    19. Private bCancel As Boolean
    20. Private Sub ProcessMessages()
    21.     Dim Message As Msg
    22.     Do While Not bCancel
    23.         WaitMessage
    24.         If PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
    25.             MsgBox "F10 Key pressed"
    26.         End If
    27.         DoEvents
    28.     Loop
    29. End Sub
    30. Private Sub Form_Load()
    31.     Dim ret As Long
    32.     bCancel = False
    33.     ret = RegisterHotKey(Me.hWnd, &HBFFF&, 0, vbKeyF10)
    34.     Show
    35.     ProcessMessages
    36. End Sub
    37. Private Sub Form_Unload(Cancel As Integer)
    38.     bCancel = True
    39.     Call UnregisterHotKey(Me.hWnd, &HBFFF&)
    40. End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Posts
    105

    Re: Disabling f10 when form unloads

    OOoo that works. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width