視頻播放器的制作,視頻流在靜態控件上顯示,類似迅雷看看雙擊全屏操作的實現
在主窗口的 .h 文件中
[cpp]
BOOL m_isFullScreen;
CRect m_Old;
BOOL PreTranslateMessage(MSG* pMsg);
nbsp;afx_msg void OnDoubleStatic(UINT nFlags,CPoint point); //雙擊靜態控件(顯示視頻)響應函數
.cpp文件中
[cpp]
//定義消息相應
ON_STN_DBLCLK(IDC_STATIC_VIDEOWND,OnDoubleStatic) ON_STN_DBLCLK(IDC_STATIC_VIDEOWND,OnDoubleStatic)
//在主窗口 .cpp 文件中的初始化函數中先獲取原始的位置
m_videoWnd.GetWindowRect(&m_Old);
ScreenToClient(&m_Old);
在主窗口 .cpp 文件中
[cpp]
//
void CTestVoxCVSA_DemoDlg::OnDoubleStatic(UINT nFlags,CPoint point)
{
CTestVoxCVSA_DemoDlg* m_pDemoDlg = (CTestVoxCVSA_DemoDlg*)AfxGetApp()->m_pMainWnd;
if (m_isFullScreen == FALSE)
{
CWnd *saveParent=m_videoWnd.GetParent();
m_videoWnd.SetParent(GetDesktopWindow());
CRect rect;
GetDesktopWindow()-> GetWindowRect(&rect);
m_videoWnd.SetWindowPos(&wndTopMost,rect.left,rect.top,rect.right,rect.bottom,SWP_SHOWWINDOW);
m_pDemoDlg->ShowWindow(SW_HIDE);
m_isFullScreen = TRUE;
}
CDialog::OnLButtonDblClk(nFlags,point);
}
//獲取消息的函數
BOOL CTestVoxCVSA_DemoDlg::PreTranslateMessage(MSG* pMsg)
{
CTestVoxCVSA_DemoDlg* m_pDemoDlg = (CTestVoxCVSA_DemoDlg*)AfxGetApp()->m_pMainWnd;
if ((pMsg->message==WM_LBUTTONDBLCLK)&&(m_isFullScreen == TRUE))
{
m_pDemoDlg->ShowWindow(SW_SHOW);
m_videoWnd.SetParent(m_pDemoDlg);
m_videoWnd.SetWindowPos(&wndTop,m_Old.left,m_Old.top,m_Old.right-m_Old.left,m_Old.bottom-m_Old.top,SWP_SHOWWINDOW);
m_isFullScreen = FALSE;
return TRUE;
}
return CWnd::PreTranslateMessage(pMsg);
}