I have figured out how to change the wallpaper and save it to the registry - the only problem is people have to restart to see it! How do I refresh the desktop so that hte wallpaper gets instantly updated?
THanks
Adrift
Printable View
I have figured out how to change the wallpaper and save it to the registry - the only problem is people have to restart to see it! How do I refresh the desktop so that hte wallpaper gets instantly updated?
THanks
Adrift
Try this:
Code:Private Const RDW_INVALIDATE = &H1
Private Const RDW_INTERNALPAINT = &H2
Private Const RDW_ERASE = &H4
Private Const RDW_VALIDATE = &H8
Private Const RDW_NOINTERNALPAINT = &H10
Private Const RDW_NOERASE = &H20
Private Const RDW_NOCHILDREN = &H40
Private Const RDW_ALLCHILDREN = &H80
Private Const RDW_UPDATENOW = &H100
Private Const RDW_ERASENOW = &H200
Private Const RDW_FRAME = &H400
Private Const RDW_NOFRAME = &H800
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function CreateRectRgnIndirect Lib "gdi32" _
(lpRect As RECT) As Long
Private Declare Function RedrawWindow Lib "user32" _
(ByVal hwnd As Long, lprcUpdate As RECT, ByVal hrgnUpdate _
As Long, ByVal fuRedraw As Long) As Long
Usage
Private Sub Command1_Click()
Dim udtScrDim As RECT
Dim lReturn As Long
Dim hRegion As Long
udtScrDim.Left = 0
udtScrDim.Top = 0
udtScrDim.Right = Screen.Width
udtScrDim.Bottom = Screen.Height
hRegion = CreateRectRgnIndirect(udtScrDim)
If hRegion <> 0 Then
lReturn = RedrawWindow(0, udtScrDim, hRegion, _
RDW_ERASE Or RDW_FRAME Or RDW_INVALIDATE Or RDW_UPDATENOW Or RDW_INTERNALPAINT Or RDW_ALLCHILDREN)
End If
End Sub
It worked!
Thanks a million!
Adrift
Code: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 Const SPI_SCREENSAVERRUNNING = 97
Public Const SPI_SETDESKWALLPAPER = 20
Public Const SPIF_SENDWININICHANGE = &H2
Public Const SPIF_UPDATEINIFILE = &H1
Call SystemParametersInfo(SPI_SETDESKWALLPAPER, True, "C:\Test.bmp", SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
Less lines of code, Nitro?
Two sentences for you:
All code is better than none.
If it works, use it!
But maybe he might like the code you posted better.
Either way, as long as they both work and the customer is satisfied, than...it's all good ;).
Sorry if I tamper with you, but I really wanted to provide a more efficient solution. HeSaidJoe style.
What does ROFL stand for?
No, it wasn't meant like that..wasn't mean to offend you or anything.
It's just funny that you said, if you want to do it with less lines of code.
As HeSaidJoe said once that sometimes people can post this big line of code that gets the job done, and then next, someone posts something shorter which gets the same job done.
All code is better than none, don't worry, your code is of use.
Maybe it might be more efficient than mine.
ROFL = Rolling on the floor laugh
It's lame, but I thought it was funny how I posted a whole lot of code and then you come and post something that probably gets the same job done in 1 line :rolleyes:.
Cool Matthrew.
I have a question for you Matthrew. I am playing around with your codes. I changed the wallpaper already and ran your code after that, but it did not do anything. Is it because I am on Winnt?
Thanks Again. You been helping me a lot but you just don't know it yet. :D
I believe so. But the code I gave does work!Quote:
Is it because I am on Winnt?
I guess its only for Win98 though :rolleyes:.
Thanks Matthrew, see you tomorrow.