你可以自己编写这部分的代码呀!
主要是通过坐标的判断了直到mouse是不是在你规定的范围!
主要是通过坐标的判断了直到mouse是不是在你规定的范围!
解决方案 »
- vbscript把數據插入數據庫問題
- 为何我设置了MSCOMM的RThreshold=1后ONCOMM事件还是不起作用?
- 求助oracle访问问题!!!!!!
- 困扰的xml读取问题,小数没有了???!!!
- 请问一下,如何把一个可执行文件用VB包含进去
- 初学VB,编计算器碰到问题
- 还是输出到EXCEL的问题,我本来是编号的字符串,被它自行改成数值了,“0000001”成了“1”,如何解决?!
- 紧急求助!!!!不懂得别进来!!关于数据库的问题
- 如何调用自己创建的ActiveX的数组?
- 急急急!!!那位高手可以告诉我,如何编码控制datagrid控件的行数和列数,使它具有5行5列????
- VB6分形图像程序源代码提供!
- 用activereport打印为什么打印一张就跟着走一张空纸?
Declare Function SetCapture Lib "user32" Alias "SetCapture" (ByVal hwnd As Long) As Long
说明
将鼠标捕获设置到指定的窗口。在鼠标按钮按下的时候,这个窗口会为当前应用程序或整个系统接收所有鼠标输入
返回值
Long,之前拥有鼠标捕获的窗口的句柄
参数表
参数 类型及说明
hwnd Long,要接收所有鼠标输入的窗口的句柄
注解
我的理解:与ReleaseCapture函数一起使用,用于判断鼠标离开(mouseleave)事件
ReleaseCapture VB声明
Declare Function ReleaseCapture Lib "user32" Alias "ReleaseCapture" () As Long
说明
为当前的应用程序释放鼠标捕获
返回值
Long,TRUE(非零)表示成功,零表示失败
注解
我的理解:与SetCapture函数一起使用,用于判断鼠标离开(mouseleave)事件
'Mouse Capture
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim Pt As POINTAPI
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'redirect all mouse input to this form
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Get the current cursor position
GetCursorPos Pt
Me.CurrentX = 0
Me.CurrentY = 0
'Clear the screen
Me.Cls
Me.Print "Cursor position:"
'Print the mouse co?rdinates to the form
Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y)
Me.Print " (Press ALT-F4 to unload this form)"
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
MOUSEOUT事件:发生在鼠标从它的上面移出的时候;
例如:
Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Index
Case 0: Label1(0).ForeColor = &HC00000
Label1(1).ForeColor = &H0&
Label1(2).ForeColor = &H0&
Label1(3).ForeColor = &H0&
Case 1: Label1(1).ForeColor = &HC00000
Label1(0).ForeColor = &H0&
Label1(2).ForeColor = &H0&
Label1(3).ForeColor = &H0&
Case 2: Label1(2).ForeColor = &HC00000
Label1(0).ForeColor = &H0&
Label1(1).ForeColor = &H0&
Label1(3).ForeColor = &H0&
Case 3: Label1(3).ForeColor = &HC00000
Label1(0).ForeColor = &H0&
Label1(1).ForeColor = &H0&
Label1(2).ForeColor = &H0&
End Select
End Sub
我在程序中加了一个TEXT控件
如何实现像TEXT_MOUSEOVER or TEXT_MOUSEOUT 这两个事件有知道的吗?
谢谢了,能够实现马上给分事先如明:我的TEXT是可变的!!!我也试过用MOUSEMOVE事件,再通过判断TEXT的LEFT,TOP,WIDTH,EHIGHT和X,Y进行比较,但达不到预期的效果。
请帮忙·!!!!!
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > 0 And X < Text1.Width And Y > 0 And Y < Text1.Height Then
Label1.Caption = "MouseOver"
SetCapture Text1.hWnd
Else
Label1.Caption = "MouseOut"
ReleaseCapture
End If
End Sub
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > 0 And X < Text1.Width And Y > 0 And Y < Text1.Height Then
Label1.Caption = "MouseOver"
SetCapture Text1.hWnd
Else
Label1.Caption = "MouseOut"
ReleaseCapture
End If
End Sub
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub MyIMG_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
在 obj 的 mousemove 事件中加入 Dim MouseEnter As Boolean
With obj
MouseEnter = (0 <= X) And (X <= .Width) And (0 <= Y) And (Y <= .Height)
If MouseEnter Then
SetCapture .hWnd
If Hot = False Then
Hot = True
‘写入进入事件
End If
Else
ReleaseCapture
.Picture = DefaultImage
'写入离开事件
Hot = False
End If
End With