| |
WinCE中基于Media Player的多媒体开发 |
|
时间: 2005-12-07 来自:天极开发 |
 |
|
使用旧版本的WMP控件
如果你使用的手持设备没有WMP10,那事情还没有完。你仍然还可以使用WMP OCX版本8来为你的Pocket PC编程,虽然提供的功能特性少,好在也可以基本满足需要。我创建了一个简单的工程来展示它如何在MFC环境下工作。下面的代码段证明了它和ATL方式一样简单:
BOOL CWMP8SampleDlg::OnInitDialog() { 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 CenterWindow(GetDesktopWindow()); // center to the hpc screen CRect rect; m_Panel.GetClientRect(&rect); if ( m_PlayerWnd.CreateControl(__uuidof(WMP),L"", WS_VISIBLE|WS_CHILD,rect, &m_Panel,AFX_IDW_PANE_FIRST) ) { LPUNKNOWN lpUnk = m_PlayerWnd.GetControlUnknown(); HRESULT hr = lpUnk->QueryInterface(__uuidof(IWMP),(void**) &m_spWMPPlayer); } else { AfxMessageBox(L"Failed to create WMP control"); ::PostQuitMessage(0); return 0; } if ( m_spWMPPlayer ) { m_WMPEvents.m_pMainDlg = (CWMP8SampleDlg*)this; CComPtr<IConnectionPointContainer> spConnectionContainer; HRESULT hr = m_spWMPPlayer-> QueryInterface( IID_IConnectionPointContainer, (void**)&spConnectionContainer ); if (SUCCEEDED(hr)) { hr = spConnectionContainer-> FindConnectionPoint( __uuidof(_IWMPEvents), &m_spConnectionPoint ); } if (SUCCEEDED(hr)) { hr = m_spConnectionPoint->Advise((IDispatch*)&m_WMPEvents, &m_dwAdviseCookie ); } else { AfxMessageBox(L"Failed to get WMP control events"); ::PostQuitMessage(0); return 0; } if ( FAILED(SetupWMP()) ) { AfxMessageBox(L"Failed to setup WMP control"); ::PostQuitMessage(0); return 0; } } m_spWMPPlayer->Stop(); return TRUE; // return TRUE unless you set the focus to a // control } |
|
|
|
|
|
|
|
|