//////////////////////////////////////////////////////////////////////////
// Windows Event Handler
//////////////////////////////////////////////////////////////////////////
LRESULT CSkinScrollWnd::OnHScroll ( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
	if ( FALSE == ::IsWindow ( ( HWND ) lParam ) )
	{
		return S_OK;
	}

	CScrollBar ScrollBarWnd;

	ScrollBarWnd.Attach ( ( HWND ) lParam );

	CWindow Wnd = m_MidWnd.GetWindow ( GW_CHILD );

	INT32 nSBCode = LOWORD ( wParam );

	INT32 nPos = HIWORD ( wParam );

	m_bOperation = TRUE;
	Wnd.SendMessage ( WM_HSCROLL, MAKELONG ( nSBCode, nPos ), 0 );
	m_bOperation = FALSE;

	SCROLLINFO SInfo = { 0x00 };
	SInfo.cbSize = sizeof ( SInfo );
	SInfo.fMask = SIF_ALL;
	::GetScrollInfo ( Wnd.m_hWnd, SB_HORZ, &SInfo );
	ScrollBarWnd.SetScrollInfo ( &SInfo );

	return S_OK;
}
LRESULT CSkinScrollWnd::OnVThumbTrack( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
	if ( FALSE == ::IsWindow ( ( HWND ) lParam ) )
	{
		return 0;
	}
	CScrollBar ScrollBarWnd;
	ScrollBarWnd.Attach ( ( HWND ) lParam );
	CWindow Wnd = m_MidWnd.GetWindow ( GW_CHILD );
	INT32 nPos =  wParam ;
	m_bOperation = TRUE;
	if ( m_nPos != nPos )
	{
		Wnd.SendMessage ( WM_VSCROLL, MAKELONG ( SB_THUMBTRACK, nPos ), nPos  );
	}
	m_nPos = nPos;
	m_bOperation = FALSE;
	SCROLLINFO SInfo = { 0x00 };
	SInfo.cbSize = sizeof ( SInfo );
	SInfo.fMask = SIF_ALL;
	::GetScrollInfo ( Wnd.m_hWnd, SB_VERT, &SInfo );
	ScrollBarWnd.SetScrollInfo ( &SInfo );

	return 0;
}
void CBCGPMSOffice2007DemoView::OnENRequesteResize(NMHDR *pNMHDR, LRESULT *pResult)
{
	*pResult = 0;

	REQRESIZE *pReqResize = reinterpret_cast<REQRESIZE *>(pNMHDR);
	ASSERT (pReqResize != NULL);

	CScrollBar* pScrollBar = ((CMainFrame*) GetTopLevelFrame ())->GetScrollBar ();
	if (pScrollBar->GetSafeHwnd () == NULL)
	{
		return;
	}

	ASSERT_VALID (pScrollBar);

	CRect rectClient;
	GetClientRect (rectClient);

	const int nViewHeight = rectClient.Height ();
	const int nTotalHeight = (pReqResize->rc.bottom - pReqResize->rc.top);

	if (nTotalHeight <= nViewHeight)
	{
		pScrollBar->EnableScrollBar (ESB_DISABLE_BOTH);
	}
	else
	{
		pScrollBar->EnableScrollBar (ESB_ENABLE_BOTH);

		SCROLLINFO scrollInfo;
		memset (&scrollInfo, 0, sizeof (scrollInfo));

		scrollInfo.cbSize = sizeof (SCROLLINFO);
		scrollInfo.fMask = SIF_RANGE | SIF_PAGE;
		scrollInfo.nMin = 0;
		scrollInfo.nMax = nTotalHeight;
		scrollInfo.nPage = nViewHeight;

		if (!pScrollBar->SetScrollInfo (&scrollInfo))
		{
			pScrollBar->SetScrollRange (0, nTotalHeight, TRUE);
		}
	}
}