I have a non-fullscreen DirectX window displaying video, which I for application purposes need to both move around and sometimes change from hidden/visible programmatically.
When going from hidden to visible the window may sometimes need to be moved to a new position before it is shown.
I hide the window with ShowWindow(hWnd, SW_HIDE).
When I want to show the window again, at a new position, I first move it with SetWindowPos using the new coordinates and SWP_NOREDRAW and SWP_NOZORDER flags (I don’t want to mess with the Z-order).
Then I call ShowWindow(hWnd, SW_SHOW) for the window to appear at the new position. This works fine except for the window briefly appearing at the position where is was last visible before it appears at its new correct position.
I have tried using the alternatives MoveWindow (with repaint-option set to false) and GetWindowPlacement together with SetWindowPlacement (with appropriate flags), buth they give the same result.
How can I force the window to appear at the right position when going from hidden to visible?
Turns out the problem was not the fault of either the Windows API or DirectX, but a tricky bug in the way the decoder was handled.
Placement of the window and its visibility status is based on a values in frame user-data passed through the video decoder. When the decoder stopped receiving input data, happening when the network connection to the encoder was broken, it would also stop giving callbacks for decoded frames, with data still in its “pipeline”. When input data arrived in the decoder again it spit out a few of the “stuck” frames, with user-data which was no longer valid.