refresh desktop

  • Thread starter Thread starter jhirst
  • Start date Start date
J

jhirst

I have written a piece of code that ramdomly chooses a
picture and changes the desktop background accordingly.
When I change the registry key (HKEY_CURRENT_USER/control
panel/desktop/Wallpaper) the key value changes but it does
not update the background of the desktop. If I restart
the computer it has changed. How do I update the
background to the new picture. How do I manually refresh
the Desktop? (C++, Visual Studio.NET).
 
I have only ever done this using VBScript and an ActiveX control called AutoIT... In case this solution could work for you here are the details..

Download AutoIT version 2, installit and grab the AutoITX.DL
You will need to register this using RegSvr32.exe on the target system... This can be done with VBScript also..

Once registered the following script can be used to refresh the desktop... The script simply right clicks on the desktop and selects 'Refresh'..

'VBScrip
Dim oAutoI
Set oAutoIt = WScript.CreateObject("AutoItX.Control"
oAutoIt.WinMinimizeAl
oAutoIt.Sleep 150
oAutoIt.RightClick 600, 1
oAutoIt.Sleep 30
oAutoIt.SetKeyDelay 10
oAutoIt.Send "E"
Wscript.quit
 
I have only ever done this using VBScript and an ActiveX control called AutoIT... In case this solution could work for you here are the details..

Download AutoIT version 2, installit and grab the AutoITX.DL
You will need to register this using RegSvr32.exe on the target system... This can be done with VBScript also..

Once registered the following script can be used to refresh the desktop... The script simply right clicks on the desktop and selects 'Refresh'..

'VBScrip
Dim oAutoI
Set oAutoIt = WScript.CreateObject("AutoItX.Control"
oAutoIt.WinMinimizeAl
oAutoIt.Sleep 150
oAutoIt.RightClick 600, 1
oAutoIt.Sleep 30
oAutoIt.SetKeyDelay 10
oAutoIt.Send "E"
Wscript.quit
 
Thank you for replying. I didn't use it but it prompted
me into finding the following code. This changes the
background (string containing path to picture is szNew)
and sends an update message to all top-level windows)

I have yet to work around the active desktop stuff!

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, szNew,
SPIF_SENDCHANGE);
 
Thank you for replying. I didn't use it but it prompted
me into finding the following code. This changes the
background (string containing path to picture is szNew)
and sends an update message to all top-level windows)

I have yet to work around the active desktop stuff!

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, szNew,
SPIF_SENDCHANGE);
 
jhirst said:
I have written a piece of code that ramdomly chooses a
picture and changes the desktop background accordingly.
When I change the registry key (HKEY_CURRENT_USER/control
panel/desktop/Wallpaper) the key value changes but it does
not update the background of the desktop. If I restart
the computer it has changed. How do I update the
background to the new picture. How do I manually refresh
the Desktop? (C++, Visual Studio.NET).

see windows API "SystemParametersInfo" for setting the background image.

Lar.
 
jhirst said:
I have written a piece of code that ramdomly chooses a
picture and changes the desktop background accordingly.
When I change the registry key (HKEY_CURRENT_USER/control
panel/desktop/Wallpaper) the key value changes but it does
not update the background of the desktop. If I restart
the computer it has changed. How do I update the
background to the new picture. How do I manually refresh
the Desktop? (C++, Visual Studio.NET).

see windows API "SystemParametersInfo" for setting the background image.

Lar.
 
Back
Top