Ejemplo n.º 1
0
	virtual HRESULT SetVideoPosition(RECT *pSrc, RECT *pDst, BOOL hideMouse)
	{
		if (!m_pGraph) return E_FAIL;
		if (m_pVmrAllocator && pSrc && pDst)
		{
			// Update our VMR9 window positioning for mouse events to work (this may only
			// work on XP, I think it will still fail on 2K)
			m_pVmrAllocator->UpdateVideoPosition(pSrc, pDst);
			return S_OK;
		}

		IBasicVideo* pBV = NULL;
		HRESULT hr = m_pGraph->QueryInterface(IID_IBasicVideo, (void**)&pBV);
		if (SUCCEEDED(hr))
		{
	/*		long nativeWidth;
			hr = pBV->get_VideoWidth(&nativeWidth);
			if (FAILED(hr))
			{
				SAFE_RELEASE(pBV);
				// no video is present
				return;
			}
	*/
			long srcTop, srcLeft, srcWidth, srcHeight;
			pBV->GetSourcePosition(&srcLeft, &srcTop, &srcWidth, &srcHeight);
			pBV->GetDestinationPosition(&srcLeft, &srcTop, &srcWidth, &srcHeight);
			if (pSrc)
			{
				pBV->SetSourcePosition(pSrc->left, pSrc->top, pSrc->right - pSrc->left, pSrc->bottom - pSrc->top);
			}
			else
			{
				pBV->SetDefaultSourcePosition();
			}
			if (pDst)
			{
				pBV->SetDestinationPosition(pDst->left, pDst->top, pDst->right - pDst->left, pDst->bottom - pDst->top);
			}
			else
			{
				pBV->SetDefaultDestinationPosition();
			}
			SAFE_RELEASE(pBV);

			IVideoWindow* pVW = NULL;
			hr = m_pGraph->QueryInterface(IID_IVideoWindow, (void**)&pVW);
			if (SUCCEEDED(hr))
			{
				OAHWND vidWinHWND;
				hr = pVW->get_Owner(&vidWinHWND);
				if (SUCCEEDED(hr))
				{
					RECT grc;
					GetClientRect((HWND)vidWinHWND, &grc);
					pVW->SetWindowPosition(0, 0, grc.right, grc.bottom);
				}
				pVW->HideCursor(hideMouse == JNI_TRUE ? OATRUE : OAFALSE);
				SAFE_RELEASE(pVW);
			}
		}
		return S_OK;
	}