none
VB6 能否指定要屏蔽的按键或组合键? RRS feed

答案

  • Private Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim
    KBEvent As KBDLLHOOKSTRUCT
        If nCode >= 0 Then
           
    '在这里可以加入实际的过滤条件
           
    CopyMemory KBEvent, ByVal lParam, 20&   'sizeof KBDLLHOOKSTRUCT=20
            'wParam = 消息,如WM_KEYDOWN, WM_KEYUP等
           
    Debug.Print Hex$(KBEvent.vkCode)    'VK_??? 定义的键码

    '应该是这句话,判断KBEvent.vkCode是否置1
            LowLevelKeyboardProc = 1            '1屏蔽,否则应调用CallNextHookEx
        Else
           
    LowLevelKeyboardProc = CallNextHookEx(m_lHookID, nCode, wParam, lParam)
       
    End If
    End Function

     

    2008年12月10日 1:31
    版主

全部回复

  • Private Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim
    KBEvent As KBDLLHOOKSTRUCT
        If nCode >= 0 Then
           
    '在这里可以加入实际的过滤条件
           
    CopyMemory KBEvent, ByVal lParam, 20&   'sizeof KBDLLHOOKSTRUCT=20
            'wParam = 消息,如WM_KEYDOWN, WM_KEYUP等
           
    Debug.Print Hex$(KBEvent.vkCode)    'VK_??? 定义的键码

    '应该是这句话,判断KBEvent.vkCode是否置1
            LowLevelKeyboardProc = 1            '1屏蔽,否则应调用CallNextHookEx
        Else
           
    LowLevelKeyboardProc = CallNextHookEx(m_lHookID, nCode, wParam, lParam)
       
    End If
    End Function

     

    2008年12月10日 1:31
    版主
  •  feiyun0112 写:

    Private Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim
    KBEvent As KBDLLHOOKSTRUCT
        If nCode >= 0 Then
           
    '在这里可以加入实际的过滤条件
           
    CopyMemory KBEvent, ByVal lParam, 20&   'sizeof KBDLLHOOKSTRUCT=20
            'wParam = 消息,如WM_KEYDOWN, WM_KEYUP等
           
    Debug.Print Hex$(KBEvent.vkCode)    'VK_??? 定义的键码

    '应该是这句话,判断KBEvent.vkCode是否置1
            LowLevelKeyboardProc = 1            '1屏蔽,否则应调用CallNextHookEx
        Else
           
    LowLevelKeyboardProc = CallNextHookEx(m_lHookID, nCode, wParam, lParam)
       
    End If
    End Function

     

     

    能否来个示例,应该怎么修改呢。我不太懂API。。。

    2008年12月10日 5:22