|
-
Oct 9th, 2000, 06:59 PM
#1
Thread Starter
New Member
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
-
Oct 9th, 2000, 07:03 PM
#2
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
-
Oct 9th, 2000, 07:29 PM
#3
Thread Starter
New Member
It worked!
Thanks a million!
Adrift
-
Oct 9th, 2000, 08:12 PM
#4
Fanatic Member
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
-
Oct 9th, 2000, 08:22 PM
#5
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 .
-
Oct 9th, 2000, 08:25 PM
#6
Fanatic Member
Sorry if I tamper with you, but I really wanted to provide a more efficient solution. HeSaidJoe style.
Chemically Formulated As:
Dr. Nitro
-
Oct 9th, 2000, 08:26 PM
#7
Fanatic Member
What does ROFL stand for?
Chemically Formulated As:
Dr. Nitro
-
Oct 9th, 2000, 08:37 PM
#8
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 .
-
Oct 9th, 2000, 08:40 PM
#9
Fanatic Member
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
-
Oct 9th, 2000, 08:53 PM
#10
Is it because I am on Winnt?
I believe so. But the code I gave does work!
I guess its only for Win98 though .
-
Oct 9th, 2000, 09:08 PM
#11
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|