ADAM'S WEB PRESENCE

15 November 2007

Moving a DirectShow window while paused

Filed under: Nerd Notes — adam @ 2:26 pm

directshowmoveproblem.jpegI’ve been writing a lot of DirectX / DirectShow stuff lately and I’ve come across a problem if I pause a video replay and then move the containing window. The playback window becomes separated from the containing window even though I am handling the WM_MOVE event.

You’d think that the following code would work:

void CMyWindow::OnMove()
{
    CRect r;
    GetClientRect(r);

// _piWindow is a pointer to my filtergraph's IVideoWindow interface.
    _piWindow->SetWindowPosition(r.left, r.top, r.Width(), r.Height());
}

It works fine if the video is playing but if the replay is paused, the active movie window will ignore the window move commands.

The solution was to trick DirectShow into thinking that you want to resize the window like so:

void CMyWindow::OnMove()
{
    CRect r;
    GetClientRect(r);

    _piWindow->SetWindowPosition(r.left, r.top, r.Width() + 4, r.Height());
    _piWindow->SetWindowPosition(r.left, r.top, r.Width(), r.Height());
}

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment


Powered by WordPress