CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 1999
    Location
    Sweden
    Posts
    55

    PreTranslateMessage

    Hi,
    I´m having some trouble getting the preTranslateMessage funktion to work while playing a movie using Dshow.

    this is what I call, but it wont react at all. My guess is because it has rendered the file and doesn´t let any other messages pass throug. But how do I solve this. I want to be able to close the playing window with the esc-button.

    this is my preTranslateMessage function.
    if (pMsg->message == WM_KEYDOWN)
    if (pMsg->wParam == VK_ESCAPE)
    PostMessage(WM_CLOSE);

    please help

    Regards Frederik.


  2. #2
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: PreTranslateMessage

    HOw did you start playing ....

    Sally


  3. #3
    Join Date
    May 1999
    Location
    Sweden
    Posts
    55

    Re: PreTranslateMessage

    I start playing via a button in my maindlg. The command that´s done when pressing this button is:

    void CDshowDlg::Play()
    {
    if( CanPlay() )
    {
    HRESULT hr;
    hr = pigb->QueryInterface(IID_IMediaControl, (void **) &pimc);
    if( SUCCEEDED(hr) )
    {

    #undef REWIND
    #define FROM_START
    #ifdef REWIND

    hr = pigb->QueryInterface(IID_IMediaPosition, (void**) &pimb);
    if (SUCCEEDED(hr))
    {
    // start from last position, but rewind if near the
    // end
    REFTIME tCurrent, tLength;
    hr = pimp->get_Duration(&tLength);
    if (SUCCEEDED(hr))
    {
    hr = pimp->get_CurrentPosition(&tCurrent);
    if (SUCCEEDED(hr))
    {
    // within 1sec of end? (or past end?)
    if ((tLength - tCurrent) < 1)
    pimp->put_CurrentPosition(0);
    }
    }
    pimp->Release();
    }
    #endif
    hr = pimc->Run();
    pimc->Release();

    if( SUCCEEDED(hr) )
    {
    m_State=Playing;
    return;
    }
    }
    // Inform the user that an error occurred
    TCHAR msg;
    AMGetErrorText(hr, &msg,NULL);
    AfxMessageBox(msg);
    }
    }

    Also before this I call a loadfile funcition, which renders the file.

    BOOL CDshowDlg::LoadFile(LPSTR lpszPathName)
    {
    ObjectRelease();

    if ( !CreateFilterGraph() )
    return FALSE;

    MultiByteToWideChar( CP_ACP, 0, lpszPathName,-1, wFile, MAX_PATH );

    HRESULT hr = pigb->RenderFile(wFile, NULL);
    if (FAILED(hr))
    {
    TCHAR msg;
    AMGetErrorText(hr, &msg,NULL);
    AfxMessageBox(msg);
    return FALSE;
    }

    m_State = Stopped;

    return TRUE;

    }

    Any ideas?


  4. #4
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: PreTranslateMessage

    Maybe, just maybe, the playing does not release clock cycles to Windows, so no messages are processed....

    Sally


  5. #5
    Join Date
    May 1999
    Location
    Sweden
    Posts
    55

    Re: PreTranslateMessage

    Yeah, that sounds like the case here. I can always use the alt+F4 to shut it down, but I really wanna use the esc-button to do this. Any Idea how i can do this in another way?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured