Does anyone know how I can refresh the whole screen including objects outside my visual basic project?
I am assuming that this will require some kind of API call.
Printable View
Does anyone know how I can refresh the whole screen including objects outside my visual basic project?
I am assuming that this will require some kind of API call.
I can think of 2 ways of doing it, The first way is much easier and faster and works a lot better that I anticipated, so use that.
you need these APIsand just call it withCode:Private Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
this refreshes the desktop window, which basicly means the screenCode:Call UpdateWindow(GetDesktopWindow)
Just in case you're interested the secons uses EnumWindows to Get a handle to every window on the screen and refreshes them all individually
Put this in a standard module
Then use RefreshScreen to refresh the whole screen.Code:Private Declare Function UpdateWindow Lib "user32" (ByVal hWnd As Long) As Long
Public Sub RefreshScreen()
Call EnumWindows(AddressOf EnumProc, 0)
End Sub
Public Function EnumProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
Call UpdateWindow(hWnd)
EnumProc = 1
End Function
Use the first one.
Thankyou that was very helpful!