by Yossof Shehata Elnaggar (1 Submission)
Category: Windows System Services
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 4th May 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
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
API 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
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
No comments have been posted about Change Desktop wallpaper; also learn how You use Drive ,Dir & File Controls to pick the file anywhe. Why not be the first to post a comment about Change Desktop wallpaper; also learn how You use Drive ,Dir & File Controls to pick the file anywhe.