致新手:用VB6解决一些有趣的问题(三)

屏幕保护

 

循环显示某个文件夹的图片

设置Form1 BorderSytyle属性为0

添加FileListBox 取名File1  添加一个Timer 取名Timer1

致新手:用VB6解决一些有趣的问题(三)_第1张图片

使用如下代码

 

Option Explicit Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private f() As String Private Sub Form_Click() End End Sub Private Sub Form_Load() Dim i As Integer, j As Integer File1.Visible = False File1.Path = App.Path '文件夹的路径(循环显示) For i = 0 To File1.ListCount - 1 If LCase(Right(File1.List(i), 3)) = "bmp" Or _ LCase(Right(File1.List(i), 3)) = "jpg" Or _ LCase(Right(File1.List(i), 3)) = "gif" Then ReDim Preserve f(j) f(j) = File1.Path & "/" & File1.List(i) j = j + 1 End If Next i If j = 0 Then MsgBox "所在文件夹没有支持的图片!": Timer1.Enabled = False ': End If Me.BackColor = vbBlack SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1 Me.WindowState = 2 Timer1.Interval = 3000 End Sub Private Sub Timer1_Timer() Static i As Integer On Error Resume Next Me.Picture = LoadPicture(f(i)) i = i + 1 If i > UBound(f) Then i = 0 End Sub

 

可以自己更改文件夹路径,运行时候的图片就不贴了

注意生成的时候,文件(File) ->生成(Make) XXX.exe 文件后缀名不要exe 要scr

然后把你的屏幕保护程序设置为Windows的屏幕保护就ko以啦

发挥你的美术功底,给亲朋好友发个礼物吧

 

献给很善良很善良很善良很善良很善良很善良,比天使还善良的人

你可能感兴趣的:(致新手:用VB6解决一些有趣的问题(三))