Click here to Skip to main content
15,917,176 members
Articles / Programming Languages / Visual Basic 6
Article
Stats
Revisions (10)
VB6
Windows
.NET
Visual-Studio

How to create an automatic Wallpaper Changer with Visual Basic 6.0

Software_Developer
Rate me:
Please Sign up or sign in to vote.
1.94/5 (8 votes)
28 Jun 2010 CPOL2 min read 45.9K   2.2K   22   5
How to create an automatic Wallpaper Changer with Visual Basic 6.0

Download chwallpaper_src.zip - 159.46 KB

Image 1

Designing apps in Visual basic is pretty straightforward.
Click on the desired component (control) , located at the left toolbar
of visual basic and draw it at an appropiate locaton on the form.
Componments on the form align to rectangular grids giving
your apps a symmetric look.

This app uses the following components:

- command buttons
- radio buttons
- check boxes
- horizontal scroll bars
- frames
- image controls
- list box
- timer
- labels

Altering the wallpaper change mode

Screenshot - wall03_change_mode.jpg

Selection of how the app will change desktop wallpapers is
done here. One can either let the app automatically change
wallpapers or one can manually do so by clicking the
'set as wallpaper' button.



Private Sub optMode_Click(Index As Integer)
	Select Case Index
	Case 0: optMode(0).Value = True
	Case 1: optMode(1).Value = True
	End Select
End Sub

If optMode(0).Value = True Then
    
           
        '***********************
        
If optSeq(0).Value = True Then

     cnt = cnt + 1
     Frame5.Caption = " Wallpapers  ( " & MaxWallpaperFiles & "  files ) " & MaxWallpaperFiles - cnt & "  to go "
      'CurrentWallpaperFile = DoneWallpaperFiles(cnt)
       CurrentWallpaperFile = Int(MaxWallpaperFiles * Rnd)
     List1.ListIndex = CurrentWallpaperFile
     'If (DoneFileCount > MaxWallpaperFiles) Then

	     If (cnt > MaxWallpaperFiles - 1) Then
	     cnt = 0
	      ' DoneFileCount = 0
	      GenerateRandomFile

     End If

End If


Setting the wallpaper change sequence
Screenshot - wall04_change_sequence.jpg

The sequence of the wallpapers can be randomily done or
sequenced in a foward non-random direction.
The app generates a series of random numbers, stores them
in an array. This is done to assure that numbers arent
repeated as often occurs when using the random function.

Private Sub optSeq_Click(Index As Integer)
Select Case Index
      Case 0:
                optSeq(0).Value = True
                optSeq(1).Value = False
                autoMode = True
      Case 1:
                optSeq(1).Value = True
                optSeq(0).Value = False
                autoMode = False
   End Select
End Sub

If optSeq(1).Value = True Then



        List1.ListIndex = CurrentWallpaperFile
        FileName1 = DriveLetter & WallpaperFile(CurrentWallpaperFile).Path & WallpaperFile(CurrentWallpaperFile).Name
        Image1.Picture = LoadPicture(FileName1)


        If (CurrentWallpaperFile > MaxWallpaperFiles - 1) Then CurrentWallpaperFile = 0
        Frame5.Caption = " Wallpapers  ( " & MaxWallpaperFiles & "  files ) " & (MaxWallpaperFiles - 1) - CurrentWallpaperFile & "  to go "


            Else

            'DoneFileCount = DoneFileCount + 1
            'CurrentWallpaperFile = DoneWallpaperFiles(DoneFileCount)




    End If


Adjusting the wallpaper change time

Screenshot - wall05_change_delay.jpg

The default time and max time is set to 30 seconds but can be
reduced down to 2 seconds using the scrollbar.

Private Sub HScroll1_Change()
    Timer1.Interval = HScroll1.Value
    Label10.Caption = " " & Timer1.Interval / 1000 & " seconds"
    WallpaperChangeInterval = HScroll1.Value
End Sub

The Program's loop

< alt="Screenshot - wall06_timer.jpg" src="/KB/vb/wallpaperchanger/wall06_timer.jpg" />

The core of this app has been placed in Timer1
to make things as simple as can be.

Private Sub Timer1_Timer()

        '********************
        '**                **
        '********************
        On Error Resume Next
        
        TimerStart = Timer
        
         'Delay = ((TimeDelay / 1000) - (TimerElap - TimerStart)) * 1000
          Delay = TimeDelay - Int(((TimerElap - TimerStart)) * 1000)
        
        '***********************
                        
If optMode(0).Value = True Then
    
           
        '***********************
        
        If optSeq(0).Value = True Then
        
             cnt = cnt + 1
             Frame5.Caption = " Wallpapers  ( " & MaxWallpaperFiles & "  files ) " & MaxWallpaperFiles - cnt & "  to go "
              'CurrentWallpaperFile = DoneWallpaperFiles(cnt)
               CurrentWallpaperFile = Int(MaxWallpaperFiles * Rnd)
             List1.ListIndex = CurrentWallpaperFile
             'If (DoneFileCount > MaxWallpaperFiles) Then
             
             If (cnt > MaxWallpaperFiles - 1) Then
             cnt = 0
              ' DoneFileCount = 0
              GenerateRandomFile
                              
             End If
        
        End If
        
        '***********************
       If optSeq(1).Value = True Then
             
            
            
             List1.ListIndex = CurrentWallpaperFile
             FileName1 = DriveLetter & WallpaperFile(CurrentWallpaperFile).Path & WallpaperFile(CurrentWallpaperFile).Name
             Image1.Picture = LoadPicture(FileName1)
    
            
             If (CurrentWallpaperFile > MaxWallpaperFiles - 1) Then CurrentWallpaperFile = 0
             Frame5.Caption = " Wallpapers  ( " & MaxWallpaperFiles & "  files ) " & (MaxWallpaperFiles - 1) - CurrentWallpaperFile & "  to go "
                 
                 
                 Else
                
                 'DoneFileCount = DoneFileCount + 1
                 'CurrentWallpaperFile = DoneWallpaperFiles(DoneFileCount)
            
    
       
             
         End If
     
     ChangeWallpaper
     CurrentWallpaperFile = CurrentWallpaperFile + 1
         
     If (CurrentWallpaperFile > MaxWallpaperFiles - 1) Then CurrentWallpaperFile = 0
     
       
     'DoneFileCount = DoneFileCount + 1
     'MsgBox DoneFileCount & ".  " & DoneWallpaperFiles(DoneFileCount) & " opps"
      
    End If
     
End Sub

when all said and done
(when the code is run)

Image 5


Browsing for wallpapers and
selecting wallpaper folders.

03.jpg

Obviously this app would be useless without this feature. Browsing for
folders containing wallpapers is pretty straightforward. Select the
folder containing the 'bmp files and click the ' ok ' button.
The app will list all bmp files found in the directory, in the list box
located to the lower left section of the form.

Selecting the files is done by clicking the file in question,
a preview of the .bmp file will be rendered in the wapaper preview.
Clicking the ' set as wallpaper ' will set it as wallpaper or
one can click the ' automatic ' radio button to have the app
automatically set the wallpapers.



Download Source code : Download chWallpaper_src.zip - 198.03 KB

两个鬼故事什么是差额选举我的世界燧石长安三怪探第二部丧茶起名字女儿梦见水水着彼女osxelcapitan起名四字大全昆山一建筑造型像搭积木东北往事之黑道风云20年小说南京公司起名三步曲琴棋书画十字绣图片2009年nba总决赛政法工作条例属虎的女孩怎么起名才好千反田中国银行的理财产品网名起什么好三个土这里有妖气不死武尊商贸个体户名称怎么起名给建筑劳务企业起名台北晚九朝五体坛周报创办于2015属羊起名大全绿化公司起名四个字的三个字什么商标起名少年生前被连续抽血16次?多部门介入两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”淀粉肠小王子日销售额涨超10倍高中生被打伤下体休学 邯郸通报单亲妈妈陷入热恋 14岁儿子报警何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言张家界的山上“长”满了韩国人?男孩8年未见母亲被告知被遗忘中国拥有亿元资产的家庭达13.3万户19岁小伙救下5人后溺亡 多方发声315晚会后胖东来又人满为患了张立群任西安交通大学校长“重生之我在北大当嫡校长”男子被猫抓伤后确诊“猫抓病”测试车高速逃费 小米:已补缴周杰伦一审败诉网易网友洛杉矶偶遇贾玲今日春分倪萍分享减重40斤方法七年后宇文玥被薅头发捞上岸许家印被限制高消费萧美琴窜访捷克 外交部回应联合利华开始重组专访95后高颜值猪保姆胖东来员工每周单休无小长假男子被流浪猫绊倒 投喂者赔24万小米汽车超级工厂正式揭幕黑马情侣提车了西双版纳热带植物园回应蜉蝣大爆发当地回应沈阳致3死车祸车主疑毒驾恒大被罚41.75亿到底怎么缴妈妈回应孩子在校撞护栏坠楼外国人感慨凌晨的中国很安全杨倩无缘巴黎奥运校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变王树国卸任西安交大校长 师生送别手机成瘾是影响睡眠质量重要因素国产伟哥去年销售近13亿阿根廷将发行1万与2万面值的纸币兔狲“狲大娘”因病死亡遭遇山火的松茸之乡“开封王婆”爆火:促成四五十对奥巴马现身唐宁街 黑色着装引猜测考生莫言也上北大硕士复试名单了德国打算提及普京时仅用姓名天水麻辣烫把捣辣椒大爷累坏了

两个鬼故事 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software_Developer
Sweden Sweden
About me:
I attended programming college and I have a degree in three most famous and successful programming languages. C/C++, Visual Basic and Java. So i know i can code. And there is a diploma hanging on my wall to prove it.
.
I am a professional, I am paid tons of cash to teach or do software development. I am roughly 30 years old .

I hold lectures in programming. I have also coached students in C++, Java and Visual basic.

In my spare time i do enjoy developing computer games, and i am developing a rather simple flight simulator game
in the c++ programming language using the openGL graphics libray.

I've written hundreds of thousands of code syntax lines for small simple applications and games.

Comments and Discussions

 
Question compliment Pin
plikukaku9-Dec-12 6:15
plikukaku9-Dec-12 6:15 
General My vote of 5 Pin
Manoj Kumar Choubey16-Feb-12 19:59
professional Manoj Kumar Choubey16-Feb-12 19:59 
Question People still use this??? Pin
Eli Nurman10-Jun-10 6:33
Eli Nurman10-Jun-10 6:33 
General My vote of 1 Pin
Member 15069667-Jun-10 6:49
Member 15069667-Jun-10 6:49 
General hey you people, post comments Pin
Software_Developer5-Dec-07 3:40
Software_Developer5-Dec-07 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


两个鬼故事什么是差额选举我的世界燧石长安三怪探第二部丧茶起名字女儿梦见水水着彼女osxelcapitan起名四字大全昆山一建筑造型像搭积木东北往事之黑道风云20年小说南京公司起名三步曲琴棋书画十字绣图片2009年nba总决赛政法工作条例属虎的女孩怎么起名才好千反田中国银行的理财产品网名起什么好三个土这里有妖气不死武尊商贸个体户名称怎么起名给建筑劳务企业起名台北晚九朝五体坛周报创办于2015属羊起名大全绿化公司起名四个字的三个字什么商标起名少年生前被连续抽血16次?多部门介入两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”淀粉肠小王子日销售额涨超10倍高中生被打伤下体休学 邯郸通报单亲妈妈陷入热恋 14岁儿子报警何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言张家界的山上“长”满了韩国人?男孩8年未见母亲被告知被遗忘中国拥有亿元资产的家庭达13.3万户19岁小伙救下5人后溺亡 多方发声315晚会后胖东来又人满为患了张立群任西安交通大学校长“重生之我在北大当嫡校长”男子被猫抓伤后确诊“猫抓病”测试车高速逃费 小米:已补缴周杰伦一审败诉网易网友洛杉矶偶遇贾玲今日春分倪萍分享减重40斤方法七年后宇文玥被薅头发捞上岸许家印被限制高消费萧美琴窜访捷克 外交部回应联合利华开始重组专访95后高颜值猪保姆胖东来员工每周单休无小长假男子被流浪猫绊倒 投喂者赔24万小米汽车超级工厂正式揭幕黑马情侣提车了西双版纳热带植物园回应蜉蝣大爆发当地回应沈阳致3死车祸车主疑毒驾恒大被罚41.75亿到底怎么缴妈妈回应孩子在校撞护栏坠楼外国人感慨凌晨的中国很安全杨倩无缘巴黎奥运校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变王树国卸任西安交大校长 师生送别手机成瘾是影响睡眠质量重要因素国产伟哥去年销售近13亿阿根廷将发行1万与2万面值的纸币兔狲“狲大娘”因病死亡遭遇山火的松茸之乡“开封王婆”爆火:促成四五十对奥巴马现身唐宁街 黑色着装引猜测考生莫言也上北大硕士复试名单了德国打算提及普京时仅用姓名天水麻辣烫把捣辣椒大爷累坏了

两个鬼故事 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化