Click to See Complete Forum and Search --> : PreTranslateMessage


fwehlin
May 20th, 1999, 10:38 AM
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.

sally
May 22nd, 1999, 08:20 AM
HOw did you start playing ....

Sally

Sally
May 22nd, 1999, 08:20 AM
HOw did you start playing ....

Sally

fwehlin
May 22nd, 1999, 09:32 AM
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?

sally
May 23rd, 1999, 03:34 AM
Maybe, just maybe, the playing does not release clock cycles to Windows, so no messages are processed....

Sally

Sally
May 23rd, 1999, 03:34 AM
Maybe, just maybe, the playing does not release clock cycles to Windows, so no messages are processed....

Sally

fwehlin
May 23rd, 1999, 08:23 AM
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?