johnyjoja
Mar 16th, 2001, 11:22 AM
I would like to know how to set a *.jpg or *gif file as your background using VB,
I used this code,
Public Const SPI_SETDESKWALLPAPER = 20
Public Const SPIF_SENDWININICHANGE = &H2
Public Const SPIF_UPDATEINIFILE = &H1
Public Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Public Sub SetWallPaper(strFileName As String)
Dim lngResult As Long
Dim lngFlags As Long
lngFlags = SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE
lngResult = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal strFileName, lngFlags)
End Sub
and as used in the code:
private sub nameofit()
CommonDialog1.Filter = "*.bmp|*.jpg|*.gif"
CommonDialog1.DialogTitle = "Change Wallpaper"
CommonDialog1.Action = 1
filename = CommonDialog1.filename
SetWallPaper = filename
end sub
PLEASE HELP ME OUT...
thnx in advance
I used this code,
Public Const SPI_SETDESKWALLPAPER = 20
Public Const SPIF_SENDWININICHANGE = &H2
Public Const SPIF_UPDATEINIFILE = &H1
Public Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Public Sub SetWallPaper(strFileName As String)
Dim lngResult As Long
Dim lngFlags As Long
lngFlags = SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE
lngResult = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal strFileName, lngFlags)
End Sub
and as used in the code:
private sub nameofit()
CommonDialog1.Filter = "*.bmp|*.jpg|*.gif"
CommonDialog1.DialogTitle = "Change Wallpaper"
CommonDialog1.Action = 1
filename = CommonDialog1.filename
SetWallPaper = filename
end sub
PLEASE HELP ME OUT...
thnx in advance