| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 468 人关注过本帖
标题:这个屏保代码,如何能让图片的移动更平滑些呢?
只看楼主 加入收藏
ggyy66
Rank: 1
等 级:新手上路
帖 子:427
专家分:0
注 册:2007-8-14
结帖率:86.25%
收藏
 问题点数:0 回复次数:0 
这个屏保代码,如何能让图片的移动更平滑些呢?
这个屏保代码,如何能让图片的移动更平滑些呢?
以下代码可以实现一个图片在屏幕上移动,但是现在的问题是移动不够平滑,如何改可以实现呢?
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Dim WithEvents lbl1 As Label
Dim WithEvents Timer1 As Timer
Dim WithEvents Timer2 As Timer
Dim WithEvents image1 As Image


Private Sub Form_Load()
    Set lbl1 = Me.Controls.Add("VB.Label", "lbl1")
    Set Timer1 = Me.Controls.Add("VB.Timer", "Timer1")
    Set Timer2 = Me.Controls.Add("VB.Timer", "Timer2")
    Set image1 = Me.Controls.Add("vb.image", "image1")
    With Me
        .BorderStyle = 0
        .Caption = ""
        .BackColor = &H0&
        .KeyPreview = True
        .WindowState = 2
    End With
    image1.Stretch = False
    image1.Visible = True
    image1.Picture = LoadPicture(App.Path & "\tmp.bmp")
   
    With lbl1
        .Visible = True
        .AutoSize = True
        .BackStyle = 0
        .Caption = "美人如此多娇,引无数英雄竞折腰"
        .Font.Size = 60
        .Font.Name = "楷体_gb2312"
        .Font.Bold = True
        .ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
        .Move 0, 0
    End With
   
    Timer1.Enabled = True
    Timer1.Interval = 1500
    Timer2.Enabled = True
    Timer2.Interval = 800
End Sub


Private Sub Timer1_Timer()
   
    Dim i#, j#
    i = Rnd * 15000
    j = Rnd * 10000
    image1.Move i, j
   
End Sub

Private Sub Timer2_Timer()
    lbl1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub

'在窗体上按下按键时退出程序
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Or KeyCode = 27 Then
        Unload Me
    End If
End Sub

'在窗体上移动鼠标或单击鼠标时退出程序
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    Unload Me
End Sub
搜索更多相关主题的帖子: 代码 屏保 
2009-08-12 14:12
快速回复:这个屏保代码,如何能让图片的移动更平滑些呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023827 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved