//------------------------------------------------------------------------- // RepositionMovie // Updates video position in windowless mode //------------------------------------------------------------------------- void CMultiSAP::RepositionMovie() { RECT rcPos; GetMoviePosition(&rcPos); PutMoviePosition(rcPos); }
/******************************Public*Routine******************************\ * RepositionMovie * \**************************************************************************/ void RepositionMovie(HWND hwnd) { if(pMpegMovie) { long xPos, yPos, cx, cy; GetMoviePosition(hwnd, &xPos, &yPos, &cx, &cy); pMpegMovie->PutMoviePosition(xPos, yPos, cx, cy); InvalidateRect(hwnd, NULL, false); UpdateWindow(hwnd); } }
/*****************************Private*Routine******************************\ * RepositionMovie * \**************************************************************************/ void RepositionMovie(HWND hwnd) { if(pMovie) { long xPos, yPos, cx, cy; GetMoviePosition(hwnd, &xPos, &yPos, &cx, &cy); pMovie->PutMoviePosition(xPos, yPos, cx, cy); HDC hdcWin = GetDC(NULL); pMovie->SetAppText(g_szLine21Text); pMovie->RepaintVideo(hwnd, hdcWin); ReleaseDC(hwnd, hdcWin); } }
/*****************************Private*Routine******************************\ * VideoCd_OnPaint * \**************************************************************************/ void VideoCd_OnPaint( HWND hwnd ) { PAINTSTRUCT ps; HDC hdc; RECT rc1; RECT rc2; /* ** Draw a frame around the movie playback area. */ GetClientRect(hwnd, &rc2); hdc = BeginPaint(hwnd, &ps); if(pMpegMovie) { long xPos, yPos, cx, cy; GetMoviePosition(hwnd, &xPos, &yPos, &cx, &cy); SetRect(&rc1, xPos, yPos, xPos + cx, yPos + cy); HRGN rgnClient = CreateRectRgnIndirect(&rc2); HRGN rgnVideo = CreateRectRgnIndirect(&rc1); CombineRgn(rgnClient, rgnClient, rgnVideo, RGN_DIFF); HBRUSH hbr = GetSysColorBrush(COLOR_BTNFACE); FillRgn(hdc, rgnClient, hbr); DeleteObject(hbr); DeleteObject(rgnClient); DeleteObject(rgnVideo); pMpegMovie->RepaintVideo(hwnd, hdc); } else { FillRect(hdc, &rc2, (HBRUSH)(COLOR_BTNFACE + 1)); } EndPaint(hwnd, &ps); }
/*****************************Private*Routine******************************\ * VideoCd_OnMove * \**************************************************************************/ void VideoCd_OnMove( HWND hwnd, int x, int y ) { if(pMpegMovie) { if(pMpegMovie->GetStateMovie() != State_Running) { RepositionMovie(hwnd); } else { long xPos, yPos, cx, cy; // Reposition movie but don't invalidate the rect, since // the next video frame will handle the redraw. GetMoviePosition(hwnd, &xPos, &yPos, &cx, &cy); pMpegMovie->PutMoviePosition(xPos, yPos, cx, cy); } } }
//------------------------------------------------------------------------- // Name: CmdAddMovie // Desc: Processes command "add movie" from the parent dialog // Parameters: (sMovieInfo *)lParam; // Return: // Other: 1. Create CMovie // 2. Add movie to the end of the list // 3. Start playing //------------------------------------------------------------------------- void CMultiSAP::CmdAddMovie(sMovieInfo* pMovInf) { HRESULT hr = S_OK; RECT rc; CMovie *pmovie = NULL; CAutoLock Lock(&m_AppImageLock); CmdAddEffect(eEffectFading,2000, 300, 400, TRUE); // set next videoeffect "fading" if( m_pEffect ) // ping video effect change { m_pEffect->Finish(); } if( !pMovInf) { OutputDebugString(TEXT("Invalid parameter sent to CmdAddMovie()\n")); return; } if( 0 == m_movieList.GetSize() ) { ShowWindow( m_hwndApp, SW_SHOW); } pmovie = new CMovie; if( !pmovie ) { OutputDebugStringA("Failed to allocate new movie in CmdAddMovie()\n"); return; } pmovie->Initialize(pMovInf, this); if( FALSE == m_movieList.Add( pmovie )) { OutputDebugStringA("Failed to add new movie to the list in CmdAddMovie()\n"); pmovie->Release(); delete pmovie; return; } try { if( !m_movieList.GetMovie( pMovInf->pdwUserID) ) throw; hr = m_movieList.GetMovie( pMovInf->pdwUserID)->OpenMovie(); } catch(...) { pmovie->Release(); delete pmovie; OutputDebugString(TEXT("Unhandled exception when trying to open the movie\n")); hr = E_POINTER; } if( FAILED(hr)) { m_movieList.Delete( pMovInf->pdwUserID ); if( m_bErrorMessage ) { MessageBox(NULL, m_achErrorMessage, m_achErrorTitle, MB_ICONEXCLAMATION); m_bErrorMessage = false; } else { #ifdef UNICODE hr = StringCchPrintfW( m_achErrorMessage, NUMELMS(m_achErrorMessage),TEXT("Direct3D object returned error code 0x%08x.\r\n"), hr); #else hr = StringCchPrintf( m_achErrorMessage, NUMELMS(m_achErrorMessage),TEXT("Direct3D object returned error code 0x%08x.\r\n"), hr); #endif hr = StringCchCat( m_achErrorMessage, NUMELMS(m_achErrorMessage), TEXT("Please use DirectX Error Lookup tool and verify DirectX\r\n")\ TEXT("capabilities of your video driver. We are sorry for inconvenience.\r\n")\ TEXT("You may want to try a different media file, or try a different video driver.")); hr = StringCchCopy( m_achErrorTitle, MAX_PATH, TEXT("Error when trying to render media file")); MessageBox(NULL, m_achErrorMessage, m_achErrorTitle, MB_ICONEXCLAMATION); m_bErrorMessage = false; } return; } GetMoviePosition(&rc); PutMoviePosition(rc); if( m_pEffect ) { m_pEffect->Invalidate(); } try { hr = PlayMovie(pMovInf->pdwUserID); } catch(...) { OutputDebugString(TEXT("Failed to start movie\n")); m_movieList.Delete( pMovInf->pdwUserID ); hr = E_FAIL; } if( FAILED(hr)) { m_movieList.Delete( pMovInf->pdwUserID ); } }