|
-
May 18th, 2002, 04:22 AM
#1
Refreshing the Desktop
Does anyone know how to refresh the desktop after changing some of its properties (eg the wallpaper image) in the registry using code? I'm guessing I need to use the SendMessage API to get the Desktop to refresh but don't know exactly what I have to do or where to look to find out.
-
May 18th, 2002, 06:49 AM
#2
Hyperactive Member
Check out these APIs:
VB Code:
Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long
Declare Function RedrawWindow Lib "user32" Alias "RedrawWindow" (ByVal hwnd As Long, lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
And you might want to have a look here.
"Today's mighty oak is just yesterday's nut,
that held its ground."
-
May 18th, 2002, 11:06 PM
#3
Not quite there.
Thanks Alan,
I have tried RedrawWindow and it works but does not requery the registry. Unfortunately it seems that it only redraws the window as it was. I am looking for something that will allow me to do something like the "Apply" button on the desktop propities window.
-
May 19th, 2002, 02:05 AM
#4
Member
windows is really weird. i don't know how to directly tell it to refresh the desktop based on the registry, but with the following code you can manually enter the path to the new wallpaper.
Code:
Const SPIF_SENDWININICHANGE = &H2
Const SPIF_UPDATEINIFILE = &H1
Const SPI_SETDESKWALLPAPER = 20
Private 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
Private Sub Command1_Click()
Dim LTemp As Long
LTemp = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, "C:\Documents and Settings\Administrator\My Documents\My Pictures\003_1280.bmp", SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Sub
Chris Haas
Web Developer
Ovation Advertising & Marketing
p. (608) 785-2460
e. [email protected]
-
May 19th, 2002, 10:23 PM
#5
Thanks Chris,
I am already changing the wallpaper & some other setings using a .reg file but need to have these changes take effect without forceing a reboot of the machine.
-
May 21st, 2002, 12:53 AM
#6
Chris,
Since I replied to your post I have tried using SystemParametersInfo and it causes the desktop to refresh, but only those setings under "Desktop" in the registry seem to be used. I also want to update some of the colour settings. These don't update when the wallpaper is refreshed. Is there an API like SystemParametersInfo that would do this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|