void CSoundAnimDlg::updateScroll(uint pos, uint min, uint max) { CScrollBar* scroll = (CScrollBar*) GetDlgItem(IDC_SOUND_ANIM_SCROLLBAR); scroll->SetScrollRange(min, max, FALSE); scroll->SetScrollPos(pos, TRUE); }
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; }
////////////////////////////////////////////////////////////////////////// // 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; }
void CBCGPMSOffice2007DemoView::OnInitialUpdate () { CRichEditView::OnInitialUpdate(); SendMessage (EM_SHOWSCROLLBAR, SB_HORZ, FALSE); SendMessage (EM_SHOWSCROLLBAR, SB_VERT, FALSE); GetRichEditCtrl ().SetEventMask (GetRichEditCtrl ().GetEventMask() | (ENM_REQUESTRESIZE | ENM_SCROLL)); CScrollBar* pScrollBar = ((CMainFrame*) GetTopLevelFrame ())->GetScrollBar (); if (pScrollBar->GetSafeHwnd () != NULL && GetRichEditCtrl().GetTextLength () == 0) { ASSERT_VALID (pScrollBar); pScrollBar->EnableScrollBar (ESB_DISABLE_BOTH); } // Set the printing margins (720 twips = 1/2 inch). SetMargins(CRect(720, 720, 720, 720)); CCharFormat cf; GetDefaultFont (cf); SetCharFormat (cf); SyncFont (); }
BOOL CScrollWnd::OnScrollBy(CSize sizeScroll, BOOL bDoScroll) { int xOrig, x; int yOrig, y; // don't scroll if there is no valid scroll range (ie. no scroll bar) CScrollBar* pBar; DWORD dwStyle = GetStyle(); pBar = GetScrollBarCtrl(SB_VERT); if ((pBar != NULL && !pBar->IsWindowEnabled()) || (pBar == NULL && !(dwStyle & WS_VSCROLL))) { // vertical scroll bar not enabled sizeScroll.cy = 0; } pBar = GetScrollBarCtrl(SB_HORZ); if ((pBar != NULL && !pBar->IsWindowEnabled()) || (pBar == NULL && !(dwStyle & WS_HSCROLL))) { // horizontal scroll bar not enabled sizeScroll.cx = 0; } // adjust current x position xOrig = x = GetScrollPos(SB_HORZ); int xMax = GetScrollLimit(SB_HORZ); x += sizeScroll.cx; if (x < 0) x = 0; else if (x > xMax) x = xMax; // adjust current y position yOrig = y = GetScrollPos(SB_VERT); int yMax = GetScrollLimit(SB_VERT); y += sizeScroll.cy; if (y < 0) y = 0; else if (y > yMax) y = yMax; // did anything change? if (x == xOrig && y == yOrig) return FALSE; if (bDoScroll) { // do scroll and update scroll positions ScrollWindow(-(x-xOrig), -(y-yOrig)); //Invalidate(); if (x != xOrig) SetScrollPos(SB_HORZ, x); if (y != yOrig) SetScrollPos(SB_VERT, y); } return TRUE; }
void CBCGPMSOffice2007DemoView::OnENVScroll() { CScrollBar* pScrollBar = ((CMainFrame*) GetTopLevelFrame ())->GetScrollBar (); if (pScrollBar->GetSafeHwnd () != NULL) { ASSERT_VALID (pScrollBar); CPoint ptScroll (0, 0); SendMessage (EM_GETSCROLLPOS, 0, (LPARAM) &ptScroll); pScrollBar->SetScrollPos (ptScroll.y); } }
bool CAutoPanParameters::NoHorzScroll(CWnd* pParentWnd) const { DWORD dwStyle = pParentWnd->GetStyle(); CScrollBar* pSBar = pParentWnd->GetScrollBarCtrl(SB_HORZ); INT MinPos, MaxPos; pParentWnd->GetScrollRange(SB_HORZ, &MinPos, &MaxPos); if (pParentWnd->GetScrollLimit(SB_HORZ) == 0) return true; if (MinPos == MaxPos) return true; if (pSBar != NULL && !pSBar->IsWindowEnabled()) return true; return false; }
BOOL CXTPPropertyPage::DoMouseWheel(UINT fFlags, short zDelta, CPoint point) { UNUSED_ALWAYS(point); UNUSED_ALWAYS(fFlags); // if we have a vertical scroll bar, the wheel scrolls that // if we have _only_ a horizontal scroll bar, the wheel scrolls that // otherwise, don't do any work at all DWORD dwStyle = GetStyle(); CScrollBar* pBar = GetScrollBarCtrl(SB_VERT); BOOL bHasVertBar = ((pBar != NULL) && pBar->IsWindowEnabled()) || (dwStyle & WS_VSCROLL); pBar = GetScrollBarCtrl(SB_HORZ); BOOL bHasHorzBar = ((pBar != NULL) && pBar->IsWindowEnabled()) || (dwStyle & WS_HSCROLL); if (!bHasVertBar && !bHasHorzBar) return FALSE; BOOL bResult = FALSE; UINT uWheelScrollLines = 3; if (bHasVertBar) { bResult = OnScrollBy(CSize(0, (zDelta < 0 ? 1 : -1) * m_lineDev.cy * uWheelScrollLines), TRUE); } else if (bHasHorzBar) { bResult = OnScrollBy(CSize((zDelta < 0 ? 1 : -1) * m_lineDev.cy * uWheelScrollLines, 0), TRUE); } if (bResult) UpdateWindow(); return bResult; }
void CNCaptureView::OnVScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar pScrollBar) { if (SB_THUMBPOSITION == nSBCode || SB_THUMBTRACK == nSBCode) { if (pScrollBar.m_hWnd) { SCROLLINFO si = { sizeof(SCROLLINFO), SIF_POS }; if(pScrollBar.GetScrollInfo(&si)) { si.fMask = SIF_POS; si.nPos = si.nPos; SetScrollInfo(SB_VERT, &si, TRUE); } } } SetMsgHandled(FALSE); }
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); } } }
BOOL CScrollWnd::DoMouseWheel(UINT fFlags, short zDelta, CPoint point) { UNUSED_ALWAYS(point); UNUSED_ALWAYS(fFlags); // if we have a vertical scroll bar, the wheel scrolls that // if we have _only_ a horizontal scroll bar, the wheel scrolls that // otherwise, don't do any work at all DWORD dwStyle = GetStyle(); CScrollBar* pBar = GetScrollBarCtrl(SB_VERT); BOOL bHasVertBar = ((pBar != NULL) && pBar->IsWindowEnabled()) || (dwStyle & WS_VSCROLL); pBar = GetScrollBarCtrl(SB_HORZ); BOOL bHasHorzBar = ((pBar != NULL) && pBar->IsWindowEnabled()) || (dwStyle & WS_HSCROLL); if (!bHasVertBar && !bHasHorzBar) return FALSE; BOOL bResult = FALSE; UINT uWheelScrollLines = 10;//_AfxGetMouseScrollLines(); int nToScroll; int nDisplacement; if (bHasVertBar) { nToScroll = ::MulDiv(-zDelta, uWheelScrollLines, WHEEL_DELTA); if (nToScroll == -1 || uWheelScrollLines == WHEEL_PAGESCROLL) { nDisplacement = m_pageDev.cy; if (zDelta > 0) nDisplacement = -nDisplacement; } else { nDisplacement = nToScroll * m_lineDev.cy; nDisplacement = min(nDisplacement, m_pageDev.cy); } bResult = OnScrollBy(CSize(0, nDisplacement), TRUE); } else if (bHasHorzBar) { nToScroll = ::MulDiv(-zDelta, uWheelScrollLines, WHEEL_DELTA); if (nToScroll == -1 || uWheelScrollLines == WHEEL_PAGESCROLL) { nDisplacement = m_pageDev.cx; if (zDelta > 0) nDisplacement = -nDisplacement; } else { nDisplacement = nToScroll * m_lineDev.cx; nDisplacement = min(nDisplacement, m_pageDev.cx); } bResult = OnScrollBy(CSize(nDisplacement, 0), TRUE); } if (bResult) UpdateWindow(); return bResult; }