|
-
Apr 16th, 2000, 07:31 PM
#1
Thread Starter
Lively Member
i need to write some code that will do the same as clicking on the desktop and pressing F5
refresh the screen.
how can i do that ?
-
Apr 16th, 2000, 09:49 PM
#2
Addicted Member
You need to use some APIs, the code to refresh the Desktop is as follows:
Declarations:
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
Code to perform the refresh:
Code:
Private Sub cmdRefresh_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
As I said above, this will update the desktop, if you wish to update a specific Window then you need to specify that Window's handle in the first argument of the RedrawWindow call. You will also need to adjust the size of the update rectangle area and the region rectangle area. You may also want to modify the fuRedraw flags to satisfy your needs, these are only the suggested ones to use when refreshing the desktop.
Hope this is what you were looking for, Later.
-
Apr 17th, 2000, 12:29 PM
#3
Thread Starter
Lively Member
this code does refresh the desktop, but it doesnt do the job.
you see, i try to make a program that will change the wallpaper to a specific html file.
i did everything but one small detail.
if i dont press F5 on the desktop, then i will see the changes only after i restart the computer.
although this code refreshes the desktop, it is not the same as pressing F5 on it.
maybe you have in mind another code that can help me ?
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
|