'改变垂直的移动量符号,以便向相反方向飞 End If If y <= 0 Then '上边界 y = 0 yp = (-1) * yp End If 声音的播出:这里为播放mid文件 MMControl1. DeviceType ="" MMControl1. Filename = "c:\mid\eine.mid" (eine.mid 为一 mid 文件) 逆风编程精品 MMControl1. Command = "open" MMControl1. Command = "play" 这还需利用API函数实现鼠标的隐藏与出现,这里就不一一介绍了。 部分程序代码如下(详细代码及解释请见源文件): Dim x As Integer Dim y As Integer Dim xp As Integer Dim yp As Integer Dim lastx, lasty private Sub Form1_KeyDown(KeyCode As integer, Shift As Integer) Endscrnsave '结束屏幕保护程序 End Sub Private Sub Form1_Load() Move 0, 0,Screen. Width,Screen. Height '让form1全屏显示 hidemouse '隐藏鼠标 x = l000 '蝴蝶的开始位置 y = l000 xp = 80 '移动量 yp = 80 Image5. Picture = Imagel. Picture '确定翅膀张开的图形是“右飞”,蝴蝶向右飞 Image6. Picture = Image2. Picture '确定翅膀合上的图形是“右合” Image7. Picture = Image1. Picture MMControl1. Command = "close" '确保MCI控件已关闭 MMControl1. DeviceType ="" '启动程序就播放mid 声音文件 MMControl1.filename = "c:\mid\eine.mid" MMControl1.Command = "open" MMControl1.Command = "play" End Sub Private Sub Form1_MouseMove(Button As integer, Shift As Integer, x As Single, y As Single ) If IsEmpty (lastx) Or IsEmpty (lasty) Then lastx = x lasty = y End If If Abs(lastx - x) > 2 Or Abs(lasty - y) > 2 Then endscrnsave End If lastx = x lasty = y End Sub Private Sub Form1_Unload (Cancel As integer) MMControl1. Command = "close" Unload Me End Sub Private Sub Timer1_Timer() '判断mid文件是否播放完,如果播放完,进行重播 If MMControl1. Poesition = 895 Then '些mid文件的长度(mid文件的长度,可建立一Label控件,在时钟控件中令 'Lagel1.caption=mmcontrol1.position,就可动态显示播放mid '文件的位置,当mid播放完,就可求出此mid文件的长度。) MMControl1. Command = "prev" '回到此mid文件的开始位置 MMControl1. Command = "play" '播放 End If x = x xp '增加移动量 y = y yp If x > = Form1. ScaleWidth - Image1. Width Then '右边界判断 Image5. Picture = Image3. Picture '换图像 Image6. Picture = Image4. Picture x = Form1. ScaleHeight - Image1. Width xp = (-1) * xp '改变移动量 End If If x < =0 Then Image5.Picture = Image1. Picture Image6.Picture = Imege2. Picture x = 0 xp = (-1) * xp End If If y > = Form1.ScaleHeight - Image1. Height Then y = Form1. ScaleHeight - Image1. Height yp = (-1) * yp End If If y <= O Then y = O yp = (-1) * yp End If If Image7.Picture = Image5. Picture Then '不断改变图象以实现翅膀的一张一合。 Image7. Picture = Image6. Picture Else Image7. Picture = Image5. Picture End If Image7. Move x, y '最关键的一步蝴蝶的移动 End Sub 模块中的代码: Declare Function ShowCursor Lib "user32" (ByVal bSbow As Long) As Long sub endscrnsave() '结束此程序 showmouse End End Sub Sub showmouse() While ShowCursor(True) < 0 Wend End Sub Sub Hidemouse() '隐藏鼠标 While ShowCursor(False) > = 0 Wend End Sub sub Main() If App. PrevInstance = True Then Exit Sub End If Form1. Show End Sub