Results 1 to 11 of 11

Thread: Refreshing Desktop after wallpaper change

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    12
    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

  2. #2
    Guest
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    12
    It worked!
    Thanks a million!
    Adrift

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633

    Do this if you want less line of codes.

    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)
    Chemically Formulated As:
    Dr. Nitro

  5. #5
    Guest

    Talking ROFL: Muhahahahaha

    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 .

  6. #6
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Sorry if I tamper with you, but I really wanted to provide a more efficient solution. HeSaidJoe style.
    Chemically Formulated As:
    Dr. Nitro

  7. #7
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    What does ROFL stand for?
    Chemically Formulated As:
    Dr. Nitro

  8. #8
    Guest
    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 .

  9. #9
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633

    Smile

    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.
    Chemically Formulated As:
    Dr. Nitro

  10. #10
    Guest
    Is it because I am on Winnt?
    I believe so. But the code I gave does work!
    I guess its only for Win98 though .

  11. #11
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Thanks Matthrew, see you tomorrow.
    Chemically Formulated As:
    Dr. Nitro

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