WINDOWS中的程序运行时都要用到消息机制。
你可使用一些消息拦截函数截取消息,并作一定的处理,就可以得到你想得到的结果了。

解决方案 »

  1.   

    感谢您使用微软产品。您可以使用API函数GetKeyState查询某个键的状态包括鼠标左右键的状态,如下例:Private Const VK_LBUTTON = &H1
    Private Const VK_RBUTTON = &H2Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As IntegerPrivate Sub Timer1_Timer()
             If GetKeyState(VK_LBUTTON) < 0 Then
        Text1.Text = "Lbutton down"
        Else
        Text1.Text = "Lbutton up"
        End If
    End Sub详情请参阅:
    GetKeyState 
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/keybinpt_4z51.aspVirtual-Key Codes
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/vkeys_529f.asp
    - 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
    (http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
    为了为您创建更好的讨论环境,请参加我们的用户满意度调查
    (http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。