Click here to Skip to main content
15,885,216 members
Articles / Desktop Programming / MFC

Wrapper class for playing video with the VMR9

Rate me:
Please Sign up or sign in to vote.
4.67/5 (40 votes)
10 Feb 2003CPOL5 min read 364K   10.5K   116  
Class for playing and mixing video files using DirectX9 Video Mixing Renderer.
// OptionsDialog.cpp : implementation file
//

#include "stdafx.h"
#include "VMR9Demo.h"
#include "OptionsDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COptionsDialog dialog


COptionsDialog::COptionsDialog(CWnd* pParent /*=NULL*/)
	: CDialog(COptionsDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(COptionsDialog)
	m_nLeft = 0;
	m_nRight = 0;
	m_nTop = 0;
	m_nBottom = 0;
	//}}AFX_DATA_INIT
	m_pGraph = NULL;
	m_nLayer = 0;
}


void COptionsDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COptionsDialog)
	DDX_Control(pDX, IDC_SLIDER1, m_sliderCtrl);
	DDX_Text(pDX, IDC_EDIT1, m_nLeft);
	DDX_Text(pDX, IDC_EDIT2, m_nRight);
	DDX_Text(pDX, IDC_EDIT3, m_nTop);
	DDX_Text(pDX, IDC_EDIT4, m_nBottom);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COptionsDialog, CDialog)
	//{{AFX_MSG_MAP(COptionsDialog)
	ON_BN_CLICKED(IDC_OPTION_APPLY, OnOptionApply)
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER1, OnReleasedcaptureSlider1)
	ON_WM_HSCROLL()
	ON_WM_CLOSE()
	ON_WM_SHOWWINDOW()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COptionsDialog message handlers


// Function name	: COptionsDialog::SetGraph
// Description	    : 
// Return type		: void 
// Argument         : CVMR9Graph* pGraph
void COptionsDialog::SetGraph(CVMR9Graph* pGraph)
{
	m_pGraph = pGraph;
}


// Function name	: COptionsDialog::SetLayerNumber
// Description	    : 
// Return type		: void 
// Argument         : int nLayer
void COptionsDialog::SetLayerNumber(int nLayer)
{
	m_nLayer = nLayer;
}


// Function name	: COptionsDialog::OnOptionApply
// Description	    : 
// Return type		: void 
void COptionsDialog::OnOptionApply() 
{
	UpdateData(TRUE);
	CRect newRect(m_nLeft, m_nTop, m_nRight, m_nBottom);

	m_pGraph->SetLayerRect(m_nLayer, newRect);
}


// Function name	: COptionsDialog::OnInitDialog
// Description	    : 
// Return type		: BOOL 
BOOL COptionsDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


// Function name	: COptionsDialog::OnReleasedcaptureSlider1
// Description	    : 
// Return type		: void 
// Argument         : NMHDR* pNMHDR
// Argument         : LRESULT* pResult
void COptionsDialog::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	*pResult = 0;
}


// Function name	: COptionsDialog::OnHScroll
// Description	    : 
// Return type		: void 
// Argument         : UINT nSBCode
// Argument         : UINT nPos
// Argument         : CScrollBar* pScrollBar
void COptionsDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	int nAlpha = m_sliderCtrl.GetPos();

	m_pGraph->SetAlphaLayer(m_nLayer, nAlpha);
	
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

void COptionsDialog::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	ShowWindow(SW_HIDE);
	
	//CDialog::OnClose();
}

void COptionsDialog::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	if (bShow) {
		CString szTitle;
		szTitle.Format("Layer %d options", m_nLayer+1);
		SetWindowText(szTitle);

		if (m_pGraph->GetVideoRect(&m_videoRect)) {
			m_nLeft			= m_videoRect.left;
			m_nRight		= m_videoRect.right;
			m_nTop			= m_videoRect.top;
			m_nBottom		= m_videoRect.bottom;
			UpdateData(FALSE);
			m_sliderCtrl.SetRange(0, 100);
			m_sliderCtrl.SetPos(m_pGraph->GetAlphaLayer(m_nLayer));
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) G. LABOURE
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions