mfc实现播放器功能,双击全屏,再双击还原
视频播放器的制作,视频流在静态控件上显示,类似迅雷看看双击全屏操作的实现在主窗口的 .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);
}
补充:软件开发 , C++ ,