效果:屏幕剥落

  前几天心血来潮,做了一个屏幕剥落的小效果~拿出来和大家分享,同时也要感谢MySticBoy在API的使用上对我的指导~

  首先按照管理,窗体的AutoRedraw为True,BorderStyle为0,ScaleMode为3,另外就是WindowState设为2。然后添加Timer控件命名为tmr,PictureBox命名为picBack,AutoRedraw为True,AutoSize为True,并将它的ScaleMode也设为3。下面写上代码:

Option Explicit
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Const SRCCOPY = &HCC0020

Private Const POINT_NUM = 200
Private Const BACK_COLOR = &HFFFFFF
Private Type POINT
    x      As Long
    y      As Long
    V      As Long
End Type
Private pPoints() As POINT
Private lTop As Long
Private lCountNow As Long

Dim i As Long
Dim j As Long

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyEscape Then End
End Sub

Private Sub Form_Load()
    BitBlt Me.hdc, 0, 0, Screen.Width, Screen.Height, GetDC(GetDesktopWindow()), 0, 0, SRCCOPY
    picBack.Picture = Me.Image
    Show
    picBack.Left = Me.ScaleWidth
    ReDim pPoints(POINT_NUM)
    lTop = -2
    For i = 0 To POINT_NUM
        Randomize
        pPoints(i).x = Rnd * Me.ScaleWidth
        Randomize
        pPoints(i).y = Rnd * 50 + lTop
        Randomize
        pPoints(i).V = Rnd * 50 + 10
        picBack.Line (pPoints(i).x, pPoints(i).y)-(pPoints(i).x + 3, pPoints(i).y + 3), vbWhite, BF
    Next i
    lCountNow = lCountNow + POINT_NUM
    tmr.Enabled = True
End Sub

Private Sub tmr_Timer()
    For i = 0 To POINT_NUM
        BitBlt Me.hdc, pPoints(i).x, pPoints(i).y, 4, 4, picBack.hdc, pPoints(i).x, pPoints(i).y, SRCCOPY
        BitBlt Me.hdc, pPoints(i).x, pPoints(i).y + pPoints(i).V, 4, 4, picBack.hdc, pPoints(i).x, pPoints(i).y, SRCCOPY
        pPoints(i).y = pPoints(i).y + pPoints(i).V
        If pPoints(i).y >= Me.ScaleHeight Then
WrongPoint:
            Randomize
            pPoints(i).x = Rnd * Me.ScaleWidth
            Randomize
            pPoints(i).y = Rnd * 50 + lTop
            Randomize
            pPoints(i).V = Rnd * 50 + 10
            picBack.Line (pPoints(i).x, pPoints(i).y)-(pPoints(i).x + 3, pPoints(i).y + 3), vbWhite, BF
            lCountNow = lCountNow + 1
        End If
        If lCountNow * 2 >= Me.ScaleWidth Then
            lTop = lTop + 2
            lCountNow = 0
        End If
    Next i
    Me.Refresh
    DoEvents
End Sub

  如何?效果还不错吧~反正我觉得速度是快多了(还要感谢MysticBoy的提醒啊)

最终通过环境:VB6+Win2000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值