您的位置:逆风者 VB 正文
原作者:www.upwinder.com 添加时间:2007-09-02 原文发表:2007-08-31 人气:4 来源:未知

  这个小软件的功能,自然无法同久已成名的WPC(wallpaper changer)相媲美,但由于是自制的,用起来又别有一番乐趣。古人言,“独乐”不如“众乐”,所以我拿出来与大家共享,又希望能让初学者对于VB编程窥见一斑。
逆风编程技术

  这个小软件所用控件仅一列表框,两文本框,两标签,两命令及一定时控件而已。

  源代码:

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA"(ByVal uAction As Long, ByVal uParam As Long,ByVal lpvParam As Any,ByVal fuWinIni As Long) As Long
Dim flag As Boolean
Const SPI_SETDESKWALLPAPER = 20
Const SPIF_UPDATEINIFILE = &H1 
'update Win.ini Constant
Const SPIF_SENDWININICHANGE = &H2
'update Win.ini and tell everyone

Private Sub CmdCancel_Click()
  flag = False
  Textpath = ""
  Textintval = ""
  Listfile.Clear
End Sub

Private Sub CmdOK_Click()
  Dim temp As String
  temp = Textpath.Text
  If temp = "" Then End
  If Right$(temp, 1) <> "\" Then
    temp = temp "\"
  End If
  Listfile.Tag = temp
  temp = temp "*.bmp"
  temp = Dir$(temp)
  While temp <> ""
    Listfile.AddItem temp
    temp = Dir$
  Wend
  Listfile.AddItem "None"
  Show
  Listfile.ListIndex = 0
  If Listfile.List(0) = "None" Then
    flag = False
  Else
    flag = True
  End If
End Sub

Private Sub Form_Load()
  flag = False
  Timer1.Interval = Val(Textintval.Text)
End Sub

Private Sub Timer1_Timer()
  Dim temp As String
  Dim bmpfile As String
  If flag Then
    temp = Listfile.Tag
    bmpfile = temp Listfile.List(Listfile.ListIndex)
    SystemParametersInfo SPI_SETDESKWALLPAPER, 0, bmpfile, SPIF_UPDATEINIFILE
    If Listfile.ListIndex = Listfile.ListCount - 1 Then
      Listfile.ListIndex = 0
    End If
    Listfile.ListIndex = Listfile.ListIndex 1
  End If
End Sub

相关文章

在VB中如何得到网络中某一台电脑(电脑名)的
桌面屏幕翻转
用VB计算1 1=2
在桌面上建立一个 Internet 快捷键
用VB尝试新的界面风格
用VB读写注册表实例
自动更新工作站的应用程序
VB实现按钮浮动效果
VB6制作Win98风格的工具栏
利用INI文件给程序创建动态菜单
利用两种简易方法实现直接打开一个文件
PING一个IP地址(向它发送一个数据包并等待
开启文件属性窗口
Viusal Basic程序员的.NET泛型编程
VB应用程序的启动与退出设计
动态改变屏幕设置
FSO对象模型在VB中的应用
VB 从零开始编外挂(十二)
用VB编写简单的时钟程序(有时、分、秒针转
移动文件到回收站

相关评论


本文章所属分类:首页 VB

  热门关键字: