用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)可是发现很怪,鼠标要在我移动了还几下才隐藏了起来(为什么要移动好几下才响应),可是当我点击窗体的时候,鼠标并没有显示。为什么呀?应该怎样做呀!谢谢!

解决方案 »

  1.   

    我使用如下代码可以(Load时隐藏,Click显示)
    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中处理。
      

  2.   

    Mouse是否在你的Frm上Move,Click?
    不要跑到隔壁那村去找你的家哦
      

  3.   

    当然没有跑到隔壁去了,是因为我在窗体双击加上了end来结束程序,要是这样的话,以后的鼠标就隐藏不了,一定要用窗体上的关闭退出程序鼠标才可以隐藏。为什么会这样的?
      

  4.   

    这个函数只能在你程序窗内隐藏.所以你必须将它锁定ClipCursor在的frm上.
    简单代码如下
    getwindowrect me.hwnd,rect
    clipcursor rect
    showcursor false...
    clipcursor vbnullstring
    showcursor true
      

  5.   

    楼上的,为什么我的不行呀
    我照你的做,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窗体的时候鼠标显示,但是马上又隐藏掉,接着就一直隐藏了。为什么这样?
      

  6.   

    ShowCursor VB声明 
    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的情况下,指针才会显示出来=========注意注解里的文字
      

  7.   

    Private Type rect
       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
      

  8.   

    楼上的,你试下加多一个
    private sub form_DBClick()
    end
    end sub关闭的时候不要用窗体的关闭来退出程序,而是双击窗体退出,你再运行看下会有什么效果。鼠标肯定不会隐藏。
      

  9.   

    新建一个工程,在窗体上加一个timer控件,把mouseicon设一个空白的图标,粘贴如下代码
    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
      

  10.   

    如果如你的程序用到API,对象,等高级一点的编程序,建议不要用End来结束你的程序!