vb6.0 中,如何让当前窗口响应屏幕上的MOUSE事件

当前窗口不是全屏,如何响应屏幕上其它区域(不是本窗口的区域)的MOUSE事件,也就是在屏幕上不是本窗口区域的地方发生MOUSE消息时,本窗口如何接收。

添加一个类模块,命名为cCursor
代码如下
Option Explicit
DefLng A-Z

Private Type POINTAPI
X As Long
Y As Long
End Type

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Public Property Get X() As Long

Dim tmpPoint As POINTAPI
Call GetCursorPos(tmpPoint)
X = tmpPoint.X

End Property

Public Property Let X(ByVal vNewValue As Long)

Call SetCursorPos(vNewValue, Y)

End Property

Public Property Get Y() As Long

Dim tmpPoint As POINTAPI
Call GetCursorPos(tmpPoint)
Y = tmpPoint.Y

End Property

Public Property Let Y(ByVal vNewValue As Long)

Call SetCursorPos(X, vNewValue)

End Property

窗体中添加一个Timer,interval设成1

代码如下

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Dim cursor As New cCursor
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbLeftButton) Then
Me.Caption = "LeftButton Down!"
Else
Me.Caption = "LeftButton Up!"
End If
Me.Caption = Me.Caption & " " & cursor.X & "/" & cursor.Y
End Sub
温馨提示:内容为网友见解,仅供参考
第1个回答  2008-08-13
没做过,估计钩子可以实现。

vb6.0 中,如何让当前窗口响应屏幕上的MOUSE事件
窗体中添加一个Timer,interval设成1 代码如下 Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Dim cursor As New cCursor Private Sub Timer1_Timer()If GetAsyncKeyState(vbLeftButton) Then Me.Caption = "LeftButton Down!"Else Me.Caption = "LeftButt...

VB6.0如何完全禁用或者屏蔽鼠标滚轮的任何输入
ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As LongPublic Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long 'Public Const WM_LBUTTONDOWN = &H201 '窗口中按下鼠标左键'Public

如何获得vb中鼠标在窗口的坐标
可以通过Mouse_Move 来将鼠标的坐标赋值给全局变量

vb6.0中WebBrowser1控件的问题
首先建立一个新工程,在Form1中加入一个Webbrowser控件,然后在Form1中加入以下代码:Option Explicit Public Sub Some_Procedure()MsgBox "你点击了按钮."End Sub Private Sub Form_Load()'下载空页面 WebBrowser1.Navigate2 "about:blank"End Sub Private Sub WebBr...

如何用VB6.0写一个程式 可以获取另一个程式上输入的数据,如在QQ窗体中...
Private Type MOUSEHOOKSTRUCT '本地鼠标钩子结构 pt As POINTAPI '相对于屏幕左上角的坐标x,y hwnd As Long '鼠标光标下窗口的句柄 wHitTestCode As Long '鼠标光标在窗口中的位置,标题栏、左边框、右边框,下边框。。。dwExtraInfo As Long '其他信息,通常为0 End Type '---+ Private Con...

请问我用VB6.0想做个无窗体执行文件,怎么做.?
然后再在LblBtn的MouseMove和MouseDown事件中来搞定剩余部分:Private Sub LblBtn_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) ’当鼠标按在LblBtn上时 LblBtn(Index).BackColor = LBL_WHEN_MOUSE_DOWN ’临时改变LblBtn背景颜色 End Sub ...

vb6.0中,多个check,相互制约,就像Option那样,如何实现?
程序如下 ,楼主给分 添加一个timer控件,定义一个全局变量i Dim i As Integer Private Sub Form_Load()Timer1.Interval = 1 Timer1.Enabled=False End Sub Private Sub Timer1_Timer()If i = 1 Then Check1.Value = 1 Check2.Value = 0 ElseIf i = 2 Then Check1.Value = 0 Check2....

求VB6.0写的后台模拟按键
WM_SETTEXT, 0, a '3.后台按键.(是按键!)PostMessage hLastWin, WM_CHAR, Asc("a"), 0 End Sub --- 应该可以...如果不行...可以试用下激活窗口 然后 SendKey 这个方法 帝国时代 可以...其它游戏不知道了

■■■谁有VB6.0简介
在要使用的对象上单击鼠标右键即可打开快捷菜单,其上会出现与当前对象相关的经常执行的操作,以加快操作速度。7. 工程管理器窗口 用于浏览工程中所包含的窗体和模块,还可以从中查看代码、查看对象。8. 属性窗口 是VB中一个比较复杂的窗口,其中列出了对选定窗体和控件的属性设置值。VB中正是通过改变...

用VB制做可换图片的屏幕保护程序
响应键盘、鼠标是屏幕保护程序不可缺少的,在OnKeyDown()、 OnLButtonDown()、 OnMButtonDown()、OnRButtonDown()、OnSysKeyDown()函数中都加入: PostMessage(WM_CLOSE); OnMouseMove()函数比较特殊,它应加的代码为: if(m_prePoint == CPoint(-1,-1)) m_prePoint = point; else if(m_prePoint!

相似回答
大家正在搜