您的位置:逆风者 VB 正文
原作者:www.upwinder.com 添加时间:2007-09-02 原文发表:2007-08-31 人气:13 来源:未知

本文章共3011字,分2页,当前第2页,快速翻页:
 

'改变垂直的移动量符号,以便向相反方向飞
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


 
本文章更多内容<<上一页 - 1 - 2
相关文章

用Visual Basic与MS-Draw开发通用作图软件
解除网虫心病 VB做定时断线程序
带有历史记录功能的菜单
如何用VB建立快捷方式
VB应用程序中打印条形码的两种方法
利用VB实现浮动按钮
在WindowsNT网络中广播消息
VB 从零开始编外挂(八)
API实现完美的图片出现效果
ODBC API 的VB Sample
VB中远程共享显示及声音的实现
Love Letter病毒源代码
VB 从零开始编外挂(一)
用VB编写异步多线程下载程序
VB6中使用错误处理对程序速度的影响
用VB编写一个光驱保镖
用VB实现浮动按钮
在程序中打开 Internet 拨号连接窗口
用VB打造自己的SQL连接器
VB 从零开始编外挂(七)

相关评论


本文章所属分类:首页 VB

  热门关键字: