vb 编程类 谁能给我一个程序关于窗体在屏幕上飘动的,就像小球运动一样,碰壁后弹回。
最好用API做,越简单越好。最好给出注释。谢谢!用VB写,FORM窗体在屏幕上飘动加上对245488403的追问就是一个完整的程序。注:来自网络PrivateSubtmr...
最好用API做,越简单越好。最好给出注释。谢谢!用VB写,FORM窗体在屏幕上飘动
加上对245488403 的追问就是一个完整的程序。注:来自网络
Private Sub tmrBounce_Timer()
Dim ziua
'图片在屏幕上运动的算法
CurX = CurX + VelX
If (CurX > Xmax) Then
CurX = Xmax
VelX = -VelX
' Beep
ElseIf (CurX < BallR) Then
CurX = BallR
VelX = -VelX
' Beep
End If
CurY = CurY + VelY
If (CurY > Ymax) Then
CurY = Ymax
VelY = -VelY
' Beep
ElseIf (CurY < BallR) Then
CurY = BallR
VelY = -VelY
' Beep
End If
DrawBall
end sub
Public Sub Form_Load()
Dim i As Long
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_COLORKEY = &H1
BackColor = &HFEFEFE
SetWindowLong hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes hwnd, &HFEFEFE, 0, LWA_COLORKEY
Form1.Width = 5000
Form1.Height = 9000
Xmax = Screen.Width - Form1.Width
Ymax = Screen.Height - Form1.Height
End Sub 展开
加上对245488403 的追问就是一个完整的程序。注:来自网络
Private Sub tmrBounce_Timer()
Dim ziua
'图片在屏幕上运动的算法
CurX = CurX + VelX
If (CurX > Xmax) Then
CurX = Xmax
VelX = -VelX
' Beep
ElseIf (CurX < BallR) Then
CurX = BallR
VelX = -VelX
' Beep
End If
CurY = CurY + VelY
If (CurY > Ymax) Then
CurY = Ymax
VelY = -VelY
' Beep
ElseIf (CurY < BallR) Then
CurY = BallR
VelY = -VelY
' Beep
End If
DrawBall
end sub
Public Sub Form_Load()
Dim i As Long
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_COLORKEY = &H1
BackColor = &HFEFEFE
SetWindowLong hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes hwnd, &HFEFEFE, 0, LWA_COLORKEY
Form1.Width = 5000
Form1.Height = 9000
Xmax = Screen.Width - Form1.Width
Ymax = Screen.Height - Form1.Height
End Sub 展开
2011-07-14
展开全部
rmb500元,我来做
更多追问追答
追问
你真想钱,要不要我给你一个程序啊!对不起,我已做出来了。你想不到这个钱啦!
追答
做出来就好
我不需要你的程序,这种程序我有一堆
不过都是有价的
你这种无价的,没用的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
同求啊~~~~
追问
Option Explicit
Private Const BallR = 10 ' Radius.
Private CurX As Single ' Position.
Private CurY As Single
Private VelX As Single ' Velocity.
Private VelY As Single
Private Xmax As Single ' Edge of canvas.
Private Ymax As Single
Private Sub DrawBall()
Form1.Left = CurX
Form1.Top = CurY
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询