This is my personal blog. I also have a professional blog at http://siliconsparrow.com/

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.

Leave a comment

COMMENTS ARE DISABLED DUE TO EXCESSIVE SPAM. I'm sorry about this, I really love to read your comments but the amount of time I spend deleting spam is too much.


Powered by WordPress