问题补充:
说了是只在窗体中隐藏或显示。窗体外无任何隐藏显示效果。
假设动态控制隐藏了,那么鼠标在窗体内他是隐藏的,一但移动到窗体外他就不隐藏的。
不隐藏么移动到哪儿都不隐藏。
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub Timer2_Timer() '探测鼠标是否在窗体内
Dim Point As POINTAPI
GetCursorPos Point
If Point.X * 15 >= Me.Left And Point.X * 15 <= Me.Left + Me.Width And Point.Y * 15 >= Me.Top + 300 And Point.Y * 15 <= Me.Top + Me.Height Then
ShowCursor 0 '隐藏鼠标
Else
ShowCursor 1 '显示鼠标
End If
End Sub
当在其他事件里面单独用
Timer2.Enabled = False
ShowCursor 1
没有显示鼠标的效果,为什么?
但是还存在多次执行隐藏或者显示后
两个按钮
'我的程序没有错
'在VB中运行是没有你说的效果,但生成文件后就可以了,请试一下
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Sub Command1_Click()
ShowCursor 0 '隐藏鼠标
End Sub
Private Sub Command2_Click()
ShowCursor 1 '显示鼠标
End Sub