graymon

I hope this is a simple one. How do you force the desktop to repaint itself. For an application that I don't want the taskbar to appear, I've been able to move it:

ShowWindow(h, 0);
EnableWindow(h, false);
MoveWindow(h,0,-tbHeight,tbWidth,tbHeight,true);

But there is a "ghost" image of where it used to be. Is there a handle for the desktop and some way to tell it to repaint

Thanks



Re: .NET Compact Framework how do you refresh/repaint desktop

Lars Brange

Have you tested this

InvalidateRect(GetDesktopWindow(), NULL, TRUE);

Lars




Re: .NET Compact Framework how do you refresh/repaint desktop

graymon

I tried it in two steps rather than one to make it less confusing to me.  Getting the DesktopWindow handle was painless,  but it wouldn't work when I tried the InvalidateRect. At first I had some trouble passing it a NULL for the rectangle structure:

[StructLayout(LayoutKind.Sequential)]

public struct RECT

{

public int left;

public int top;

public int right;

public int bottom;

}

So I grabbed the screen size (Screen.PrimaryScreen.Bounds.Height...) and used it to define the RECT that got passed to InvalidateRect. But the ghost image on the desktop remained.

But when I close the app, I make sure to put the taskbar back where it was, and the full screen window closing seems to force a repaint of the DesktopWindow. Thanks for the tip. From everything I read, it should have worked :)