我的方法一定很笨 :-) 我没用果VB,我用VC这样做过:按钮用自定义型 (owner draw),按钮要捕获 mouse move 消息,如果接收到这个消息,说明鼠标移动到了按钮之内,如果当前没有“浮起”按钮(或改变其他状态)就设置“浮起”标志,并且重画按钮,同时一定要启动 timer,在 timer 里面检查鼠标是否移出按钮(因为Windows没有提供鼠标移出的消息),如果鼠标移出按钮,要复位“浮起”标志,并且 timer 自杀,免得占用 Windows 资源,同时重画按钮。当然按钮按下和抬起的消息还保留,不用处理,只是在重画按钮的消息WM_DRAWITEM里除了判断按下和抬起,是否有焦点等 还要 增加判断“浮起”标志。

解决方案 »

  1.   

    请去查找CSDN中VB专题中的相关内容。
      

  2.   

    http://www.ariad-software.com/ToolbarSrc.zip
      

  3.   

    ybchen的思路不错,但没必要用什么timer,在控件的MouseMove事件里利用SetCapture和ReleaseCapture造出一某MouseLeaveshijian事件就OK了。
    看懂下面的例子你就什么都明白了:
    Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        ' 没有使用MouseLeave事件,当鼠标快速移动时,程序来不及响应
        StatusBar1.Panels(1).Text = "This is Command1"
    End SubPrivate Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim MouseOver As Boolean
        
        '判断当前鼠标位置是否在Command2上
        MouseOver = (0 <= X) And (X <= Command2.Width) And (0 <= Y) And (Y <= Command2.Height)
        If MouseOver Then
            ' MouseOver Event
            ' 假如鼠标在Command2上, 则利用SetCapture将每一个鼠标事件都传递给Command2
            ' 并在StatusBar1.Panels(1)上显示帮助信息
            StatusBar1.Panels(1).Text = "This is Command2"
            SetCapture Command2.hWnd
        Else
            ' MouseLeave Event
            ' 假如鼠标不在Command2上, 则利用SetCapture释放鼠标捕捉
            ' 并清除在StatusBar1.Panels(1)上的帮助信息
            StatusBar1.Panels(1).Text = ""
            ReleaseCapture
        End If
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        StatusBar1.Panels(1).Text = ""
    End Sub
    有么问题再问?
      

  4.   

    实现浮动工具条的例子
    http://www.csdn.net/visual%20basic/source%20code/Control%20Examples/make_toolbar_flat.zip
    IE4风格的工具条
    http://www.csdn.net/visual%20basic/source%20code/Control%20Examples/code_coolbar.zip
      

  5.   

    用四条线段,一个标签就可以实现了。
    在Label1和Form1的MouseMove中加入线段的变色代码,要执行的代码放到MouseUp中去。
      

  6.   

    我最开始编的是 Gempin 说的设置 SetCapture 独占鼠标处理,因为时间久了记不太清(键盘操作、窗口切换等方面),好像发现了什么问题又改成 Timer 处理了,现在用的还是 Timer。用 SetCapture 的反应速度应该比 Timer 快。用 Timer 处理的可以做动画按钮,鼠标移动到哪个按钮,哪个作一个动作或播放动画