我的方法一定很笨 :-) 我没用果VB,我用VC这样做过:按钮用自定义型 (owner draw),按钮要捕获 mouse move 消息,如果接收到这个消息,说明鼠标移动到了按钮之内,如果当前没有“浮起”按钮(或改变其他状态)就设置“浮起”标志,并且重画按钮,同时一定要启动 timer,在 timer 里面检查鼠标是否移出按钮(因为Windows没有提供鼠标移出的消息),如果鼠标移出按钮,要复位“浮起”标志,并且 timer 自杀,免得占用 Windows 资源,同时重画按钮。当然按钮按下和抬起的消息还保留,不用处理,只是在重画按钮的消息WM_DRAWITEM里除了判断按下和抬起,是否有焦点等 还要 增加判断“浮起”标志。
解决方案 »
- vb如何检测背景音乐的状态(stopped or palying)?用mciSendString检测与用户控件共用是否会产生冲突?
- 求教用ExtFloodFill填充区域颜色方法,谢谢!!!
- sendmessage 的问题.
- 在第一个输入框中,输入某些特定值后回车,自动填充到后面的其他输入框?具体见内容..(高分求救)
- msgrid的按序排列!高手进!
- 我要做一个小的管理系统,用什么数据库格式比较小
- 连接SQL SERVER,怎样写服务器的名?
- 控件设计的问题。急!!!!!!在线等待!
- 对于treeview,如何让其按字母的相反顺序进行排序?
- 循环插入数据库时出现的问题:(
- 关于Mts问题,非高手莫看
- 请教各位VB大侠
看懂下面的例子你就什么都明白了:
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
有么问题再问?
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
在Label1和Form1的MouseMove中加入线段的变色代码,要执行的代码放到MouseUp中去。