Force Desktop Refresh

Archives Forums/BlitzPlus Programming/Force Desktop Refresh

_PJ_(Posted 2015) [#1]
Is there any way to force re-drawing of (particular area of ) the desktop?

For example, if the Desktop buffer has been drawn to, artifacts will remain on the desktop until Windows re-draws that area.

Is there anything in User32.dll or Gdi32.dll etc. that may help here?


Rick Nasher(Posted 2015) [#2]
Hmm. This apparently supposed to do a full desktop refresh(haven't been able to test):

RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True


Or probably more usefull the MSDN docs to RedrawWindow function in User32.dll:
https://msdn.microsoft.com/en-us/library/dd162911(v=vs.85).aspx

Which says under Parameters:
hWnd [in] - A handle to the window to be redrawn. If this parameter is NULL, the desktop window is updated.

So not sure if this is correct, but probably something like:
User32_RedrawWindow%(hwnd%, rect%, hrgn%, uint%):"RedrawWindow"


RemiD(Posted 2015) [#3]
http://www.blitzbasic.com/Community/posts.php?topic=104741
http://www.blitzbasic.com/codearcs/codearcs.php?code=3212


_PJ_(Posted 2015) [#4]
I did try this, but it didn't function as intended:
"RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True "

Thanks, for all the otehr suggestions, tooo, though - I should be able to find what I need there!


_PJ_(Posted 2015) [#5]
format_code('.Lib"user32.dll"
User32_RedrawWindow% (hwnd%, lprcUpdate*, hrgnUpdate%, fuRedraw%) : "RedrawWindow"')

"Unknown decls directive" :(


Floyd(Posted 2015) [#6]
I think that should be
format_code('.Lib "user32.dll"
api_RedrawWindow% (hwnd%, lprcUpdate*, hrgnUpdate%, fuRedraw%) : "RedrawWindow"')
A bunch of other user32 functions, if needed: http://www.blitzbasic.com/codearcs/codearcs.php?code=1179


_PJ_(Posted 2015) [#7]
The api_RedrawWindow% or user32_RedrawWindow% is just the function name as used in Blitz, provided the return type is correct (%), It doesn't affect anything, so changing that makes no difference.

It doesn't seem to have any effect at all whether or not there is a space between .Lib and "user32.dll" either.

I suspect the issue may be some virtualisation / UAC preventing direct access to Syswow or system32 directory since I'm using a limited account here.


RemiD(Posted 2015) [#8]
If you want to redraw the content of a window which becomes the active window after it was not the active window (if the user has previously clicked on the desktop or on the taskbar or on another window), the approach i have described here :
http://www.blitzbasic.com/codearcs/codearcs.php?code=3212
works properly on windows xp, windows vista, windows 7, windows 8.

You don't need to use RedrawWindow() you need to use SetWindowPos() with the appropriate flags...


_PJ_(Posted 2015) [#9]
It's the actual desktop buffer.

I was working in a 'desk pet' type program where the drawing is actually on the desktop. Artefacts remain drawn since the actual desktop elements are not redrawn until updated or the mouse cursor moves over them.


RemiD(Posted 2015) [#10]
Oh i see. I misunderstood, i thought you were talking about a window.


_PJ_(Posted 2015) [#11]
It's mlost likely not going to be something readily satisfactorily solved without in depth use of the DWM or other Windows API calls. Probably BlitzPlus is not really the best intended for this type of app