关于vb按钮的一个问题,急,在线等

来源:百度知道 编辑:UC知道 时间:2024/05/23 12:55:54
我在vb中用image控件加了一张图片做成一个按钮,可是鼠标经过这个按钮时根本看不出它是按钮,所以我想是不是可以当鼠标经过时改变图片,并加一个声音,可怎么做呢?
能不能尽量说的详细一点,拜托~

Dim flg
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture("c:\2.jpg")
flg = False
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Not flg Then
flg = True
Image1.Picture = LoadPicture("c:\1.jpg")
Beep 440, 100
End If
End Sub

在image的mouse_move事件中添加代码:
1.改变image1的图片为图片2
2.播放声音

在form的mouse move事件中判断x,y是不是不在image范围,然后是的话
1.改回image1的图片为图片1

一般写在图片的mouse_move事件和窗体Form的mouse_move事件做切换来实现效果
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture("...")
'播放声音
End Sub

Private Sub Form_MouseMove(Button As Integer,