Change desktop wallpaper



Change Desktop wallpaper; also learn how You use Drive ,Dir & File Controls to pick the file anywhere in ur system – create a form, 3 command buttons, image box ,” Drive, Dir, File & combo box”.

===vb code start===

Declarations
Public 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

Public Declare Function GetWindowsDirectory Lib “kernel32″ Alias “GetWindowsDirectoryA” (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Public Declare Function GetSystemDirectory Lib “kernel32″ Alias “GetSystemDirectoryA” (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Public Const SPI_SETDESKWALLPAPER = 20

Public Sub SetWallpaper(ByVal TxtPath As String)
Dim WP As Boolean
WP = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, TxtPath, 0)
End Sub

Code
Dim txtFileName As String

Private Sub Combo1_Click()
Select Case Combo1.ListIndex
Case 0
File1.Pattern = “*.bmp”
Case 1
File1.Pattern = “*.jpg”
Case 2
File1.Pattern = “*.gif”
Case 3
File1.Pattern = “*.wmf”
End Select
End Sub

Private Sub Command1_Click()
SetWallpaper txtFileName
Unload Me
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Command3_Click()
SetWallpaper txtFileName
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()

txtFileName = Dir1.Path & “\” & File1.filename

Image1.Picture = LoadPicture(txtFileName)
End Sub

Private Sub Form_Load()
Dir1.Path = GetWndDir
File1.Path = Dir1.Path
Combo1.Text = Combo1.List(0)

txtFileName = Dir1.Path & “\” & File1.List(0)
Image1.Picture = LoadPicture(txtFileName)

End Sub

Private Function GetWndDir() As String
‘ Display the location of the Windows directory
Dim windir As String ‘ receives path of Windows directory
Dim slength As Long ‘ receives length of the string returned

windir = Space(255) ‘ initialize buffer to receive the string
slength = GetWindowsDirectory(windir, 255) ‘ read the path of the Windows directory
windir = Left(windir, slength) ‘ extract the returned string from the buffer
GetWndDir = windir
End Function

===vb code end===

Category : Windows operation
Compatibility : VB 5, VB 6

Related posts

  • POETRY BOT
  • VTERM – billing database manager and processing system.
  • Change background everyday
  • Another “Users Online” Script.
  • Javascript popup software
  • Affiliate Banner Rotation Script
  • Change screen resolution


  • Leave a Reply

    You must be logged in to post a comment.