DirectX 在对话框播放视频

来源:互联网 发布:董云飞老师网络公开课 编辑:程序博客网 时间:2024/04/26 18:49
#include <mmsystem.h>#include <uuids.h> #include <initguid.h>#include <Strmif.h>#include <control.h>#include <ddrawex.h> #pragma comment(lib, "Strmiids.lib")#define OATRUE (-1) #define OAFALSE (0)  BOOL CDlg666Dlg::OnInitDialog(){  WCHAR wFile[] = L"C:\\WinDDK\\7600.16385.1\\src\\general\\toaster\\toastpkg\\toastva\\search.avi";  CDialog::OnInitDialog();  // Set the icon for this dialog.  The framework does this automatically  //  when the application's main window is not a dialog  SetIcon(m_hIcon, TRUE);// Set big icon  SetIcon(m_hIcon, FALSE);// Set small icon    // TODO: Add extra initialization here  CoInitialize(NULL);  IGraphBuilder *pigb  = NULL;  IMediaControl *pimc  = NULL;  IMediaEventEx *pimex = NULL;  IVideoWindow  *pivw  = NULL;  HRESULT hr = CoCreateInstance(CLSID_FilterGraph,    NULL,    CLSCTX_INPROC_SERVER,    IID_IGraphBuilder,    (void **)&pigb);  pigb->QueryInterface(IID_IMediaControl, (void **)&pimc);  pigb->QueryInterface(IID_IMediaEventEx, (void **)&pimex);  pigb->QueryInterface(IID_IVideoWindow, (void **)&pivw);  CRect grc;  GetClientRect(&grc);  pivw->put_Owner((OAHWND)m_hWnd);  pivw->put_WindowStyle(WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN);   pivw->SetWindowPosition(grc.left, grc.top, grc.right, grc.bottom);   pivw->put_Visible(OATRUE);   hr = pigb->RenderFile(wFile, NULL);  //pimex->SetNotifyWindow(m_hWnd, WM_GRAPHNOTIFY, 0);  hr = pimc->Run();  LONG evCode;  pimex->WaitForCompletion(INFINITE,&evCode);   pimc->Release();    pimex->Release();   pivw->Release();   pigb->Release();   CoUninitialize();   return TRUE;  // return TRUE  unless you set the focus to a control}

原创粉丝点击