
/*	Copyright (C) G. Jespersen
	See Licence.txt.*/

// ControlsBar.cpp : implementation file
//

#include "stdafx.h"
#include "DsLavSplit.h"
//#include "DsLav.h"
#include "DsLavDoc.h"
#include "ControlsBar.h"
#include "DsLavSplitterView.h" // for PreTranslateMessage 8/22-5

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

#define HIDE_LEFT _T("Hide Left")
#define SHOW_LEFT _T("Show Left")

/////////////////////////////////////////////////////////////////////////////
// CControlsBar dialog


CControlsBar::CControlsBar()
{
	//{{AFX_DATA_INIT(CControlsBar)
	//}}AFX_DATA_INIT

	// Slider
	m_draggingThumb = 0;
	m_lastVol = 0;
	m_lastTime = 0;

	// Mouse Wheel 7/22
	// EnterKey 8/22
	m_bMouseWheel = FALSE;
	m_bEnterKey = FALSE;
}

CControlsBar::~CControlsBar()
{
	// Set CDsLavApp handle
	((CDsLavApp*)AfxGetApp())->m_hwndControlBar = NULL;
}

// Override to save Bar Size.
BOOL CControlsBar::Create(CWnd* pParentWnd, UINT nIDTemplate,
						  UINT nStyle, UINT nID)
{
	if(!CDialogBar::Create(pParentWnd,nIDTemplate,nStyle,nID))
		return FALSE;

	m_sizeFloating = m_sizeDocked = m_sizeDefault;

	// Set CDsLavApp handle
	((CDsLavApp*)AfxGetApp())->m_hwndControlBar = GetSafeHwnd();

	return TRUE;
}

void CControlsBar::DoDataExchange(CDataExchange* pDX)
{
	CDialogBar::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CControlsBar)
	DDX_Control(pDX, IDC_BUTTON_LEFT_PANE, m_ctrlLeftPane);
	DDX_Control(pDX, IDC_STATIC_VOL, m_ctrlStaticVol);
	DDX_Control(pDX, IDC_STATIC_TIME, m_ctrlStaticTime);
	DDX_Control(pDX, IDC_SLIDER_VOL, m_ctrlVol);
	DDX_Control(pDX, IDC_SLIDER_VID, m_ctrlVid);
	DDX_Control(pDX, IDC_BUTTON_STOP, m_ctrlStop);
	DDX_Control(pDX, IDC_BUTTON_PLAY_PAUSE, m_ctrlPause);
	DDX_Control(pDX, IDC_BUTTON_MUTE, m_ctrlMute);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CControlsBar, CDialogBar)
	//{{AFX_MSG_MAP(CControlsBar)
	ON_BN_CLICKED(IDC_BUTTON_MUTE, OnMute)
	ON_BN_CLICKED(IDC_BUTTON_PLAY_PAUSE, OnPlayPause)
	ON_BN_CLICKED(IDC_BUTTON_STOP, OnStop)
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_VID, OnReleasedcaptureSliderVid)
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_VOL, OnReleasedcaptureSliderVol)
	ON_WM_HSCROLL()
	ON_BN_CLICKED(IDC_BUTTON_LEFT_PANE, OnHideLeftPane)
	//}}AFX_MSG_MAP

	// Dlg bar special
	ON_MESSAGE(WM_INITDIALOG, OnInitDialog)

	// Video playback messsages from View.
	ON_MESSAGE(WM_USER_BAR_START, OnVidStart)
	ON_MESSAGE(WM_USER_BAR_STOP, OnVidStopped)
	ON_MESSAGE(WM_USER_BAR_PAUSE, OnVidPause)
	ON_MESSAGE(WM_USER_BAR_TIME, OnVidTimeChange)
	ON_MESSAGE(WM_USER_BAR_VOL, OnVidVolChange)
	ON_MESSAGE(WM_USER_BAR_MUTE, OnVidMute)

	// Update handlers for mfc hook up - do nothing.
	ON_UPDATE_COMMAND_UI(IDC_BUTTON_PLAY_PAUSE, OnUpdatePlayPause)
	ON_UPDATE_COMMAND_UI(IDC_BUTTON_STOP, OnUpdateStop)
	ON_UPDATE_COMMAND_UI(IDC_BUTTON_MUTE, OnUpdateMute)
	ON_UPDATE_COMMAND_UI(IDC_SLIDER_VID, OnUpdateProgress)
	ON_UPDATE_COMMAND_UI(IDC_SLIDER_VOL, OnUpdateVolume)
	// test
	ON_UPDATE_COMMAND_UI(IDC_BUTTON_LEFT_PANE, OnUpdateHideLeft)

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CControlsBar message handlers

// Initial display.
LONG CControlsBar::OnInitDialog (UINT wParam, LONG lParam)
{
	TRACE(_T("In CControlsBar::OnInitDialog\n"));

	// Dlg editor settings:
	// Default set for HideLeft button  - enables using 
	//  enter key when first tabbing into bar. 
	// Notify Parent set for DialogBar - allows
	//  tabbing into sliders (NoParent Notify = FALSE).

	// HandleInitDialog() always returns false.
	TRACE(_T("In CControlsBar::OnInitDialog \n"));
	HandleInitDialog(wParam, lParam);
	UpdateData(FALSE);

	// Set texts for no vid playing.
	m_ctrlStaticTime.SetWindowText(_T("Progress"));
	m_ctrlStaticVol.SetWindowText(_T("Volume"));
	m_ctrlPause.SetWindowText(_T("Pause"));
	m_ctrlStop.SetWindowText(_T("Stop"));
	m_ctrlMute.SetWindowText(_T("Mute"));

	// Set Left Pane button.
	m_ctrlLeftPane.SetWindowText(HIDE_LEFT);

	// Get ctrl rects.
	m_ctrlVol.GetWindowRect(&m_r1);
	ScreenToClient(&m_r1);
	m_ctrlStaticVol.GetWindowRect(&m_r2);
	ScreenToClient(&m_r2);
	m_ctrlVid.GetWindowRect(&m_r3);
	ScreenToClient(&m_r3);
	m_ctrlStaticTime.GetWindowRect(&m_r4);
	ScreenToClient(&m_r4);
	m_ctrlMute.GetWindowRect(&m_r5);
	ScreenToClient(&m_r5);
	m_ctrlPause.GetWindowRect(&m_r6);
	ScreenToClient(&m_r6);
	m_ctrlStop.GetWindowRect(&m_r7);
	ScreenToClient(&m_r7);
	m_ctrlLeftPane.GetWindowRect(&m_r8);
	ScreenToClient(&m_r8);

	// Disable controls.
	m_ctrlVol.EnableWindow(FALSE);
	m_ctrlVid.EnableWindow(FALSE);
	m_ctrlMute.EnableWindow(FALSE);
	m_ctrlPause.EnableWindow(FALSE);
	m_ctrlStop.EnableWindow(FALSE);
	m_ctrlStaticVol.EnableWindow(FALSE);
	m_ctrlStaticTime.EnableWindow(FALSE);

	// Mouse Wheel 7/22
	// EnterKey 8/22
	m_bMouseWheel = FALSE;
	m_bEnterKey = FALSE;

	// Enable always
	m_ctrlLeftPane.EnableWindow(TRUE);
	UpdateData(FALSE);

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


// Called from CMainFrame::ControlsBarEnable()
// when video playback begins.
LRESULT CControlsBar::OnVidStart(WPARAM wParam, LPARAM lParam)	// WM_USER_BAR_START
{
	TRACE(_T("in CControlsBar :OnVidStart\n"));

	// Enable controls.
	m_ctrlVol.EnableWindow(TRUE);
	m_ctrlVid.EnableWindow(TRUE);
	m_ctrlMute.EnableWindow(TRUE);
	m_ctrlPause.EnableWindow(TRUE);
	m_ctrlStop.EnableWindow(TRUE);
	m_ctrlStaticVol.EnableWindow(TRUE);
	m_ctrlStaticTime.EnableWindow(TRUE);

	// Set video slider percent.
	m_ctrlVid.SetRange(0, 1000, TRUE);
	m_ctrlVid.SetPos(0);

	// Set static vid text.
	CString str, strHour = _T("00:"), strMinute = _T("00:"), strSecond = _T("00");
	str.Format(_T("%s%s%s"), strHour, strMinute, strSecond);
	m_ctrlStaticTime.SetWindowText(str);

	// Set Volume slider percent.
//	m_lastVol = 50;
	m_lastVol = (int)wParam;			// 11/23-1
	m_ctrlVol.SetRange(0, 100, TRUE);
	m_ctrlVol.SetPos(m_lastVol);

	// Set static vol text.
	CString s;
	s.Format(_T("%d %%"), m_lastVol);
	m_ctrlStaticVol.SetWindowText(s);

	// Set pause button text.
	m_ctrlPause.SetWindowText(_T("Pause"));

	// Set muste button text
	m_ctrlMute.SetWindowText(_T("Mute"));

	// Set stop button text.
	m_ctrlStop.SetWindowText(_T("Stop"));

	UpdateData(FALSE);

	return 0;
}

// Called from CMainFrame::ControlsBarDisable() when playback stops.
LRESULT CControlsBar::OnVidStopped(WPARAM wParam, LPARAM lParam)	// WM_USER_BAR_STOP
{
	TRACE(_T("in CControlsBar OnVidStopped\n"));

	// Zero video ctrl.
	m_ctrlVid.SetPos(0);
	m_ctrlStaticTime.SetWindowText(_T("Progress"));
	m_lastTime = 0;

	// Zero volume ctrl.
	m_ctrlVol.SetPos(0);
	m_ctrlStaticVol.SetWindowText(_T("Volume"));
	m_lastVol = 0;

	// Disable controls.
	m_ctrlVol.EnableWindow(FALSE);
	m_ctrlVid.EnableWindow(FALSE);
	m_ctrlMute.EnableWindow(FALSE);
	m_ctrlPause.EnableWindow(FALSE);
	m_ctrlStop.EnableWindow(FALSE);
	m_ctrlStaticVol.EnableWindow(FALSE);
	m_ctrlStaticTime.EnableWindow(FALSE);

	// 8/22-7
	// When the Stop button is used to stop playback
	// via OnStop(), the stop btn keeps the focus 
	// shadow as if it were the default btn. This
	// cleans it up.
	//  See: https://forums.codeguru.com/showthread.php?197179-Switching-Default-Buttons-MFC
	//
	// Clear Stop btn default style.
	DWORD style = m_ctrlStop.GetStyle();
    style &= ~BS_DEFPUSHBUTTON;
    // Update Stop btn style.
    ::SendMessage( m_ctrlStop.GetSafeHwnd(), BM_SETSTYLE, (WPARAM)style, (LPARAM)TRUE);

	// Set LeftPane btn to default style.
	style = m_ctrlLeftPane.GetStyle();
	style |= BS_DEFPUSHBUTTON;
    // Update LeftPane btn style.
	::SendMessage( m_ctrlLeftPane.GetSafeHwnd(), BM_SETSTYLE, (WPARAM)style, (LPARAM)TRUE);

	// Redraw.
	Invalidate();
	UpdateWindow();

	return 0;
}

// Set Pause button text.
// Called from CMainFrame::ControlsBarDisable() when player is paused / depaused.
LRESULT CControlsBar::OnVidPause(WPARAM wParam, LPARAM lParam)	// WM_USER_BAR_PAUSE
{
	// Vid now Paused.
	if(lParam)
	{
		m_ctrlPause.SetWindowText(_T("Play"));
	}
	// Vid now Playing.
	else
	{
		m_ctrlPause.SetWindowText(_T("Pause"));
	}
	return 0;
}

// 8/22 update.
// Update the slider position and the static text box.
// Called from:
//	CMainFrame::OnTimer
//  CMainFrame::OnPlaybackTime
//  CMainFrame::OnPlaybackTimeKeyboard
// every .1 seconds or so.
//  wParam = seconds, lParam = pos.
LRESULT CControlsBar::OnVidTimeChange(WPARAM wParam, LPARAM lParam)	// WM_USER_BAR_TIME
{
	//TRACE("In CControlsBar OnVidTimeChange\n");

	// Set slider pos - 1000 divs.
	// Note there are not 1000 pix in ctrl width.
	// Steps are one or two pix per rounding.
	// 
	// Set pos per param if not dragging the slider ctrl.
	if(!m_draggingThumb)
	{
		int pos = (int)lParam;
		//TRACE(_T("In CControlsBar OnVidTimeChange - pos = %d\n"), pos);
		if(pos < 0)
			pos = 0;
		if(pos > 1000)
			pos = 1000;
		m_ctrlVid.SetPos(pos);
	}

	// Save last pos - see OnHScroll().
	m_lastTime = (int)lParam;

	/*dbg test
	CString str;
	str.Format(_T("%d"), (int)lParam);
	m_ctrlStaticTime.SetWindowText(str); //ok - 1000
	return 0;*/

	// Set strings to nearest second;
	SetVideoTimeString((int)wParam);
	return 0;
}

// Set m_ctrlStaticTime str per seconds param.
// Called from OnVidTimeChange() and OnHScroll().
void CControlsBar::SetVideoTimeString(int sec)
{
	// Set static text.
	CString strHour = _T("00:"), strMinute = _T("00:"), strSecond = _T("00");
	int hours = 0, minutes = 0, seconds = 0;

	// Hours.
	if(sec >= (60 * 60) )
	{
		hours = sec / (60 * 60);
		sec -= hours * 60 * 60;
		if(hours < 10)
			strHour.Format(_T("0%d:"), hours);
		else
			strHour.Format(_T("%d:"), hours);
	}
	// Minutes
	if(sec >= 60)
	{
		minutes = sec / 60;
		sec -= minutes * 60;
		if(minutes < 10)
			strMinute.Format(_T("0%d:"), minutes);
		else
			strMinute.Format(_T("%d:"), minutes);
	}
	// Seconds
	if(sec > 0)
	{
		seconds = sec;
		if(seconds < 10)
			strSecond.Format(_T("0%d"), seconds);
		else
			strSecond.Format(_T("%d"), seconds);
	}
	CString str;
	str.Format(_T("%s%s%s"), strHour, strMinute, strSecond);
	m_ctrlStaticTime.SetWindowText(str);
}

// Called from CMainFrame::StepVolume().
LRESULT CControlsBar::OnVidVolChange(WPARAM wParam, LPARAM lParam)	// WM_USER_BAR_VOL
{
	// Bail if dragging the thumb.
	if(m_draggingThumb)
		return 0;

	m_lastVol = (int)lParam;

	// Set slider.
	m_ctrlVol.SetPos(m_lastVol);

	// Set text
	CString str;
	str.Format(_T("%d %%"), m_lastVol);
	m_ctrlStaticVol.SetWindowText(str);

	return 0;
}

// Set Mute button text.
// Called from CMainFrame::ToggleVolumeMute().
LRESULT CControlsBar::OnVidMute(WPARAM wParam, LPARAM lParam)	// WM_USER_BAR_MUTE
{
	// Now muted - set text to "Unmute"
	if(lParam)
		m_ctrlMute.SetWindowText(_T("Unmute"));
	else
		m_ctrlMute.SetWindowText(_T("Mute"));
	return 0;
}

// 7/22 rework for keyboard input
// User is manipulating a slider.
void CControlsBar::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if(pScrollBar->IsKindOf(RUNTIME_CLASS(CSliderCtrl)) )
    {
		TRACE(_T("In CControlsBar::OnHScroll nSBCode = %d\n"), nSBCode);

		// Video Time Slider.
		if(pScrollBar->GetSafeHwnd() == m_ctrlVid.GetSafeHwnd() )
		{
			// Must have player.
			CPlayer * pPlayer = GetPlayer();
			if(!pPlayer)
			{
				m_ctrlVid.SetPos(m_lastTime);
				return;
			}
			// 8/22-8
			/* 10/30/22 - Error - no good for dvd.
			// If playing un-seekable radio stream, bail.
			REFERENCE_TIME totalTime = pPlayer->GetTotalTime();
			if(totalTime == 0)
			{
				m_lastTime = 0;
				m_ctrlVid.SetPos(m_lastTime);
				return;
			}*/
			// 10/30/22 fix - not for dvd - GetTotalTime() is no go for DVD, 
			//  ok for CD but test anyways.
			if(!pPlayer->IsRunningDvd() && !pPlayer->IsRunningCd())
			{
				// If playing un-seekable radio stream.
				REFERENCE_TIME totalTime = pPlayer->GetTotalTime();
				if(totalTime == 0)
				{
					TRACE(_T("In CControlsBar::OnHScroll unseekable\n")); // 10/30
					m_lastTime = 0;
					m_ctrlVid.SetPos(m_lastTime);
					return;
				}
			}

			// Set paused flag.
			BOOL bPaused = pPlayer->IsPaused();

			switch(nSBCode)
			{
				// User moving slider with keyboard.
				case TB_LINEUP:		// 0 - arrow up, left, 
				case TB_LINEDOWN:	// 1 - arrow down, right, 
				case TB_PAGEUP:		// 2 - Page Up -			mouse or keyboard
				case TB_PAGEDOWN:	// 3 - PageDown			mouse or keyboard
				case TB_TOP:			// 6 - home key, 
				case TB_BOTTOM:		// 7 - end key
			//	case TB_ENDTRACK:	// 8 - key up for virtual-key code - ignore.
			//								WM_KEYUP - the user released a key that  
			//								sent a relevant virtual key code. 10/30 comment
				{
					// No keyboard input when paused.
					if(bPaused)
					{
						m_ctrlVid.SetPos(m_lastTime);
						break;
					}
					// Not dragging thumb with mouse.
					m_draggingThumb = FALSE;

					// Get slider pos - range is 0 - 1000.
					//  Note nPos always = 0.
					int pos = m_ctrlVid.GetPos();

					// Set a New Time for video play per code.
					//  Note m_lastTime is updated by player 
					//  via OnVidTimeChange(). 
					int newTime = m_lastTime;

					if(nSBCode == TB_LINEUP)
						newTime -= 50;
					else if(nSBCode == TB_LINEDOWN)
						newTime += 50;
					else if(nSBCode == TB_PAGEUP)
						newTime -= 200;
					else if(nSBCode == TB_PAGEDOWN)
						newTime += 200;
					else if(nSBCode == TB_TOP)		// Go to start
						newTime = 5;
					else if(nSBCode == TB_BOTTOM)
						newTime = 997;				// Go to end of track 8/22-3
					// Ensure
					if(newTime < 3)
						newTime = 3;
					else if(newTime > 997)
						newTime = 997;

					/*dbg
					TRACE(_T("CControlsBar::OnHScroll pos = %d\n"), pos);
					TRACE(_T("CControlsBar::OnHScroll nPos = %d\n"), nPos);
					TRACE(_T("CControlsBar::OnHScroll m_lastTime = %d\n"), m_lastTime);
					TRACE(_T("CControlsBar::OnHScroll newTime = %d\n"), newTime);*/					

					// Call CMainFrame::OnPlaybackTimeKeyboard() to
					// update video position immediately.
					//
					// -wParam not used
					// -lParam is the slider pos
					AfxGetMainWnd()->PostMessage(WM_USER_VID_TIME_KEYBOARD, 
												 (WPARAM)0, (LPARAM)newTime);
					break;
				}
				case TB_THUMBTRACK:		// 4 mouse and mousewheel only
				case TB_THUMBPOSITION:	// 5 mouse drag
				{
					// Mouse Wheeling - note flag set in PreTranslateMsg().
					if(m_bMouseWheel)
					{
						TRACE(_T("CControlsBar::OnHScroll mousewheel pos = %d, time = %d\n"),
									nPos, m_lastTime);

						// No mouse wheel input when paused.
						if(bPaused)
						{
							m_ctrlVid.SetPos(m_lastTime);
							break;
						}
						// Flag off.
						m_bMouseWheel = FALSE;

						// Set time per nPos - they differ by 1.
						//  Note - assuming this is the only way to tell
						//  if wheel is rolled foreward or backward.
						//  Also, forward roll is greater time, which
						//  is reversed. OnVidTimeChange() gets called
						//  by MainFrame.
						int newTime = m_lastTime;
						if(newTime > (int)nPos)
							newTime += 50;
						else
							newTime -= 50;

						// Ensure
						if(newTime < 5)
							newTime = 5;
						else if(newTime > 995)
							newTime = 995;

						// Call CMainFrame::OnPlaybackTimeKeyboard() to
						// update video position immediately.
						//
						// -wParam not used
						// -lParam is the slider pos
						AfxGetMainWnd()->PostMessage(WM_USER_VID_TIME_KEYBOARD, 
													 (WPARAM)0, (LPARAM)newTime);//pos);
						// Done mouse wheeling.
						break;
					}

					// Dragging thumb with mouse:
					//
					// If first time here, m_draggingThumb will be false,
					// and if paused, bail.
					if(m_draggingThumb == FALSE && bPaused)
					{
						m_ctrlVid.SetPos(m_lastTime);
						break;
					}
					//  Else set flag - OnReleasedcaptureSliderVid() resets when mouse is released.
					m_draggingThumb = TRUE;

					// Get slider pos - range is 0 - 1000.
					int pos = m_ctrlVid.GetPos();

					// Hangs if at zero? - no, fixed in CPlayer::PlaybackTimeSliderMoved
					if(pos <= 1)
					{
						pos = 1;
						m_ctrlVid.SetPos(pos);
					}
					m_lastTime = pos;

					// Call CMainFrame::OnPlaybackTime().
					//  This will pause the graph and adjust the pos
					//  and OnReleasedcaptureSliderVid() restarts.
					//
					// -wParam indicates we are moving the slider
					// -lParam is the slider pos
					AfxGetMainWnd()->PostMessage(WM_USER_VID_TIME, (WPARAM)1, (LPARAM)pos);
					break;
				}
				default:
					break;
			}
		}

		// Volume Slider.
		else if(pScrollBar->GetSafeHwnd() == m_ctrlVol.GetSafeHwnd() )
		{
			// If muted by user, no vol change allowed.
			CPlayer * pPlayer = GetPlayer();
			if(!pPlayer || pPlayer->IsMuted())
			{
				m_ctrlVol.SetPos(m_lastVol);
				return;
			}
			// Adjust vol.
			switch(nSBCode)
			{
				case TB_TOP:			// keyboard
				case TB_BOTTOM:
				case TB_LINEDOWN:
				case TB_LINEUP:
				case TB_ENDTRACK:		// mouse or keyboard
				case TB_PAGEDOWN:
				case TB_PAGEUP:
				{
					// Get slider pos. Note range is 0 - 100.
					m_lastVol = m_ctrlVol.GetPos();

					// Set text
					CString str;
					str.Format(_T("%d %%"), m_lastVol);
					m_ctrlStaticVol.SetWindowText(str);

					// Message MainFrame::OnPlaybackVol().
					//  Note not setting focus to View.
					AfxGetMainWnd()->PostMessage(WM_USER_VID_VOL, 0, m_lastVol);
					break;
				}
				case TB_THUMBTRACK:		// mouse
				case TB_THUMBPOSITION:
				{
					// If mousewheeling - note flag set in PreTranslateMsg().
					if(m_bMouseWheel)
					{
						TRACE(_T("CControlsBar::OnHScroll Volume mousewheel pos = %d, vol = %d\n"),
									nPos, m_lastVol);
						// Flag off.
						m_bMouseWheel = FALSE;

						// Set new vol.
						//  Foreward roll is louder, which is reversed.
						int newVol = m_lastVol;
						if(newVol > (int)nPos)
							newVol += 2;
						else
							newVol -= 2;

						// Ensure 0 - 100 range.
						if(newVol < 0)
							newVol = 1;			// note zero will freeze control?
						else if(newVol > 100)
							newVol = 99; 

						// Get slider pos. Note range is 0 - 100.
					//	m_lastVol = m_ctrlVol.GetPos();

						// Set control to reversed pos. OnVidVolChange() 
						// is not called.
						m_ctrlVol.SetPos(newVol);
						// Set member.
						m_lastVol = newVol;

						// Message MainFrame::OnPlaybackVol().
						//  Note not setting focus to View.
						AfxGetMainWnd()->PostMessage(WM_USER_VID_VOL, 0, newVol);
					}
					// Else dragging slider with mouse.
					else
					{
						// Get slider pos. Note range is 0 - 100.
						m_lastVol = m_ctrlVol.GetPos();

						// Message MainFrame::OnPlaybackVol().
						//  Set focus to View.
						AfxGetMainWnd()->PostMessage(WM_USER_VID_VOL, 1, m_lastVol);
					}
					// Set text
					CString str;
					str.Format(_T("%d %%"), m_lastVol);
					m_ctrlStaticVol.SetWindowText(str);

					break;
				}
				default:
					break;
			}
		}
    }
	CDialogBar::OnHScroll(nSBCode, nPos, pScrollBar);
}
/*orig
// User is manipulating a slider.
void CControlsBar::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if(pScrollBar->IsKindOf(RUNTIME_CLASS(CSliderCtrl)) )
    {
		TRACE(_T("In CControlsBar post msg for OnScroll\n"));

		// Video Slider.
		if(pScrollBar->GetSafeHwnd() == m_ctrlVid.GetSafeHwnd() )
		{
			// If paused by user, no time change allowed.
			CString str;
			m_ctrlPause.GetWindowText(str);
			if(str == _T("Play"))
			{
				m_ctrlVid.SetPos(m_lastTime);
				return;
			}

			switch(nSBCode)
			{
				// User clicking on slider.
				case TB_BOTTOM:
				case TB_ENDTRACK:
				case TB_LINEDOWN:
				case TB_LINEUP:
				case TB_PAGEDOWN:
				case TB_PAGEUP:
				case TB_TOP:
				case TB_THUMBTRACK:
				case TB_THUMBPOSITION:
				{
					// Set flag. OnReleasedcaptureSliderVid() resets
					// when mouse is released.
					m_draggingThumb = TRUE;

					// Get slider pos - range is 0 - 1000.
					int pos = m_ctrlVid.GetPos();

					/*
					// Call CMainFrame::OnPlaybackTime().
					// This will pause the graph and adjust the pos.
					//
					// -wParam indicates we are moving the slider
					// -lParam is the slider pos
					HWND hwndView = ((CDsLavApp*)AfxGetApp())->m_hwndView;
					if(hwndView)
						::PostMessage(hwndView, WM_USER_VID_TIME, (WPARAM)1, (LPARAM)pos);
					* /
					// Call CMainFrame::OnPlaybackTime().
					// This will pause the graph and adjust the pos.
					//
					// -wParam indicates we are moving the slider
					// -lParam is the slider pos
					AfxGetMainWnd()->PostMessage(WM_USER_VID_TIME, 
												 (WPARAM)1, (LPARAM)pos);
				}
				default:
					break;
			}
		}
		// Volume Slider.
		else if(pScrollBar->GetSafeHwnd() == m_ctrlVol.GetSafeHwnd() )
		{
			// If muted, no vol change allowed.
			CString str;
			m_ctrlMute.GetWindowText(str);
			if(str == _T("Unmute"))
			{
				m_ctrlVol.SetPos(m_lastVol);
				return;
			}

			// Adjust vol.
			switch(nSBCode)
			{
				case TB_TOP:		// keyboard
				case TB_BOTTOM:
				case TB_LINEDOWN:
				case TB_LINEUP:
				case TB_ENDTRACK:	// mouse or keyboard
				case TB_PAGEDOWN:
				case TB_PAGEUP:
				case TB_THUMBTRACK:	// mouse
				case TB_THUMBPOSITION:
				{
					// Get slider pos. Note range is 0 - 100.
					m_lastVol = m_ctrlVol.GetPos();

					// Set text
					CString str;
					str.Format(_T("%d %%"), m_lastVol);
					m_ctrlStaticVol.SetWindowText(str);

					/* Message View.
					HWND hwndView = ((CDsLavApp*)AfxGetApp())->m_hwndView;
					if(hwndView)
						::PostMessage(hwndView, WM_USER_VID_VOL, 0, m_lastVol);* /

					// Message MainFrm.
					AfxGetMainWnd()->PostMessage(WM_USER_VID_VOL, 0, m_lastVol);

					break;
				}
				default:
					break;
			}
		}
    }
	CDialogBar::OnHScroll(nSBCode, nPos, pScrollBar);
}*/

// 7/22 updated
// User has dragged and released the time slider - see OnHScroll().
// Update the Video position.
void CControlsBar::OnReleasedcaptureSliderVid(NMHDR* pNMHDR, LRESULT* pResult) 
{
	TRACE(_T("In CControlsBar post msg for OnReleasedcaptureSliderVid\n"));

	*pResult = 0;

	/* If paused by user, no time change allowed.
	CString str;
	m_ctrlPause.GetWindowText(str);
	if(str == _T("Play"))
	{
		m_ctrlVid.SetPos(m_lastTime);
		return;
	}*/
	// Player should be paused here.
	CPlayer * pPlayer = GetPlayer();
	if(!pPlayer || !pPlayer->IsPaused())
	{
		TRACE(_T("In CControlsBar OnReleasedcaptureSliderVid player not paused.\n"));
		return;
	}

	m_draggingThumb = FALSE;
	int pos = m_ctrlVid.GetPos();

	// Call CMainFrm::OnPlaybackTime().
	//
	// This call will de-pause the graph, and 
	// set the final position.
	//	wParam indicates we are moving the slider, = 0.
	//	lParam is the slider pos
	AfxGetMainWnd()->PostMessage(WM_USER_VID_TIME, 0, (LPARAM)pos);
}

// Volume Slider - not used - see OnHScroll().
void CControlsBar::OnReleasedcaptureSliderVol(NMHDR* pNMHDR, LRESULT* pResult) 
{
	*pResult = 0;
}

// Mute Button handler.
// Mute unmute video sound.
//  Calls CMainFrame::OnPlaybackMute().
//  8/22 revised for enter key.
void CControlsBar::OnMute() 
{
	TRACE(_T("In CControlsBar post msg for OnMute\n"));

	// Get enter key press.
	BOOL bEnterPressed = m_bEnterKey;
	m_bEnterKey = FALSE;

	// Message CMainFrm. Note CMainFrm calls back to update controls.
	// See OnVidMute().
	AfxGetMainWnd()->PostMessage(WM_USER_VID_MUTE, bEnterPressed, 0);
}

// Pause Button handler.
// Play Pause a video.
//  Calls CMainFrame::OnPlaybackPause().
//  8/22 revised for enter key.
void CControlsBar::OnPlayPause() 
{
	TRACE(_T("In CControlsBar post msg for OnPlayPause\n"));

	// Get enter key press.
	BOOL bEnterPressed = m_bEnterKey;
	m_bEnterKey = FALSE;

	// Message CMainFrm. Note CmainFrm calls back to update controls.
	// See OnVidPause().
	AfxGetMainWnd()->PostMessage(WM_USER_VID_PAUSE, bEnterPressed, 0);
}

// Stop Button handler.
// Stop a playing video.
//  Calls CMainFrame::OnPlaybackStop().
//  8/22 revised for enter key.
void CControlsBar::OnStop() 
{
	TRACE(_T("In CControlsBar post msg for OnStop\n"));

	// Enter key ignored here. Focus goes to View.
	m_bEnterKey = FALSE;

	// Message MainFrm. Note MainFrm calls back to disable controls.
	// See OnVidStopped().
	AfxGetMainWnd()->PostMessage(WM_USER_VID_STOP, 0, 0);
}

// Hide Show the left Pane tabs.
//  Calls CMainFrame::OnHideLeftPane() which 
//   calls CDsLavSplitterView::OnHideLeftPane().
//  8/22 revised for enter key.
void CControlsBar::OnHideLeftPane() 
{
	TRACE(_T("In CControlsBar post msg for OnHideLeftPane\n"));
	CString str;
	m_ctrlLeftPane.GetWindowText(str);

	// Get enter key press.
	BOOL bEnterPressed = m_bEnterKey;
	m_bEnterKey = FALSE;

	// Message CMainFrame::OnHideLeftPane().
	if(str == SHOW_LEFT)
	{
		// Show.
		m_ctrlLeftPane.SetWindowText(HIDE_LEFT);
		AfxGetMainWnd()->PostMessage(WM_USER_HIDE_LEFT_PANE, bEnterPressed, 0);
	}
	else if(str == HIDE_LEFT)
	{
		// Hide.
		m_ctrlLeftPane.SetWindowText(SHOW_LEFT);
		AfxGetMainWnd()->PostMessage(WM_USER_HIDE_LEFT_PANE, bEnterPressed, 1);
	}
	// Note: CSplitterView::OnHideLeftPane sets focus to right pane 
	// list or video view.
}

// Update handlers needed for mfc hook up.
//
// Update Stop.
void CControlsBar::OnUpdateStop(CCmdUI* pCmdUI)
{
	CMainFrame * pMainMfame = (CMainFrame*)AfxGetMainWnd();

	// 8/22-4
	// If playing or paused, enable stoping.
	if(pMainMfame->m_player.IsRunningOrPaused())
	{
		pCmdUI->Enable(TRUE);
	}
	// Not playing.
	else
	{
		pCmdUI->Enable(FALSE);
	}
}
// The Hide Left button becomes disabled for unknown reasons
// after video playback or an error message.
// This fixes.
void CControlsBar::OnUpdateHideLeft(CCmdUI* pCmdUI)
{
	// Always enabled.
	pCmdUI->Enable(TRUE);
}
void CControlsBar::OnUpdatePlayPause(CCmdUI* pCmdUI)
{
//	TRACE(_T("In CControlsBar::OnUpdatePlayPause\n"));
}
void CControlsBar::OnUpdateMute(CCmdUI* pCmdUI)
{}
void CControlsBar::OnUpdateVolume(CCmdUI* pCmdUI)
{}
void CControlsBar::OnUpdateProgress(CCmdUI* pCmdUI)
{}

///////////////////////////////////////////////////////////////////
// Bar sizing
 
CSize CControlsBar::CalcDynamicLayout(int nLength, DWORD dwMode)
{
	CSize newSz = m_sizeDefault;

	// Get the bars docking rect:
	//	- client area if docked.
	//	- bar's bounding rect if floating.
	CRect frmRect;
	CFrameWnd * pFrame = GetDockingFrame();
	pFrame->GetClientRect(&frmRect);

	// Bail if empty
	if(frmRect.IsRectEmpty())
		return newSz;

	// Not used
	if(dwMode & LM_COMMIT)
		int g = 0;	

	// If being dragged to a new location.
	if(dwMode & LM_MRUWIDTH)
	{
		// Dragging a floated bar - stay with existing.
		if(IsFloating())
			return m_sizeFloating;

		// Dragging from a docked pos to a floating or
		// another docked pos - set to default bar.
		else
		{
			CRect r(0, 0, m_sizeDefault.cx, m_sizeDefault.cy);
			CalcLayout(r);
			m_sizeFloating = m_sizeDefault; 
			return m_sizeDefault;
		}
	}

	// If docked.
	else if((dwMode & LM_VERTDOCK) || (dwMode & LM_HORZDOCK))
	{
		// If the bar's left is somewhere right of the client's 
		// left side, offset bar rightward that distance. This
		// makes the bar stick in its dropped position, clipping
		// any controls which are right of the clients right 
		// side.
		WINDOWPLACEMENT wp;
		GetWindowPlacement(&wp);
		if(wp.rcNormalPosition.left > 0 &&
		   frmRect.right > wp.rcNormalPosition.left)
		{
	//		frmRect.right -= wp.rcNormalPosition.left;
		}
		// Recalc.
		if(CalcLayout(frmRect))
			newSz = frmRect.Size();

		m_sizeDocked = newSz;
		return newSz;
	}

	// Else bar has been floated and is being resized.
	else if(nLength)
	{
		// User resizing bar's vert size.
		if(dwMode & LM_LENGTHY)
		{
			// Get calculated rect.
			CRect calcRect = frmRect;
			if(CalcLayout(calcRect))
			{
				// All we do here is ensure the rect is not
				// dragged smaller than the calculated
				// vertical size. Bigger is ok.
				if(nLength > calcRect.bottom)
					m_sizeFloating.cy = nLength;
			}
		}

		// User resizing bar's horz size.
		else
		{
			// Set copy of frame rect to the drag width.
			CRect calcRect = frmRect;
			calcRect.right = nLength;

			// Get calculated rect.
			if(CalcLayout(calcRect))
			{
				// Get newly calculated size.
				newSz = calcRect.Size();

				// User can drag wider than calculated size.
				if(nLength > newSz.cx)
					m_sizeFloating.cx = nLength;
				// But not smaller.
				else
					m_sizeFloating.cx = newSz.cx;

				// If user dragged rect taller than calculated size
				// (in LM_LENGTHY above), retain that height.
				// But if too small, adjust.
				if(newSz.cy > m_sizeFloating.cy)
					m_sizeFloating.cy = newSz.cy;
			}
		}
		// Return revised or not.
		return m_sizeFloating;
	}
	// No nLength.
	else
		return m_sizeFloating;

	// Should not get here.
	return m_sizeDefault;
}

// For now, justify controls right if posssible.
BOOL CControlsBar::CalcLayout(CRect & frmRect)
{
	// Get original ctrl rects - set in OnIntitialDlg().
	CRect r1 = m_r1;
	CRect r2 = m_r2;
	CRect r3 = m_r3;
	CRect r4 = m_r4;
	CRect r5 = m_r5;
	CRect r6 = m_r6;
	CRect r7 = m_r7;
	CRect r8 = m_r8;

	int space = 6;

	// Get width of sliders and texts.
	int widthSliders = r1.Width() + r2.Width()  + r3.Width() + r4.Width() + (space * 4);

	// Get width of buttons.
	int widthButtons = r5.Width() + r6.Width() + r7.Width() + r8.Width() + (space * 5);

	// Get total.
	int widthTotal = widthSliders + widthButtons;

	// Frame width.
	int widthFrame = frmRect.Width();

	// Wrap controls on two rows. Three cases:
	if(widthTotal >= widthFrame)
	{
		int shiftY = m_r1.Height();

		// Case 1:
		// If smaller than the buttons, justify both rows left.
		// Sliders and buttons will be clipped on right.
		if(widthButtons >= widthFrame)
		{
			// Sliders left justified.
			r4.left  = frmRect.left + space;
			r4.right = r4.left  + m_r4.Width();

			r3.left  = r4.right + space;
			r3.right = r3.left  + m_r3.Width();

			r2.left  = r3.right + space;
			r2.right = r2.left  + m_r2.Width();

			r1.left  = r2.right + space;
			r1.right = r1.left  + m_r1.Width();

			// Buttons left justified and down.
			r8.left  = frmRect.left + space;
			r8.right = r8.left  + m_r8.Width();
			r8.OffsetRect(0, shiftY);

			r7.left  = r8.right + space;
			r7.right = r7.left  + m_r7.Width();
			r7.OffsetRect(0, shiftY);

			r6.left  = r7.right + space;
			r6.right = r6.left  + m_r6.Width();
			r6.OffsetRect(0, shiftY);

			r5.left  = r6.right + space;
			r5.right = r5.left  + m_r5.Width();
			r5.OffsetRect(0, shiftY);

			// Set frame.
			frmRect.bottom = r8.bottom + space;
		}

		// Case 2:
		// If smaller than sliders, justify sliders left, buttons right.
		// Sliders will be clipped on right.
		else if(widthSliders >= widthFrame)
		{
			// Sliders left justified.
			r4.left  = frmRect.left + space;
			r4.right = r4.left  + m_r4.Width();

			r3.left  = r4.right + space;
			r3.right = r3.left  + m_r3.Width();

			r2.left  = r3.right + space;
			r2.right = r2.left  + m_r2.Width();

			r1.left  = r2.right + space;
			r1.right = r1.left  + m_r1.Width();

			// Buttons right justified and down.
			r5.right = frmRect.right - space;
			r5.left  = r5.right - m_r5.Width();
			r5.OffsetRect(0, shiftY);

			r6.right = r5.left  - space;
			r6.left  = r6.right - m_r6.Width();
			r6.OffsetRect(0, shiftY);

			r7.right = r6.left  - space;
			r7.left  = r7.right - m_r7.Width();
			r7.OffsetRect(0, shiftY);

			r8.right = r7.left  - space;
			r8.left  = r8.right - m_r8.Width();
			r8.OffsetRect(0, shiftY);

			// Set frame.
			frmRect.bottom = r8.bottom + space;
		}

		// Case 3:
		// Else set sliders and buttons fit - justified right.
		else
		{
			// Sliders right justified.
			r1.right = frmRect.right - space;
			r1.left	 = r1.right - m_r1.Width();

			r2.right = r1.left  - space;
			r2.left  = r2.right - m_r2.Width();

			r3.right = r2.left  - space;
			r3.left  = r3.right - m_r3.Width();

			r4.right = r3.left  - space;
			r4.left  = r4.right - m_r4.Width();

			// Buttons right justified and down.
			r5.right = frmRect.right - space;
			r5.left  = r5.right - m_r5.Width();
			r5.OffsetRect(0, shiftY);

			r6.right = r5.left  - space;
			r6.left  = r6.right - m_r6.Width();
			r6.OffsetRect(0, shiftY);

			r7.right = r6.left  - space;
			r7.left  = r7.right - m_r7.Width();
			r7.OffsetRect(0, shiftY);

			r8.right = r7.left  - space;
			r8.left  = r8.right - m_r8.Width();
			r8.OffsetRect(0, shiftY);

			// Set frame.
			frmRect.bottom = r8.bottom + space;
		}
	}

	// No wrap - justify right - single row.
	else
	{
		r1.right = frmRect.right - space;
		r1.left	 = r1.right - m_r1.Width();

		r2.right = r1.left  - space;
		r2.left  = r2.right - m_r2.Width();

		r3.right = r2.left  - space;
		r3.left  = r3.right - m_r3.Width();

		r4.right = r3.left  - space;
		r4.left  = r4.right - m_r4.Width();

		r5.right = r4.left  - space;
		r5.left  = r5.right - m_r5.Width();

		r6.right = r5.left  - space;
		r6.left  = r6.right - m_r6.Width();

		r7.right = r6.left  - space;
		r7.left  = r7.right - m_r7.Width();

		r8.right = r7.left  - space;
		r8.left  = r8.right - m_r8.Width();

		// Set frame.
		frmRect.bottom = r8.bottom + space;
	}

	// Position rects.
	m_ctrlVol.MoveWindow(r1, TRUE);
	m_ctrlStaticVol.MoveWindow(r2, TRUE);
	m_ctrlVid.MoveWindow(r3, TRUE);
	m_ctrlStaticTime.MoveWindow(r4, TRUE);
	m_ctrlMute.MoveWindow(r5, TRUE);
	m_ctrlPause.MoveWindow(r6, TRUE);
	m_ctrlStop.MoveWindow(r7, TRUE);
	m_ctrlLeftPane.MoveWindow(r8, TRUE);

	return TRUE;
}

// 7/22
// Get CPlayer ptr.
CPlayer * CControlsBar::GetPlayer()
{
	TRACE(_T("In CControlsBar::GetPlayer\n"));

	// Ensure CMainFrame.
	CWnd * pWnd = AfxGetMainWnd();
	if(!pWnd->IsKindOf( RUNTIME_CLASS(CMainFrame) ))
		return NULL;

	CMainFrame * pFrame = (CMainFrame*)AfxGetMainWnd();
	if(!pFrame)
		return NULL;

	return &pFrame->m_player;
}

// 7/22
BOOL CControlsBar::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message == WM_KEYDOWN)  
	{
		TRACE(_T("CControlsBar::PreTranslateMessage WM_KEYDOWN\n"));

		// Get CWnds. 8/22
		CWnd * pWnd = GetFocus();
		CWnd * pWndVolCtrl		= GetDlgItem(IDC_SLIDER_VOL);
		CWnd * pWndTimeCtrl		= GetDlgItem(IDC_SLIDER_VID);		
		CWnd * pWndBtnLeftPane	= GetDlgItem(IDC_BUTTON_LEFT_PANE);
		CWnd * pWndBtnStop		= GetDlgItem(IDC_BUTTON_STOP);
		CWnd * pWndBtnPlayPause = GetDlgItem(IDC_BUTTON_PLAY_PAUSE);
		CWnd * pWndBtnMute		= GetDlgItem(IDC_BUTTON_MUTE);

		// Tabbing - tab to TreeView, VideoView or button
		// when leaving Volume Slider.
		//  8/22-5 update for hidden TreeView.
		//  8/22-7 update
		if(pMsg->wParam == VK_TAB)
		{
			// Get hWnds.
			HWND hWndTreeView = ((CDsLavApp*)AfxGetApp())->m_hwndTreeView;
			HWND hWndListView = ((CDsLavApp*)AfxGetApp())->m_hwndListView;
			HWND hWndVideoView = ((CDsLavApp*)AfxGetApp())->m_hwndVideoView;

			// TreeView hidden.
			BOOL bHidden = FALSE;
			CDsLavSplitterView * pSplitterView = ((CDsLavApp*)AfxGetApp())->m_pSplitterView;
			if(pSplitterView && pSplitterView->LeftPaneIsHidden()) 
				bHidden = TRUE;

			// Get player.
			CPlayer * pPlayer = GetPlayer();

			// Shift Key down - tabbing backward. 8/22-5
			if(GetKeyState(VK_SHIFT) < 0)
			{
				// Framework handles.
			}

			// m_ctrlVol
			else if(pWnd == pWndVolCtrl)
			{
				TRACE(_T("CControlsBar::PreTranslateMessage Tabbing from Volume Ctrl\n"));

				// Focus to TreeView if not hidden and not tabbing backwards.
				if(hWndTreeView && !bHidden) // && !bShiftDown)
				{
					::SetFocus(hWndTreeView);
					return TRUE;
				}
				// Else Focus to ListView if showing.
				else if(hWndListView && !hWndVideoView)
				{
					::SetFocus(hWndListView);
					return TRUE;
				}
				// Else focus to first ctrl if TreeView hidden 
				// and VideoView showing.
				else if(bHidden && hWndVideoView && !hWndListView)
				{
					m_ctrlLeftPane.SetFocus();
					return TRUE;
				}
			}
			// Allow in bar with no video playing to access HideLeft btn.
			// If not playing.
			else if(pPlayer && pPlayer->IsStopped())
			{
				// If focus on HideLeft btn and not playing.
				if(pWnd == pWndBtnLeftPane)
				{
					// Focus to TreeView if not hidden and not tabbing backwards.
					if(hWndTreeView && !bHidden) // && !bShiftDown)
					{
						::SetFocus(hWndTreeView);
						return TRUE;
					}
					// Else Focus to ListView if showing.
					else if(hWndListView && !hWndVideoView)
					{
						::SetFocus(hWndListView);
						return TRUE;
					}
				}
			}
		}
		// Enter Key - set flag. 8/22
		else if(pMsg->wParam == VK_RETURN)
		{
			// If enter key used with buttons.
			if(pWnd == pWndBtnLeftPane	||
			   pWnd == pWndBtnStop		||
			   pWnd == pWndBtnPlayPause ||
			   pWnd == pWndBtnMute		)
			{
				TRACE(_T("CControlsBar::PreTranslateMessage key down in button\n"));
				m_bEnterKey = TRUE;

				if(pWnd == pWndBtnLeftPane)
				{
					TRACE(_T(" Pane button\n"));
				}
				else if(pWnd == pWndBtnStop)
					TRACE(_T(" Stop button\n"));
				else if(pWnd == pWndBtnPlayPause)
					TRACE(_T(" Play button\n"));
				else if(pWnd == pWndBtnMute)
					TRACE(_T(" Mute button\n"));
			}
		}
		// Space bar: 8/22-4
		//  Pause / depause playing.  
		else if(pMsg->wParam == VK_SPACE)
		{
			BOOL bRepeat = FALSE;
			if( (HIWORD(pMsg->lParam) & KF_REPEAT) )
				bRepeat = TRUE;

			// If a single press.
			if(!bRepeat)
			{
				TRACE(_T("CControlsBar::PreTranslateMessage key down space bar.\n"));

				// Message to CMainFrame::OnPlaybackPause(). 
				//  Note CMainFrm calls back to update btn text. See OnVidPause().
				// Set WPARAM true to keep focus in ControlsBar.
				AfxGetMainWnd()->PostMessage(WM_USER_VID_PAUSE, TRUE, 0);
			}
			/*else
			{
				TRACE(_T("CControlsBar::PreTranslateMessage key down space bar repeat\n"));
			}*/

			// Message handled here - false forwards to 
			// other buttons like a VK_RETURN press.
			return TRUE;
		}
	}

	// Mouse wheel flag used in OnHScroll() for Time or Vol Slider.
	else if(pMsg->message == WM_MOUSEWHEEL)  
	{
		// Get CWnds.
		CWnd * pWnd = GetFocus();
		CWnd * pWndVolCtrl = GetDlgItem(IDC_SLIDER_VOL);
		CWnd * pWndTimeCtrl = GetDlgItem(IDC_SLIDER_VID);

		// If mouseweeling in either slider:
		if(pWnd == pWndTimeCtrl || pWnd == pWndVolCtrl)
		{
			// Set flag - reset in OnHScroll().  7/22
			m_bMouseWheel = TRUE;
		}
	}
	return CDialogBar::PreTranslateMessage(pMsg);
}



