//create an activeobject
/创建播放控件
CWnd *PlayerWnd; PlayerWnd = CWnd::FromHandle(this-> m_hWnd);
m_pCActiveMovie3 =new CActiveMovie30; ASSERT_VALID (m_pCActiveMovie3);
CRect rect; PlayerWnd->GetWindowRect(rect); PlayerWnd->ScreenToClient(rect); m_pCActiveMovie3-> Create(_T ( "视频播放"), WS_OVERLAPPED|WS_VISIBLE,rect, PlayerWnd, IDC_ACTIVEMOVIECONTROL1);// m_pCActiveMovie3->put_ShowControls(false); m_pCActiveMovie3->put_FileName("C://Documents and Settings//new//My Documents//My Pictures//mov.avi"); m_pCActiveMovie3->Run(); / CRect movieR,dlgR,clientR; m_pCActiveMovie3->GetWindowRect(movieR); //保证对话框客户区宽不小于300,高度>=55 if(movieR.Width()<300||movieR.Height()<255){ movieR.right = movieR.left+300; movieR.bottom = movieR.top+255; } //得到窗口大小和客户区大小 this->GetWindowRect(dlgR); this->GetClientRect(clientR);
//让对话框适应视频大小 this->MoveWindow(dlgR.left,dlgR.top,dlgR.Width()-clientR.Width()+movieR.Width(),dlgR.Height()-clientR.Height()+movieR.Height());
//居中到对话框 m_pCActiveMovie3->GetWindowRect(movieR); this->GetClientRect(clientR); m_pCActiveMovie3->MoveWindow((clientR.Width()-movieR.Width())/2,(clientR.Height()-movieR.Height())/2,movieR.Width(),movieR.Height());