利用New关键字仿屏保

效果图

 http://v.youku.com/v_show/id_XMzQ2Nzg2Nzg4.html

窗体布局

form1上添加timer控件

属性设置

 

代码部分

form1

Private Sub Form_Load()
    Form1.ScaleWidth = Screen.Width
    Form1.ScaleHeight = Screen.Height
    Dim hbitmap
    Form1.AutoRedraw = True
    hbitmap = CreateCompatibleBitmap(Me.hdc, 0, 0)
    SelectObject Me.hdc, hbitmap
    Me.Refresh
    Timer1.Enabled = True
    'Form1.Visible = False
    
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Or Button = 2 Then
        End
    End If
End Sub

Private Sub Timer1_Timer()
    Static i As Integer
    i = i + 1
    Dim aform As New Form2
    aform.Show
    aform.Top = Screen.Height * Rnd
    aform.Left = Screen.Width * Rnd
    If i > 1000 Then End
    
End Sub

form2

Private Sub Form_KeyPress(KeyAscii As Integer)
    End
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Or Button = 2 Then
        End
    End If
End Sub

module1

Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long


PS:由于知识太有限,如果将图片换成透明背景的话,还达不到想要的效果,查了源码以后发现,有从资源文件装载图片的部分,可惜不会,把我找到的源码贴过来吧

http://www.mndsoft.com/blog/VB6/0969.html


 



 

评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值