void hexEdit::scroll(WPARAM wParam) { WORD code = LOWORD(wParam); int oldLine = line; switch (code) { case SB_TOP: line = 0; break; case SB_BOTTOM: line = lineCount; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: { SCROLLINFO si = { sizeof(si), SIF_TRACKPOS }; GetScrollInfo(scrwnd, SB_CTL, &si); line = si.nTrackPos; } break; case SB_LINEUP: line--; break; case SB_LINEDOWN: line++; break; case SB_PAGEUP: line-=rows; break; case SB_PAGEDOWN: line+=rows; break; } if (line < 0) { line = 0; } else if (line > lineCount) { line = lineCount; } if (line != oldLine) { SetScrollPos(scrwnd, SB_CTL, line, TRUE); occupy(); invalidate(); } }
static LRESULT handle_WM_SIZING(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LPRECT prect; int width; int height; int style; prect = (LPRECT) lParam; /* total window rect */ width = (prect->right - prect->left) - (g_xoff * 2); height = (prect->bottom - prect->top) - (g_yoff + g_xoff); if (height < g_height || width < g_width) { style = GetWindowLongPtr(g_Wnd, GWL_STYLE); if (!(style & WS_HSCROLL)) { style |= WS_HSCROLL | WS_VSCROLL; SetWindowLongPtr(g_Wnd, GWL_STYLE, style); g_xscroll = 0; g_yscroll = 0; SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); } } else if (height >= g_height && width >= g_width) { style = GetWindowLongPtr(g_Wnd, GWL_STYLE); if (style & WS_HSCROLL) { style &= ~WS_HSCROLL; style &= ~WS_VSCROLL; SetWindowLongPtr(g_Wnd, GWL_STYLE, style); g_xscroll = 0; g_yscroll = 0; } } return 0; }
static VOID local doCreate_Classes(HWND hWnd) { PAINTSTRUCT ps; HDC hDC; HFONT hSaveFont; INT numClasses = classMax() - CLASSMIN; /* total number of classes */ cBrowse.hNormalCursor = LoadCursor(NULL, IDC_ARROW); cBrowse.hMoveClassCursor = LoadCursor(hThisInstance, "MOVECLASSCURSOR"); cBrowse.SelectedClass = -1; cBrowse.Moved = FALSE; cBrowse.ClassesTopX = 10; cBrowse.ClassesTopY = 10; cBrowse.XOffset = 0; cBrowse.YOffset = 0; if (!allocNodes(numClasses)) { MessageBox(hWnd, "Out of memory: create nodes list", NULL, MB_ICONEXCLAMATION | MB_OK); return; } hDC = BeginPaint(hWnd, &ps); hSaveFont = SelectObject(hDC, hDialogFont); buildClassGraph( hDC ); /* Restore font */ SelectObject(hDC, hSaveFont); EndPaint(hWnd, &ps); /* Show upper-left part of window */ SetScrollPos(hWnd, SB_HORZ, 0, TRUE); SetScrollPos(hWnd, SB_VERT, 0, TRUE); setClassBrowserSize(); }
void CScreenSpyDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here if (!IsWindowVisible()) return; RECT rect; GetClientRect(&rect); InterlockedExchangeT pInterlockedExchange=(InterlockedExchangeT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"InterlockedExchange"); if ((rect.right + m_HScrollPos) > m_lpbmi->bmiHeader.biWidth) pInterlockedExchange((PLONG)&m_HScrollPos, m_lpbmi->bmiHeader.biWidth - rect.right); if ((rect.bottom + m_VScrollPos) > m_lpbmi->bmiHeader.biHeight) pInterlockedExchange((PLONG)&m_VScrollPos, m_lpbmi->bmiHeader.biHeight - rect.bottom); SetScrollPos(SB_HORZ, m_HScrollPos); SetScrollPos(SB_VERT, m_VScrollPos); if (rect.right >= m_lpbmi->bmiHeader.biWidth && rect.bottom >= m_lpbmi->bmiHeader.biHeight) { ShowScrollBar(SB_BOTH, false); pInterlockedExchange((PLONG)&m_HScrollPos, 0); pInterlockedExchange((PLONG)&m_VScrollPos, 0); RECT rectClient, rectWindow; GetWindowRect(&rectWindow); GetClientRect(&rectClient); ClientToScreen(&rectClient); // 边框的宽度 int nBorderWidth = rectClient.left - rectWindow.left; rectWindow.right = rectClient.left + nBorderWidth + m_lpbmi->bmiHeader.biWidth; rectWindow.bottom = rectClient.top + m_lpbmi->bmiHeader.biHeight + nBorderWidth; MoveWindow(&rectWindow); } else ShowScrollBar(SB_BOTH, true); }
void CWFView::SyncPosition(D3DVECTOR &CameraPos) { CBTEditDoc* pDoc = GetDocument(); SLONG TextureWidth = (SLONG)pDoc->GetTextureWidth(); SLONG TextureHeight = (SLONG)pDoc->GetTextureHeight(); SLONG TileWidth = (SLONG)pDoc->GetTileWidth(); SLONG TileHeight = (SLONG)pDoc->GetTileHeight(); SLONG MapWidthO2 = (SLONG)pDoc->GetMapWidth()/2; SLONG MapHeightO2 = (SLONG)pDoc->GetMapHeight()/2; RECT ClientRect; GetClientRect(&ClientRect); m_ScrollX = ( ( ((SLONG)CameraPos.x)/TileWidth)+MapWidthO2 - ((SLONG)ClientRect.right/2/TextureWidth) )*TextureWidth; m_ScrollY = ( ( (-(SLONG)CameraPos.z)/TileHeight)+MapHeightO2 - ((SLONG)ClientRect.bottom/2/TextureHeight) )*TextureHeight; SCROLLINFO ScrollInfo; GetScrollInfo( SB_HORZ, &ScrollInfo, SIF_ALL ); int MinPos = ScrollInfo.nMin; int MaxPos = ScrollInfo.nMax-ScrollInfo.nPage; if(m_ScrollX < MinPos) m_ScrollX = MinPos; if(m_ScrollX > MaxPos) m_ScrollX = MaxPos; GetScrollInfo( SB_VERT, &ScrollInfo, SIF_ALL ); MinPos = ScrollInfo.nMin; MaxPos = ScrollInfo.nMax-ScrollInfo.nPage; if(m_ScrollY < MinPos) m_ScrollY = MinPos; if(m_ScrollY > MaxPos) m_ScrollY = MaxPos; SetScrollPos( SB_HORZ, m_ScrollX, TRUE ); SetScrollPos( SB_VERT, m_ScrollY, TRUE ); pDoc->RegisterScrollPosition(m_ScrollX-pDoc->GetTextureWidth()*OVERSCAN,m_ScrollY-pDoc->GetTextureHeight()*OVERSCAN); InvalidateRect(NULL,NULL); }
void CScrollWnd::CenterOnPoint(CPoint ptCenter) // center in device coords { CRect rect; GetClientRect(&rect); // find size of client window int xDesired = ptCenter.x - rect.Width() / 2; int yDesired = ptCenter.y - rect.Height() / 2; DWORD dwStyle = GetStyle(); if ((dwStyle & WS_HSCROLL) == 0 || xDesired < 0) { xDesired = 0; } else { int xMax = GetScrollLimit(SB_HORZ); if (xDesired > xMax) xDesired = xMax; } if ((dwStyle & WS_VSCROLL) == 0 || yDesired < 0) { yDesired = 0; } else { int yMax = GetScrollLimit(SB_VERT); if (yDesired > yMax) yDesired = yMax; } ASSERT(xDesired >= 0); ASSERT(yDesired >= 0); SetScrollPos(SB_HORZ, xDesired); SetScrollPos(SB_VERT, yDesired); }
//滚动消息 BOOL CFaceItemSelectWnd::OnMouseWheel(UINT nFlags, short zDelta, CPoint Point) { __super::OnMouseWheel(nFlags,zDelta,Point); //设置变量 INT nLastPos=m_nCurrentPos; m_nCurrentPos=__max(0,__min(m_nCurrentPos-zDelta/WHELL_PELS,m_nMaxPels-m_nPagePels)); //设置滚动 SetScrollPos(SB_VERT,m_nCurrentPos); ScrollWindow(0,nLastPos-m_nCurrentPos,NULL,NULL); return TRUE; }
void OpenMedia(TCHAR *path) { SetWindowText(g_stTime, _T("00:00")); SetScrollPos(g_sbTime, SB_CTL, 0, false); //move time bar position to 0 if (!g_pPlayer->Open(path)) { MessageBox(g_hMain, _T("File does not exist\nor is not supported"), _T("Error"), MB_OK); return; } g_nDuration = g_pPlayer->GetDuration() / 100; //duration in 1/10 sec SetScrollRange(g_sbTime, SB_CTL, 0, g_nDuration, true); //set time bar range OnPlay(); //start playing }
void CColumnTreeWnd::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar * /* pScrollBar */) { CRect rcClient; GetClientRect(&rcClient); int cx = rcClient.Width(); int xLast = m_xPos; switch (nSBCode) { case SB_LINELEFT: m_xPos -= 15; break; case SB_LINERIGHT: m_xPos += 15; break; case SB_PAGELEFT: m_xPos -= cx; break; case SB_PAGERIGHT: m_xPos += cx; break; case SB_LEFT: m_xPos = 0; break; case SB_RIGHT: m_xPos = m_cxTotal - cx; break; case SB_THUMBTRACK: m_xPos = nPos; break; } if (m_xPos < 0) { m_xPos = 0; } else if (m_xPos > m_cxTotal - cx) { m_xPos = m_cxTotal - cx; } if (xLast == m_xPos) { return; } SetScrollPos(SB_HORZ, m_xPos); RepositionControls(); }
void ScrollX::SetScroll( long newScrollPos ) { if ( newScrollPos < 0 ) newScrollPos = 0; if ( newScrollPos > scrollMax ) newScrollPos = scrollMax; if ( getParent() ) getParent()->handleMessage( aMSG_SCROLLTO, newScrollPos ); SetScrollPos( newScrollPos ); }
/***************************************************************************** * ScrollFont() * * purpose: scrolls tiny window at bottom * * params: none * * returns: none * * side effects: alters scroll position variable * ****************************************************************************/ VOID ScrollFont( VOID ) { HDC hDC; swH = max(0, swH); swH = min(100, swH); /* maintain 0 - 100 range */ SetScrollPos(hFont, SB_HORZ, swH, TRUE); /* Move thumb */ hDC = GetDC(hFont); FontShowPaint(hDC); ReleaseDC(hFont, hDC); }
void CPropertyWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { CRect rClient; GetClientRect(rClient); int nDelta = 0; int nOldPos = GetScrollPos(SB_VERT); int nMaxSize = PROPERTY_HEIGHT * MAX_PROPS_PER_GROUP; switch(nSBCode) { case SB_TOP: nDelta = -nMaxSize; break; case SB_BOTTOM: nDelta = nMaxSize; break; case SB_PAGEUP: nDelta = -rClient.Height(); break; case SB_PAGEDOWN: nDelta = rClient.Height(); break; case SB_LINEUP: nDelta = -PROPERTY_HEIGHT; break; case SB_LINEDOWN: nDelta = PROPERTY_HEIGHT; break; case SB_THUMBPOSITION: nDelta = nPos - nOldPos; break; case SB_THUMBTRACK: nDelta = nPos - nOldPos; break; default: break; } //get the bar range int nMinRng, nMaxRng; GetScrollRange(SB_VERT, &nMinRng, &nMaxRng); //now we need to find the final position and clamp it int nNewPos = max(nMinRng, min(nMaxRng - rClient.Height(), nOldPos + nDelta)); //recalculate the delta (now clamped) and pixel based nDelta = nNewPos - nOldPos; //see if we even moved if(nDelta == 0) return; SetScrollPos(SB_VERT, nNewPos); //scroll the window ScrollWindow(0, -nDelta); //draw the invalidated rectangle UpdateWindow(); CWnd::OnVScroll(nSBCode, nPos, pScrollBar); }
long aScrollBar::init(long xPos, long yPos, long w, long h) { long err; err = aObject::init(xPos,yPos,w,h); if (err) return err; topButton.setID( aMSG_SCROLLUP ); bottomButton.setID( aMSG_SCROLLDOWN ); scrollTab.setSinglePress(); topButton.setSinglePress(); bottomButton.setSinglePress(); addChild( &topButton ); addChild( &bottomButton ); addChild( &scrollTab ); topButton.setHoldTime( 0.001f ); scrollTab.setHoldTime( 0.001f ); bottomButton.setHoldTime( 0.001f ); topButton.setPressFX( -1 ); bottomButton.setPressFX( -1 ); scrollTab.setPressFX( -1 ); topButton.setHighlightFX( -1 ); bottomButton.setHighlightFX( -1 ); scrollTab.setHighlightFX( -1 ); topButton.setDisabledFX( -1 ); bottomButton.setDisabledFX( -1 ); scrollTab.setDisabledFX( -1 ); scrollTab.setTexture( (unsigned long)0 ); moveTo(xPos,yPos); SetScrollMax(0); SetScrollPos(0); scrollInc = 1; pageInc = 10; scrollTab.lightEdge = 0xff005392; scrollTab.darkEdge = 0xff002D51; scrollTab.regularColor =0xff004275; return (NO_ERR); }
// Actual zoom code. void CPreviewView::DoZoom(UINT nPage, CPoint point) { if (m_nZoomState == ZOOM_OUT) { // taking over scroll bars m_nPages = m_nZoomOutPages; ShowScrollBar(SB_HORZ, FALSE); //hide the horizontal bar BOOL bShowBar = m_pPreviewInfo->GetMaxPage() < 0x8000 && m_pPreviewInfo->GetMaxPage() - m_pPreviewInfo->GetMinPage() <= 32767U; ShowScrollBar(SB_VERT, bShowBar); //Show the vertical bar if (bShowBar) { SetScrollRange(SB_VERT, m_pPreviewInfo->GetMinPage(), m_pPreviewInfo->GetMaxPage(), FALSE); SetScrollPos(SB_VERT, m_nCurrentPage, TRUE); } SetCurrentPage(m_nCurrentPage, TRUE); } else { m_nPages = 1; // only one page in zoomed states m_pPageInfo[0].sizeZoomOutRatio = m_pPageInfo[nPage].sizeZoomOutRatio; m_pPageInfo[0].sizeUnscaled = m_pPageInfo[nPage].sizeUnscaled; // Sets the printer page SetCurrentPage(m_nCurrentPage + nPage, FALSE); SetScaledSize(0); CSize* pRatio = &m_pPageInfo[nPage].sizeScaleRatio; // convert Hit Point from screen 1:1 point.x = MulDiv(point.x, pRatio->cx, pRatio->cy); point.y = MulDiv(point.y, pRatio->cx, pRatio->cy); // Adjust point for page position point += (CSize)m_pPageInfo[0].rectScreen.TopLeft(); // Scroll to center CenterOnPoint(point); } }
static void status_OnHScroll( HWND hwnd, HWND hwndCtl, UINT code, int pos) { int min, max, cp; struct statusWindowData *theData; theData = (struct statusWindowData *) GetWindowLongPtr(hwnd,GWLP_USERDATA); if (theData == NULL) { return; } GetScrollRange(hwnd,SB_HORZ,&min,&max); cp = GetScrollPos(hwnd,SB_HORZ); switch (code) { case SB_LINEDOWN: cp++; break; case SB_LINEUP: cp--; break; case SB_PAGEDOWN: cp += theData->noLines; // Should be window width? break; case SB_PAGEUP: cp -= theData->noLines; // Should be window width? break; case SB_THUMBTRACK: cp = pos; break; default: return; } if (cp > max) cp = max; if (cp < min) cp = min; SetScrollPos(hwnd,SB_HORZ,cp,TRUE); InvalidateRect(hwnd,NULL,TRUE); }
static void gwscrollbar(GUIWIN *gw, long top, long bottom, long total) { GUI_WINDOW *gwp = (GUI_WINDOW *)gw; #if defined (SIF_ALL) SCROLLINFO scrollinfo; #endif if (!o_scrollbar (gwp)) return; /* Prescale to make total < 65535, to work around Win32 limit */ while (total >= 65535) { top >>= 1; bottom >>= 1; total >>= 1; } if (total < gwp->numrows || bottom <= 0) { total = gwp->numrows; top = 0; bottom = total - 1; } if (top == 0 && bottom >= total) /* Weird bug in Win32? */ bottom = total - 1; gwp->scrollsize = total; #if defined (SIF_ALL) scrollinfo.cbSize = sizeof (scrollinfo); scrollinfo.fMask = SIF_ALL; scrollinfo.nMin = 0; scrollinfo.nMax = total; scrollinfo.nPos = top; scrollinfo.nPage = bottom - top + 1; /* "+1" is because nMin=0 */ if (scrollinfo.nPage > (unsigned)total) scrollinfo.nPage = (unsigned)total + 1; /* "+1" is because nMin=0 */ scrollinfo.nTrackPos = top; gwp->thumbsize = scrollinfo.nPage; SetScrollInfo (gwp->clientHWnd, SB_VERT, &scrollinfo, TRUE); if (o_verbose >= 3) msg(MSG_STATUS, "[ddd], nMin=0, nMax=$1, nPage=$2, nPos=$3", (long)scrollinfo.nMax, (long)scrollinfo.nPage, (long)scrollinfo.nPos); #else /* Win16, or Win32 with MSVC++ 2.0 */ SetScrollRange (gwp->clientHWnd, SB_VERT, 0, total, FALSE); SetScrollPos (gwp->clientHWnd, SB_VERT, top, TRUE); #endif }
void CCalendarCtrl::Goto(const COleDateTime& dtDate, bool bSelect) { if( (dtDate < m_BoundUp) && (dtDate > m_BoundDown) ) { m_DateCurrent = dtDate; if(m_nFirstWeekDay<1 || m_nFirstWeekDay>7) m_nFirstWeekDay = 1; COleDateTime dtIte(m_DateCurrent.GetYear(), m_DateCurrent.GetMonth(), m_DateCurrent.GetDay(),0,0,0); int narr[7]; for (int d=0; d<7; d++) narr[((m_nFirstWeekDay-1)+d)%7] = d; int nCellStart = narr[dtIte.GetDayOfWeek()-1]; for(int i=0; i<nCellStart; i++) dtIte -= COleDateTimeSpan(1,0,0,0); for(i=0; i<CALENDAR_ROWS ; i++) { for(int u=0; u<CALENDAR_COLUMNS; u++) { // Init the cell m_dayCells[i][u].date = dtIte; m_dayCells[i][u].bPartial = false; m_dayCells[i][u].bMark = false; m_dayCells[i][u].csaLines.RemoveAll(); if(m_pfnDataCallback) m_pfnDataCallback(this, DateToSeconds(m_dayCells[i][u].date)); dtIte += COleDateTimeSpan(1,0,0,0); } } if(bSelect) { m_RandomSelection.RemoveAll(); m_SelectionRange[2] = 0; m_SelectionRange[1] = DateToSeconds(COleDateTime(m_DateCurrent.GetYear(), m_DateCurrent.GetMonth(), m_DateCurrent.GetDay(),0,0,0)); m_SelectionRange[0] = m_SelectionRange[1]; // Scrolling pos COleDateTime today(time(NULL)); m_nVscrollPos = (m_nVscrollMax/2) + (m_DateCurrent-today).GetDays()/7; SetScrollPos(SB_VERT, m_nVscrollPos, TRUE); } } Invalidate(true); }
BOOL CWndMapPartsGrp::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { int nTmp; nTmp = -1; if (zDelta < 0) { nTmp = 1; } nTmp += GetScrollPos (SB_VERT); nTmp = max (nTmp, 0); SetScrollPos (SB_VERT, nTmp); InvalidateRect (NULL); return FALSE; }
void ChatCtrl::scrollToEnd() { SCROLLINFO si = { 0 }; POINT pt = { 0 }; si.cbSize = sizeof(si); si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; GetScrollInfo(SB_VERT, &si); GetScrollPos(&pt); // this must be called twice to work properly :( PostMessage(EM_SCROLL, SB_BOTTOM, 0); PostMessage(EM_SCROLL, SB_BOTTOM, 0); SetScrollPos(&pt); }
void SCALE::DoVscroll (HWND hwnd, WPARAM wParam, LPARAM lParam) { int nVscrollInc ; switch (wParam) { case SB_TOP: nVscrollInc = -nVscrollPos ; break ; case SB_BOTTOM: nVscrollInc = nVscrollMax - nVscrollPos ; break ; case SB_LINEUP: nVscrollInc = -5 ; break ; case SB_LINEDOWN: nVscrollInc = 5 ; break ; case SB_PAGEUP: nVscrollInc = min (-5, -nVscrollMax ) ; break ; case SB_PAGEDOWN: nVscrollInc = max (5, nVscrollMax ) ; break ; case SB_THUMBTRACK: nVscrollInc = LOWORD (lParam) - nVscrollPos ; break ; default: nVscrollInc = 0 ; } nVscrollInc = max (-nVscrollPos, min (nVscrollInc, nVscrollMax - nVscrollPos)) ; if (nVscrollInc) { nVscrollPos += nVscrollInc ; nVfirstPixel +=nVscrollInc ; ScrollWindow (hwnd, 0, -nVscrollInc, NULL, NULL) ; SetScrollPos (hwnd, SB_VERT, nVscrollPos, TRUE) ; UpdateWindow (hwnd) ; } }
/////////////////////////////////////////////////////////////////////////////// // Subclassing of IDC_FRAME to implement more user-friendly fields scrolling // static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_COMMAND && lParam != 0) { HWND hwndDlg=GetParent(hwnd); JabberSearchData * dat=(JabberSearchData *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); if (dat && lParam) { int pos=dat->curPos; RECT MineRect; RECT FrameRect; GetWindowRect(GetDlgItem(hwndDlg, IDC_FRAME),&FrameRect); GetWindowRect((HWND)lParam, &MineRect); if (MineRect.top-10 < FrameRect.top) { pos=dat->curPos+(MineRect.top-14-FrameRect.top); if (pos<0) pos=0; } else if (MineRect.bottom > FrameRect.bottom) { pos=dat->curPos+(MineRect.bottom-FrameRect.bottom); if (dat->frameHeight+pos>dat->CurrentHeight) pos=dat->CurrentHeight-dat->frameHeight; } if (pos != dat->curPos) { ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, NULL, &(dat->frameRect)); SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE); RECT Invalid=dat->frameRect; if (dat->curPos - pos >0) Invalid.bottom=Invalid.top+(dat->curPos - pos); else Invalid.top=Invalid.bottom+(dat->curPos - pos); RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW |RDW_ALLCHILDREN); dat->curPos = pos; } } if (HIWORD(wParam)==EN_SETFOCUS) { //Transmit focus set notification to parent window PostMessage(GetParent(hwndDlg),WM_COMMAND, MAKEWPARAM(0,EN_SETFOCUS), (LPARAM)hwndDlg); } } if (msg == WM_PAINT) { PAINTSTRUCT ps; HDC hdc=BeginPaint(hwnd, &ps); FillRect(hdc,&(ps.rcPaint),GetSysColorBrush(COLOR_BTNFACE)); EndPaint(hwnd, &ps); } return DefWindowProc(hwnd,msg,wParam,lParam); }
void CCxImageCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int nDelta; int nMaxPos = m_dwHeight - m_nCurHeight; switch (nSBCode) { case SB_LINEDOWN: if (m_nVScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/20,nMaxPos-m_nVScrollPos); break; case SB_LINEUP: if (m_nVScrollPos <= 0) return; nDelta = -min(nMaxPos/20,m_nVScrollPos); break; case SB_PAGEDOWN: if (m_nVScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/2,nMaxPos-m_nVScrollPos); break; case SB_THUMBPOSITION: nDelta = (int)nPos - m_nVScrollPos; break; case SB_PAGEUP: if (m_nVScrollPos <= 0) return; nDelta = -min(nMaxPos/2,m_nVScrollPos); break; default: return; } m_nVScrollPos += nDelta; SetScrollPos(SB_VERT,m_nVScrollPos,TRUE); //ScrollWindow(0,-nDelta); if(IsWindow(GetSafeHwnd())) Invalidate(FALSE); CWnd::OnVScroll(nSBCode, nPos, pScrollBar); }
void CColumnTreeView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { UNREFERENCED_PARAMETER( pScrollBar ); CRect rcClient; GetClientRect(&rcClient); int cx = rcClient.Width(); int xLast = m_xPos; switch (nSBCode) { case SB_LINELEFT: m_xPos -= 15; break; case SB_LINERIGHT: m_xPos += 15; break; case SB_PAGELEFT: m_xPos -= cx; break; case SB_PAGERIGHT: m_xPos += cx; break; case SB_LEFT: m_xPos = 0; break; case SB_RIGHT: m_xPos = m_cxTotal - cx; break; case SB_THUMBTRACK: m_xPos = nPos; break; } if (m_xPos < 0) m_xPos = 0; else if (m_xPos > m_cxTotal - cx) m_xPos = m_cxTotal - cx; if (xLast == m_xPos) return; SetScrollPos(SB_HORZ, m_xPos); RepositionControls(); }
void CScrollableDialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* /*pScrollBar*/) { // calc new y position int y = GetScrollPos(SB_VERT); int yOrig = y; switch (nSBCode) { case SB_TOP: y = 0; break; case SB_BOTTOM: y = INT_MAX; break; case SB_LINEUP: y -= 10; break; case SB_LINEDOWN: y += 10; break; case SB_PAGEUP: y -= 100; break; case SB_PAGEDOWN: y += 100; break; case SB_THUMBTRACK: y = nPos; break; } SetScrollPos(SB_VERT, y); y = GetScrollPos(SB_VERT); if (y != yOrig) { /* Now ScrollWindow(0, yOrig-y) is SUPPOSED to move all the child windows and in normal Win32 it does, but in WinCE it doesn't. All documentation says that it does, but to damn well DOESN'T. */ for (CWnd * pChild = GetWindow(GW_CHILD); pChild != NULL; pChild = pChild->GetNextWindow(GW_HWNDNEXT)) { CRect rect; pChild->GetWindowRect(&rect); ScreenToClient(&rect); pChild->SetWindowPos(NULL, rect.left, rect.top+(yOrig-y), 0, 0, SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER); } } }
void CDuiItemBox::EnsureVisible(CDuiWindow *pItem) { if(!HasScrollBar(TRUE)) return; DUIASSERT(pItem); CRect rcItem; pItem->GetRect(&rcItem); int yOffset=0; if(rcItem.bottom>m_rcWindow.bottom) { yOffset=rcItem.bottom-m_rcWindow.bottom; } else if(rcItem.top<m_rcWindow.top) { yOffset=rcItem.top-m_rcWindow.top; } SetScrollPos(TRUE,GetScrollPos(TRUE)+yOffset,TRUE); }
void CCxImageCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int nDelta; int nMaxPos = m_dwWidth - m_nCurWidth; switch (nSBCode) { case SB_LINEDOWN: if (m_nHScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/20,nMaxPos-m_nHScrollPos); break; case SB_LINEUP: if (m_nHScrollPos <= 0) return; nDelta = -min(nMaxPos/20,m_nHScrollPos); break; case SB_PAGEDOWN: if (m_nHScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/2,nMaxPos-m_nHScrollPos); break; case SB_THUMBPOSITION: nDelta = (int)nPos - m_nHScrollPos; break; case SB_PAGEUP: if (m_nHScrollPos <= 0) return; nDelta = -min(nMaxPos/20,m_nHScrollPos); break; default: return; } m_nHScrollPos += nDelta; SetScrollPos(SB_HORZ,m_nHScrollPos,TRUE); //ScrollWindow(-nDelta,0); Invalidate(FALSE); CWnd::OnHScroll(nSBCode, nPos, pScrollBar); }
void CDropWnd::SetRegex(TSTLSTRING strRegex) { m_strRegex = TEXT("[\\w\\W]*"); m_strRegex.append(strRegex); m_strRegex.append(TEXT("[\\w\\W]*")); Filter(); SetScrollPos(SB_VERT, 0, FALSE); if(m_FilterItemCollection.size() <= 10) EnableScrollBar(SB_VERT, ESB_DISABLE_BOTH); else { EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH); SetScrollRange(SB_VERT, 0, m_FilterItemCollection.size() - 10); } Invalidate(); }
void CScrollDlg::SetupScrollbars() { CRect tempRect; GetClientRect(&tempRect); //Max Vertical Scrolling is the difference between size //of the Whole Property Page with Controls and that with //the current one devided by the Indentation you set m_nVertInc = (m_ClientRect.Height() - tempRect.Height())/VERT_PTS; m_nVscrollMax = max(0, m_nVertInc); m_nVscrollPos = min(m_nVscrollPos, m_nVscrollMax); SetScrollRange(SB_VERT, 0, m_nVscrollMax, FALSE); SetScrollPos(SB_VERT, m_nVscrollPos, TRUE); }
static int winCanvasSetDXAttrib(Ihandle* ih, const char *value) { if (ih->data->sb & IUP_SB_HORIZ) { double posx, xmin, xmax; float dx; int iposx, ipagex; if (!iupStrToFloat(value, &dx)) return 1; xmin = iupAttribGetFloat(ih, "XMIN"); xmax = iupAttribGetFloat(ih, "XMAX"); posx = ih->data->posx; iupCanvasCalcScrollIntPos(xmin, xmax, dx, posx, IUP_SB_MIN, IUP_SB_MAX, &ipagex, &iposx); if (dx >= (xmax-xmin)) { if (iupAttribGetBoolean(ih, "XAUTOHIDE")) ShowScrollBar(ih->handle, SB_HORZ, FALSE); else EnableScrollBar(ih->handle, SB_HORZ, ESB_DISABLE_BOTH); ih->data->posx = (float)xmin; SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, TRUE); return 1; } else { ShowScrollBar(ih->handle, SB_HORZ, TRUE); EnableScrollBar(ih->handle, SB_HORZ, ESB_ENABLE_BOTH); } winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, iposx, ipagex, SB_HORZ); /* update position because it could be corrected */ iupCanvasCalcScrollRealPos(xmin, xmax, &posx, IUP_SB_MIN, IUP_SB_MAX, ipagex, &iposx); ih->data->posx = (float)posx; } return 1; }
INT_PTR CALLBACK viewerChooseValueWndProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND scrollbar; SCROLLINFO sbinfo; int val; switch(message) { case WM_INITDIALOG: SetWindowText(hwndDlg, viewer_cvwin_caption); SetDlgItemInt(hwndDlg, 103, viewer_cvwin_minval, TRUE); SetDlgItemInt(hwndDlg, 104, viewer_cvwin_maxval, TRUE); SetDlgItemInt(hwndDlg, 105, viewer_cvwin_newval, TRUE); scrollbar = GetDlgItem(hwndDlg, 102); sbinfo.cbSize = sizeof(SCROLLINFO); sbinfo.fMask = SIF_POS|SIF_RANGE; sbinfo.nMin = 0; sbinfo.nMax = viewer_cvwin_maxval-viewer_cvwin_minval; sbinfo.nPos = viewer_cvwin_newval-viewer_cvwin_minval; SetScrollInfo(scrollbar, SB_CTL, &sbinfo, TRUE); case WM_COMMAND: switch(LOWORD(wParam)) { case 100: scrollbar = GetDlgItem(hwndDlg, 102); val = GetScrollPos(scrollbar, SB_CTL)+viewer_cvwin_minval; if((val-viewer_cvwin_newval)%viewer_cvwin_step == 0) viewer_cvwin_newval = val; case 101: EndDialog(hwndDlg, wParam); return TRUE; } case WM_HSCROLL: case WM_VSCROLL: switch(LOWORD(wParam)) { case SB_THUMBPOSITION: case SB_THUMBTRACK: scrollbar = GetDlgItem(hwndDlg, 102); if((HIWORD(wParam)+viewer_cvwin_minval-viewer_cvwin_newval)%viewer_cvwin_step == 0) viewer_cvwin_newval = HIWORD(wParam)+viewer_cvwin_minval; SetDlgItemInt(hwndDlg, 105, viewer_cvwin_newval, TRUE); SetScrollPos(scrollbar, SB_CTL, HIWORD(wParam), TRUE); } return TRUE; } return FALSE; }