void CResizableFormView::GetTotalClientRect(LPRECT lpRect) const { GetClientRect(lpRect); // get dialog template's size // (this is set in CFormView::Create) CSize sizeTotal, sizePage, sizeLine; int nMapMode = 0; GetDeviceScrollSizes(nMapMode, sizeTotal, sizePage, sizeLine); // otherwise, give the correct size if scrollbars active if (nMapMode < 0) // scrollbars disabled return; // enlarge reported client area when needed CRect rect(lpRect); if (rect.Width() < sizeTotal.cx) rect.right = rect.left + sizeTotal.cx; if (rect.Height() < sizeTotal.cy) rect.bottom = rect.top + sizeTotal.cy; rect.OffsetRect(-GetDeviceScrollPosition()); *lpRect = rect; }
void CBeatDetectView::GetViewRect ( RECT *prc ) { INT32 nTemp; SIZE szTotal, szTemp1, szTemp2; GetDeviceScrollSizes( nTemp, szTotal, szTemp1, szTemp2 ); prc->top = 0; prc->left = 0; prc->bottom = szTotal.cy; prc->right = szTotal.cx; }
void CAutoScrollView::AutoScroll(UINT nRefMessage) { MSG msg; // dummmy message structure to process incoming // messages while autoscrolling. CPoint ptScrollPos, // Current scroll position - logical units ptDevScrollPos, // Current scroll position - device units ptCursorPos; // Current mouse cursor position CRect rc; // Client area long dx, dy; // Scrolling increment SIZE sizeTotal, // CScrollView scroll data sizePage, sizeLine; int nMapMode, // Mapping mode nMapFactor, // Accounts for mapping mode xMin, xMax, yMin, yMax; // Scroll range if (!m_bAutoScroll) return; msg.message = 0; // forces at least one loop. SetCapture(); GetDeviceScrollSizes(nMapMode, sizeTotal, sizePage, sizeLine); // We keep track of the scroll range because CScrollView::ScrollToPosition always // try to scroll even if the scroll limit has been reached. This results in screen // flickering when ScrollWindow is called. GetScrollRange(SB_HORZ, &xMin, &xMax); GetScrollRange(SB_VERT, &yMin, &yMax); // Process all messages until the relevant mouse button // has been released. nRefMessage depends on which button // has been used to trigger autoscrolling. // while (msg.message != nRefMessage) BOOL bSawRefMessage = FALSE; while (!bSawRefMessage) { // Process incoming messages until autoscroll button is released // You cannot peek here because it may process an invalidate // due to the scrolling. /* if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } */ ptScrollPos = GetScrollPosition(); ptDevScrollPos = GetDeviceScrollPosition(); GetCursorPos(&ptCursorPos); ScreenToClient(&ptCursorPos); GetClientRect(&rc); dx = 0L; dy = 0L; if ((ptCursorPos.y < 0) && (ptDevScrollPos.y != yMin)) // Cursor is above client area dy = min(-sizeLine.cy, max(-sizePage.cy, (ptCursorPos.y/10) * sizeLine.cy)); else if ((ptCursorPos.y > rc.bottom) && (ptDevScrollPos.y != yMax)) // Cursor is below client area dy = max(sizeLine.cy, min(sizePage.cy, ((ptCursorPos.y - rc.bottom)/10) * sizeLine.cy)); // otherwise we can't scroll anyway if ((ptCursorPos.x < 0) && (ptDevScrollPos.x != xMin)) // Cursor is on the left of the client area dx = min(-sizeLine.cx, max(-sizePage.cx, (ptCursorPos.x/10) * sizeLine.cx)); else if ((ptCursorPos.x > rc.right) && (ptDevScrollPos.x != xMax)) // Cursor is on the right of the client area dx = max(sizeLine.cx, min(sizePage.cx, ((ptCursorPos.x - rc.right)/10) * sizeLine.cx)); // otherwise we can't scroll anyway // if mouse cursor is dragging outside the client area, scrolling occurs if ((dx != 0) || (dy != 0)) { // Flip the Y coordinate if we're not in MM_TEXT nMapFactor = (nMapMode == MM_TEXT) ? 1 : -1; ptScrollPos.y += (int) dy * nMapFactor; ptScrollPos.x += (int) dx; m_bIsScrolling = TRUE; OnAutoScroll(ptCursorPos, TRUE); ScrollToPosition(ptScrollPos); while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); // if (msg.message == nRefMessage) break; if (msg.message == nRefMessage) bSawRefMessage = TRUE; } // if (!bSawRefMessage) OnAutoScroll(ptCursorPos, FALSE); } else { while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); // if (msg.message == nRefMessage) break; if (msg.message == nRefMessage) bSawRefMessage = TRUE; } m_bIsScrolling = FALSE; } } ReleaseCapture(); m_bIsScrolling = FALSE; }
BOOL MFCArrangeView::OnScroll( UINT nScrollCode, UINT unPos, BOOL bDoScroll ) { int nPos = (int) unPos; // fprintf(stderr, "on scroll %d/%d %d %d\n", nScrollCode&0xff, (nScrollCode&0xff00)>>8, nPos, bDoScroll); InvalidateRect(NULL, TRUE); switch ((nScrollCode&0xff00)>>8) { case SB_BOTTOM: { // Scroll to bottom. if (channeler && bDoScroll) { long cPos = GetScrollPos(SB_VERT); int scrollMapMode; CSize totalSize; CSize pageSize; CSize lineSize; GetDeviceScrollSizes(scrollMapMode, totalSize, pageSize, lineSize); // fprintf(stderr, "V Scrolling channels to bottom %d\n", pageSize.cy); if (cPos < totalSize.cy) { channeler->ScrollWindow(0, totalSize.cy-cPos, NULL, NULL); } } break; } case SB_ENDSCROLL: { // End scroll. if (channeler) { // fprintf(stderr, "End of scroll\n"); } break; } case SB_LINEDOWN: { // Scroll one line down. if (channeler && bDoScroll) { long cPos = GetScrollPos(SB_VERT); int scrollMapMode; CSize totalSize; CSize pageSize; CSize lineSize; GetDeviceScrollSizes(scrollMapMode, totalSize, pageSize, lineSize); // fprintf(stderr, "V Scrolling channels linedown %d %d %d\n", lineSize.cy, cPos, totalSize.cy); if (cPos < totalSize.cy-bounds.bottom) { int scrollAmt = (cPos+lineSize.cy > totalSize.cy-bounds.bottom)?cPos - totalSize.cy+bounds.bottom:-lineSize.cy; channeler->ScrollWindow(0, scrollAmt, NULL, NULL); } } break; } case SB_LINEUP: { // Scroll one line up. if (channeler && bDoScroll) { long cPos = GetScrollPos(SB_VERT); long chPos = channeler->GetScrollPos(SB_VERT); int scrollMapMode; CSize totalSize; CSize pageSize; CSize lineSize; GetDeviceScrollSizes(scrollMapMode, totalSize, pageSize, lineSize); if (cPos > 0) { int scrollAmt = (cPos-lineSize.cy < 0)?cPos:lineSize.cy; // fprintf(stderr, "V Scrolling channels lineup %d %d %d scroll amt %d %d\n", lineSize.cy, cPos, totalSize.cy, scrollAmt, chPos); channeler->ScrollWindow(0, scrollAmt, NULL, NULL); } } break; } case SB_PAGEDOWN: { // Scroll one page down. if (channeler && bDoScroll) { long cPos = GetScrollPos(SB_VERT); int scrollMapMode; CSize totalSize; CSize pageSize; CSize lineSize; GetDeviceScrollSizes(scrollMapMode, totalSize, pageSize, lineSize); // fprintf(stderr, "V Scrolling channels pagedown %d\n", pageSize.cy); if (cPos < totalSize.cy-bounds.bottom) { int scrollAmt = (cPos+pageSize.cy > totalSize.cy-bounds.bottom)?cPos - totalSize.cy+bounds.bottom:-pageSize.cy; channeler->ScrollWindow(0, scrollAmt, NULL, NULL); } } break; } case SB_PAGEUP: { // Scroll one page up. if (channeler && bDoScroll) { long cPos = GetScrollPos(SB_VERT); int scrollMapMode; CSize totalSize; CSize pageSize; CSize lineSize; GetDeviceScrollSizes(scrollMapMode, totalSize, pageSize, lineSize); // fprintf(stderr, "V Scrolling channels pageup %d\n", pageSize.cy); if (cPos > 0) { int scrollAmt = (cPos-pageSize.cy < 0)?cPos:pageSize.cy; channeler->ScrollWindow(0, scrollAmt, NULL, NULL); } } break; } case SB_THUMBPOSITION: // Scroll to the absolute position. The current position is provided in nPos. case SB_THUMBTRACK: { // Drag scroll box to specified position. The current position is provided in nPos. if (channeler && bDoScroll) { long cPos = GetScrollPos(SB_VERT); // fprintf(stderr, "V Scrolling channels absolute in parallel %x %d %d\n", nScrollCode, nPos, cPos); channeler->ScrollWindow(0,cPos-nPos,NULL,NULL); } break; } case SB_TOP: { // Scroll to top. if (channeler && bDoScroll) { long cPos = GetScrollPos(SB_VERT); // fprintf(stderr, "V Scrolling to top (by %d)\n", -cPos); if (cPos > 0) { channeler->ScrollWindow(0,-cPos,NULL,NULL); } } break; } } return CScrollView::OnScroll(nScrollCode,unPos,bDoScroll); }