用API的showcursor可以隐藏鼠标,可是为什么会出现这样的情况:
我在form的load事件里加入:
dim x as integer
x=showcursor(false)接着在form的mousemove加入
x=showcursor(true)可是并没有实现到我想的效果:在程序一运行把鼠标隐藏,当我一定鼠标的时候鼠标显现。于是我试了改了下,
在Form的mousemove的代码改为:
x=showcursor(False)在form的click加入代码:
x=Showcursor(true)可是发现很怪,鼠标要在我移动了还几下才隐藏了起来(为什么要移动好几下才响应),可是当我点击窗体的时候,鼠标并没有显示。为什么呀?应该怎样做呀!谢谢!
我在form的load事件里加入:
dim x as integer
x=showcursor(false)接着在form的mousemove加入
x=showcursor(true)可是并没有实现到我想的效果:在程序一运行把鼠标隐藏,当我一定鼠标的时候鼠标显现。于是我试了改了下,
在Form的mousemove的代码改为:
x=showcursor(False)在form的click加入代码:
x=Showcursor(true)可是发现很怪,鼠标要在我移动了还几下才隐藏了起来(为什么要移动好几下才响应),可是当我点击窗体的时候,鼠标并没有显示。为什么呀?应该怎样做呀!谢谢!
Option Explicit
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As LongPrivate Sub Form_Click()
Call ShowCursor(True)
End SubPrivate Sub Form_Load()
Call ShowCursor(False)
End Sub初步分析,可能跟你在MouseMove中处理有关。在显示窗体时系统会自动调用MouseMove事件(不行你可看看),Click当然也会有鼠标移动(MouseMove)。所以建议最好不要在MouseMove中处理。
不要跑到隔壁那村去找你的家哦
简单代码如下
getwindowrect me.hwnd,rect
clipcursor rect
showcursor false...
clipcursor vbnullstring
showcursor true
我照你的做,private type rect
top as long
left as long
right as long
bottom as long
end typedim rects as rect接着在form的load事件加入:
getwindowrect me.hwnd,rects
clipcursor rects
call showcursor(false)
再在form的click事件加入:
clipcursor 0&
call showcursor(true)在运行的时候,鼠标隐藏,click窗体的时候鼠标显示,但是马上又隐藏掉,接着就一直隐藏了。为什么这样?
Declare Function ShowCursor Lib "user32" Alias "ShowCursor" (ByVal bShow As Long) As Long
说明
控制鼠标指针的可视性
返回值
Long,显示计数(参考注解)
参数表
参数 类型及说明
bShow Long,TRUE(非零)显示指针,FALSE隐藏
注解
windows维持着一个内部显示计数;倘若bShow为TRUE,那么每调用一次这个函数,计数就会递增1;反之,如bShow为FALSE,则计数递减1。只有在这个计数大于或等于0的情况下,指针才会显示出来=========注意注解里的文字
top As Long
left As Long
right As Long
bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As rect) As Long
Private Declare Function ShowCursor Lib "user32.dll" (ByVal bShow As Long) As Long
Private Declare Function ClipCursor Lib "user32.dll" (ByRef lpRect As Any) As LongPrivate Sub Form_Click()
ClipCursor 0&
Call ShowCursor(-1)'<-----不知道为什么,用它就行,用true是不行的
End SubPrivate Sub Form_Load()
Dim rects As rect
GetWindowRect Me.hwnd, rects
ClipCursor rects
Call ShowCursor(False)End Sub
private sub form_DBClick()
end
end sub关闭的时候不要用窗体的关闭来退出程序,而是双击窗体退出,你再运行看下会有什么效果。鼠标肯定不会隐藏。
Option ExplicitPrivate Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.MousePointer = 0
Timer1.Enabled = False
Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
Me.MousePointer = 99
End Sub