利用New关键字仿屏保

来源:互联网 发布:mac用excel怎么截图 编辑:程序博客网 时间:2024/05/22 08:29

效果图

 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 SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)    If Button = 1 Or Button = 2 Then        End    End IfEnd SubPrivate 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)    EndEnd SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)    If Button = 1 Or Button = 2 Then        End    End IfEnd Sub

module1

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


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

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


 



 

原创粉丝点击