Results 1 to 6 of 6

Thread: Refreshing the Desktop

  1. #1
    VBQuery
    Guest

    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.

  2. #2
    Hyperactive Member Alan777's Avatar
    Join Date
    Jan 2001
    Location
    New Zealand
    Posts
    303
    Check out these APIs:
    VB Code:
    1. Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long
    2.  
    3. 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."

  3. #3
    VBQuery
    Guest

    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.

  4. #4
    Member
    Join Date
    Feb 2002
    Posts
    38
    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]

  5. #5
    VBQuery
    Guest
    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.

  6. #6
    VBQuery
    Guest
    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
  •  



Click Here to Expand Forum to Full Width