我用Picture 控件来做按钮,图片里有五个一样大小的图像,但颜色不一样.
窗体和控件的单位是 "像素"在MouseMove 事件里写了这样的代码Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then '是否是单击左键
If X < 0 Or X > 30 Or Y < 0 Or Y > 30 Then '是否移出按钮
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 0, 0, 30, 30, vbSrcCopy
Else
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 120, 0, 30, 30, vbSrcCopy
End If
ElseIf X < 5 Or X > 25 Or Y < 5 Or Y > 25 Then
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 0, 0, 30, 30, vbSrcCopy
Else
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 30, 0, 30, 30, vbSrcCopy
End If
End Sub
在MouseDown 事件里写了这样的代码Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 120, 0, 30, 30, vbSrcCopy
End Sub 这些代码是用来当鼠标移到 Picture上时切割到另外一个图像,单击的时候又切割到别外一个图像
在按钮上移动只要慢一点效果就很好,但是遗憾的是当鼠标飞快的从按钮上移过或移走时图像就不能切回来了请问各位高手,我要如何才能达到完美的 MouseOut 事件啊
窗体和控件的单位是 "像素"在MouseMove 事件里写了这样的代码Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then '是否是单击左键
If X < 0 Or X > 30 Or Y < 0 Or Y > 30 Then '是否移出按钮
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 0, 0, 30, 30, vbSrcCopy
Else
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 120, 0, 30, 30, vbSrcCopy
End If
ElseIf X < 5 Or X > 25 Or Y < 5 Or Y > 25 Then
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 0, 0, 30, 30, vbSrcCopy
Else
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 30, 0, 30, 30, vbSrcCopy
End If
End Sub
在MouseDown 事件里写了这样的代码Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 120, 0, 30, 30, vbSrcCopy
End Sub 这些代码是用来当鼠标移到 Picture上时切割到另外一个图像,单击的时候又切割到别外一个图像
在按钮上移动只要慢一点效果就很好,但是遗憾的是当鼠标飞快的从按钮上移过或移走时图像就不能切回来了请问各位高手,我要如何才能达到完美的 MouseOut 事件啊
解决方案 »
- 求助:简单代码转换(正则表达式)____在线等!!!!
- 请教VB高手,!!如何将Excel表中的资料导入到ORACLE RDB里面?
- VB的COPY文件问题(高分相赠)
- 一个字符串中保存一个变量的名称,如何引用这个变量?
- 在VB中怎么建一个文件夹呀?
- 关于GBtoUTF-8编码转换的问题!
- 如何得到某个进程占用的内存数?
- 看到一个关于地图热区处理的帖子是KissApple(菊花普洱茶)写的,有谁的知道他的联系方式的请告诉我好吗?
- 如何在程序运行当中随时知道Form中的当前具有焦点的控件的名字,并且知道上一个具有焦点的控件的名字
- VB6.0中用Debug.Print怎么打印结构体信息?【求教】
- 请问怎么样在word中插入 vb应用程序
- 怎么样判断picturebox里面是否已经有图象?
你在窗体的mousemove里改回不就行了?
If X < 0 Or X > 30 Or Y < 0 Or Y > 30 Then '是否移出按钮
Picture1.PaintPicture Picture1.Picture, 0, 0, 30, 30, 0, 0, 30, 30, vbSrcCopy
永远执行不了。
而且if嵌套有错误
??
自己画自己?能执行你也看不到啊。
API就是BITBLT,
然后 再用mouseMove mouseDown 会不会快一点
忘记了vb里面有没有mouseOn没有的话可以考虑自己写一个
用起来会很方便
我的单位是"像数"
好菜啊 如果可以的话你做一个出来给我看一看啊,要多加注释啊也可发到
'前两天刚刚研究过这个问题,在网上找到的Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseEnter As Boolean
MouseEnter = (0 <= X) And (X <= Picture1.Width) And (0 <= Y) And (Y <= Picture1.Height)
If MouseEnter Then
'
SetCapture Picture1.hwnd
Text1.Text = "Mouse in picuture!"
Else
Text1.Text = "Mouse out!"
ReleaseCapture
End If
End Sub