| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 922 人关注过本帖
标题:[求助]谁可以给我解释以下原代码?
取消只看楼主 加入收藏
limaowin
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2005-3-24
收藏
 问题点数:0 回复次数:1 
[求助]谁可以给我解释以下原代码?

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

If MousePress Then Exit Sub

StopSounds

ButtonPicture1(Index).Picture = DownImage.Picture

lblStatus.Caption = "Mouse Down"

PlayWav MousePressMCI

MousePress = True

End Sub

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

If MouseOver Then Exit Sub

StopSounds

ButtonPicture1(Index).Picture = OverImage.Picture

lblStatus.Caption = "Mouse Over - Button"

PlayWav MouseOverMCI

NewIndex = Index

MouseOver = True

End Sub

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

If Not MousePress Then Exit Sub

StopSounds

PlayWav MouseUpMCI

ButtonPicture1(Index).Picture = UpImage.Picture

lblStatus.Caption = "Mouse Up"

MousePress = False

End Sub

Private Sub Form_Load()

Dim str1 As String

str1 = Space$(255)

MouseOverSound = "boink.wav"

MousePressSound = "bleeb.wav"

MouseUpSound = "type.wav"

''Load the sounds

LoadSound MouseOverSound, MouseOverMCI

LoadSound MousePressSound, MousePressMCI

LoadSound MouseUpSound, MouseUpMCI

Debug.Print mciSendString("PLAY WAVEUP11 FROM 0", str1, 0, 0)

Dim i As Integer

lblStatus.Caption = "Ready?"

For i = ButtonPicture1.LBound To ButtonPicture1.UBound

ButtonPicture1(i).Picture = UpImage.Picture

Next i

End Sub

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

If Not MouseOver Then Exit Sub

StopSounds

lblStatus.Caption = "Mouse Over - Form"

MouseOver = False

MousePress = False

ButtonPicture1(NewIndex).Picture = UpImage.Picture

End Sub

Private Sub Form_Unload(Cancel As Integer)

'This shouldn't be needed but it

'can't hurt to stop the sound

StopSounds

'Unload the form and remove any references

Unload Me

Set Form1 = Nothing

End Sub

Public Function PlayWav(Alias As String)

Dim rt As Long, ErrorString As String

'Play the sound

rt = mciSendString("PLAY " & Alias & " FROM 0", 0&, 0, 0)

If rt <> 0 Then

ErrorString = Space$(255)

mciGetErrorString rt, ErrorString, Len(ErrorString)

MsgBox "Error: " & ErrorString

End If

End Function

Private Sub LoadSound(Filename As String, Alias As String)

Dim CommandString As String, ErrorString As String

Dim ShortPathName As String

Dim AppPath As String

Dim rt As Long

''Get the path name

AppPath = App.Path

If Right$(AppPath, 1) <> "\" Then

AppPath = AppPath & "\"

End If

''Allocate space for short path name

ShortPathName = Space$(255)

''Get the short path name since MCI only accepts those

GetShortPathName AppPath, ShortPathName, Len(ShortPathName)

''Remove empty spaces and the trailing NULL character

ShortPathName = Left$(ShortPathName, Len(Trim$(ShortPathName)) - 1)

'Build the command string

CommandString = "OPEN " & ShortPathName & Filename & " TYPE WAVEAUDIO ALIAS " & Alias

'Open the sound

rt = mciSendString(CommandString, 0&, 0, 0)

If rt <> 0 Then ''Non 0 = error

ErrorString = Space$(255)

mciGetErrorString rt, ErrorString, Len(ErrorString)

MsgBox "Error: " & ErrorString

End If

End Sub

Private Sub StopSounds()

mciSendString "STOP " & MouseOverMCI, 0&, 0, 0

mciSendString "STOP " & MouseUpMCI, 0&, 0, 0

mciSendString "STOP " & MousePressMCI, 0&, 0, 0

End Sub

搜索更多相关主题的帖子: 代码 解释 
2005-03-24 13:20
limaowin
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2005-3-24
收藏
得分:0 
我是初学者,我现在想遍一个很酷的按纽,(鼠标不放去是一个颜色,放上去是一个颜色,单击它又是一个颜色,单击它的同时还要运行一段程序)
我现在连怎么语句都不动,不知道该什么办

我是新来的,希望和大家多多交流! 我的QQ:404108102 E-mail:limaowin1@
2005-03-25 12:00
快速回复:[求助]谁可以给我解释以下原代码?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016158 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved