|
void CNewAviTestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
IGraphBuilder *m_pGraph;
IMediaControl *m_pControl;
IMediaEventEx *m_pEvent;
IVideoWindow *m_pVideoWindow;
CoInitialize(NULL);
HWND hWnd;
hWnd = GetDlgItem(IDC_STATIC_MPEG)->m_hWnd;
HRESULT hr;
//free(); //Deletes any previous DirectShow instances
hr = CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&m_pGraph);
if (!SUCCEEDED(hr))
{
MessageBox(_T("CoCreateInstance failed"));
}
hr = m_pGraph->QueryInterface(IID_IMediaControl, (void **)&m_pControl);
if (!SUCCEEDED(hr))
{
MessageBox(_T("IID_IMediaControl failed"));
}
hr = m_pGraph->QueryInterface(IID_IMediaEventEx, (void **)&m_pEvent);
if (!SUCCEEDED(hr))
{
MessageBox(_T("IID_IMediaEventEx failed"));
}
hr = m_pEvent->SetNotifyWindow((OAHWND)hWnd, 0, 0);
if (!SUCCEEDED(hr))
{
MessageBox(_T("SetNotifyWindow failed"));
}
hr = m_pGraph->RenderFile(_T("C\\爱我别走.avi"), NULL);
if (!SUCCEEDED(hr))
{
MessageBox(_T("RenderFile failed"));
//m_pMediaPlayerLog->WriteOut("RenderFile failed,RESULT:0x%x",hr);
}
hr = m_pGraph->QueryInterface(IID_IVideoWindow, (LPVOID *) &m_pVideoWindow);
if (!SUCCEEDED(hr))
{
MessageBox(_T("IID_IVideoWindow failed"));
}
SetWindowLong(hWnd,GWL_STYLE,GetWindowStyle(hWnd) ?WS_CLIPCHILDREN);
hr = m_pVideoWindow->put_Owner((OAHWND)hWnd);// 这里报错,失败了
if (!SUCCEEDED(hr))
{
MessageBox(_T("put_Owner failed"));
}
hr = m_pVideoWindow->put_WindowStyle(WS_CHILD ?WS_CLIPCHILDREN ?WS_CLIPSIBLINGS); //然后这里也会报错 ,失败了
if (!SUCCEEDED(hr))
{
MessageBox(_T("put_WindowStyle failed"));
//m_pMediaPlayerLog->WriteOut("put_WindowStyle failed,RESULT:0x%x",hr);
}
hr = m_pVideoWindow->put_MessageDrain((OAHWND)hWnd);//然后这里也会报错 ,失败了
if (!SUCCEEDED(hr))
{
MessageBox(_T("put_MessageDrain failed"));
//m_pMediaPlayerLog->WriteOut("put_MessageDrain failed,RESULT:0x%x",hr);
}
hr = m_pVideoWindow->put_Visible(OATRUE); //最后是这里也会报错 ,失败了
if (!SUCCEEDED(hr))
{
MessageBox(_T("put_Visible failed"));
//m_pMediaPlayerLog->WriteOut("put_Visible failed,RESULT:0x%x",hr);
}
RECT grc;
GetClientRect(&grc);
m_pVideoWindow->SetWindowPosition(289,81,704,585);
m_pVideoWindow->put_Visible(OATRUE);
m_pControl->Run();
}
哪位大侠能告诉我,我的m_pVideoWindow->put_Owner((OAHWND)hWnd),
m_pVideoWindow->put_WindowStyle(WS_CHILD ?WS_CLIPCHILDREN ?WS_CLIPSIBLINGS);
m_pVideoWindow->put_MessageDrain((OAHWND)hWnd);
m_pVideoWindow->put_Visible(OATRUE);
都错在哪里?谢谢!!!
|
|