Click here to Skip to main content
Click here to Skip to main content
Go to top

How to create an automatic Wallpaper Changer with Visual Basic 6.0

, 28 Jun 2010
Rate this:
Please Sign up or sign in to vote.
How to create an automatic Wallpaper Changer with Visual Basic 6.0

Download chwallpaper_src.zip - 159.46 KB

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="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)




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

License

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

Share

About the Author

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

 
Questioncompliment Pinmemberplikukaku9-Dec-12 6:15 
GeneralMy vote of 5 Pinmembermanoj kumar choubey16-Feb-12 19:59 
QuestionPeople still use this??? PinmemberEli Nurman10-Jun-10 6:33 
???
GeneralMy vote of 1 PinmemberMember 15069667-Jun-10 6:49 
Generalhey you people, post comments PinmemberDj Rush5-Dec-07 3:40 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 28 Jun 2010
Article Copyright 2007 by Software_Developer
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid