What I am trying to do is to cause a control (in the same process, but which I have no control of) to redraw itself, and for my code to block until it finished redrawing.
I tried using UpdateWindow
but that doesn't seem to wait for the redraw to finish.
The reason I need to wait for it to finish redrawing is that I would like to grab the screen afterwards.
The control is not a dotNet control, it's a regular windows control.
I've confirmed that:
- The handle is correct.
UpdateWindow
returns true.- Tried sending
InvalidateRect(hWnd, IntPtr.Zero, true)
just before the call toUpdateWindow
to make sure the window needs invalidating. - Tried doing the same thing on the parent window of the control.
Code used:
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool InvalidateRect(IntPtr hWnd, IntPtr rect, bool bErase);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool UpdateWindow(IntPtr hWnd);
public bool PaintWindow(IntPtr hWnd)
{
InvalidateRect(hWnd, IntPtr.Zero, true);
return UpdateWindow(hWnd);
}
//returns true