void XYDrawbox::RefreshYPosScrollBar() { scrollinfo.fMask = SIF_POS; scrollinfo.nPos = this->posYScroll; SetScrollInfo(this->hwndThis, SB_VERT, &scrollinfo, TRUE); GetScrollInfo(this->hwndThis, SB_VERT, &scrollinfo); this->posYScroll = scrollinfo.nPos; }
int NativeScrollBarWin::GetPosition() const { SCROLLINFO si; si.cbSize = sizeof(si); si.fMask = SIF_POS; GetScrollInfo(sb_container_->GetScrollBarHWND(), SB_CTL, &si); return si.nPos; }
LRESULT CTrashSkipCtrl::OnVScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { SCROLLINFO si; int vertPos; si.cbSize = sizeof si; si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS; GetScrollInfo(SB_VERT, &si); vertPos = si.nPos; switch (LOWORD(wParam)) { case SB_TOP: si.nPos = si.nMin; break; case SB_BOTTOM: si.nPos = si.nMax; break; case SB_LINEUP: si.nPos -= 1; break; case SB_LINEDOWN: si.nPos += 1; break; case SB_PAGEUP: si.nPos -= si.nPage; break; case SB_PAGEDOWN: si.nPos += si.nPage; break; case SB_THUMBTRACK: si.nPos = si.nTrackPos; break; default: break; } si.fMask = SIF_ALL; m_nPos = abs(si.nPos); SetScrollInfo(SB_VERT, &si, TRUE); int nScrollHeight = int((m_rcRealClient.Height() - m_rcClient.Height()) * (m_nPos * 1.0) / (m_rcRealClient.Height())); int n = (m_nHeight - nScrollHeight); if (n > 1 || n < -1) { Invalidate(); } bHandled = FALSE; return TRUE; }
void CTerrainEditorDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { SCROLLINFO si; si.cbSize=sizeof(si); GetScrollInfo(SB_HORZ,&si); int pos; switch(nSBCode) { case SB_LEFT: ScrollWindow(si.nPos-si.nMin,0); si.nPos=si.nMin; SetScrollInfo(SB_HORZ,&si); break; case SB_RIGHT: ScrollWindow(si.nPos-si.nMax+si.nPage,0); si.nPos=si.nMax-si.nPage; SetScrollInfo(SB_HORZ,&si); break; case SB_LINELEFT: pos=si.nPos; si.nPos-=10; if(si.nPos<si.nMin) si.nPos=si.nMin; ScrollWindow(pos-si.nPos,0); SetScrollInfo(SB_HORZ,&si); break; case SB_LINERIGHT: pos=si.nPos; si.nPos+=si.nPage; if(si.nPos>si.nMax-(int)si.nPage) si.nPos=si.nMax-si.nPage; ScrollWindow(pos-si.nPos,0); SetScrollInfo(SB_HORZ,&si); break; case SB_PAGELEFT: pos=si.nPos; si.nPos-=si.nPage; if(si.nPos<si.nMin) si.nPos=si.nMin; ScrollWindow(pos-si.nPos,0); SetScrollInfo(SB_HORZ,&si); break; case SB_PAGERIGHT: pos=si.nPos; si.nPos+=10; if(si.nPos>si.nMax-(int)si.nPage) si.nPos=si.nMax-si.nPage; ScrollWindow(pos-si.nPos,0); SetScrollInfo(SB_HORZ,&si); break; case SB_THUMBPOSITION: case SB_THUMBTRACK: ScrollWindow(si.nPos-nPos,0); si.nPos=nPos; SetScrollInfo(SB_HORZ,&si); break; default: break; } CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar); }
void CDisplayDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int h = 10; SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_ALL; GetScrollInfo(SB_VERT, &si); int nOldPos = si.nPos; switch (nSBCode) { case SB_LINEDOWN: si.nPos = min(si.nPos + h, si.nMax); break; case SB_PAGEDOWN: si.nPos = min(si.nPos + h * 10, si.nMax); break; case SB_LINEUP: si.nPos = max(si.nPos - h, si.nMin); break; case SB_PAGEUP: si.nPos = max(si.nPos - h * 10, si.nMin); break; case SB_THUMBPOSITION: case SB_THUMBTRACK: si.nPos = si.nTrackPos; break; case SB_TOP: si.nPos = si.nMin; break; case SB_BOTTOM: si.nPos = si.nMax; break; } SetScrollInfo(SB_VERT, &si); GetScrollInfo(SB_VERT, &si); //重新获取新的位置 ScrollWindowEx(0, nOldPos - si.nPos,NULL, NULL, NULL, NULL, SW_ERASE|SW_SCROLLCHILDREN); UpdateWindow(); RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0); //m_ScreenDisplayer->ReflashDC(); CDialog::OnVScroll(nSBCode, nPos, pScrollBar); }
UINT CDocWindow::GetScrollPage(int nBar) { SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_PAGE; si.nPage = 0; GetScrollInfo(nBar, &si); return si.nPage; }
int GetScrollPos(HWND hwnd, int nBar) { SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); info.fMask = SIF_POS; GetScrollInfo(g_sbTime, SB_CTL, &info); return info.nPos; }
static void getScrollPos(HWND hwnd, int *xpos, int *ypos) { SCROLLINFO si; ZeroMemory(&si, sizeof (SCROLLINFO)); si.cbSize = sizeof (SCROLLINFO); si.fMask = SIF_POS | SIF_TRACKPOS; if (GetScrollInfo(hwnd, SB_HORZ, &si) == 0) xpanic("error getting horizontal scroll position for Area", GetLastError()); *xpos = si.nPos; // MSDN example code reinitializes this each time, so we'll do it too just to be safe ZeroMemory(&si, sizeof (SCROLLINFO)); si.cbSize = sizeof (SCROLLINFO); si.fMask = SIF_POS | SIF_TRACKPOS; if (GetScrollInfo(hwnd, SB_VERT, &si) == 0) xpanic("error getting vertical scroll position for Area", GetLastError()); *ypos = si.nPos; }
void sys_winlog_set( void *wnd, const char *txt ) { HWND text = (HWND)GetProp(wnd,PTEXT); DWORD a,b; SCROLLINFO sinf; POINT pt; sinf.cbSize = sizeof(sinf); sinf.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; GetScrollInfo(text,SB_VERT,&sinf); SendMessage(text,EM_GETSCROLLPOS,0,(LPARAM)&pt); SendMessage(text,EM_GETSEL,(WPARAM)&a,(LPARAM)&b); SetWindowText(text,txt); SendMessage(text,EM_SETSEL,a,b); if( sinf.nPos + sinf.nPage == sinf.nMax || sinf.nMax == 1 ) { GetScrollInfo(text,SB_VERT,&sinf); pt.y = sinf.nMax - sinf.nPage; } SendMessage(text,EM_SETSCROLLPOS,0,(LPARAM)&pt); }
int CGraphListCtrl::GetScrollPos32(int nBar, BOOL bGetTrackPos /* = FALSE */) { SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); if (bGetTrackPos) { if (GetScrollInfo(nBar, &si, SIF_TRACKPOS)) return si.nTrackPos; } else { if (GetScrollInfo(nBar, &si, SIF_POS)) return si.nPos; } return 0; }
void PrintText( HWND hwnd,int cxChar,int cyChar,int cxCaps ) { HDC hdc; PAINTSTRUCT ps; SCROLLINFO si; int iVertPos,iHorzPos,iPaintBeg,iPaintEnd; int x,y; TCHAR szBuffer[10]; hdc = BeginPaint(hwnd,&ps); si.cbSize = sizeof(si); si.fMask = SIF_POS; GetScrollInfo(hwnd,SB_VERT,&si); iVertPos = si.nPos; GetScrollInfo(hwnd,SB_HORZ,&si); iHorzPos = si.nPos; iPaintBeg = max(0,iVertPos + ps.rcPaint.top / cyChar); iPaintEnd = min(NUMLINES - 1, iVertPos + ps.rcPaint.bottom / cyChar); for (int i = iPaintBeg ; i <= iPaintEnd ; i++) { x = cxChar * (1 - iHorzPos) ; y = cyChar * (i - iVertPos) ; TextOut (hdc, x, y,sysmetrics[i].szLabel, lstrlen (sysmetrics[i].szLabel)) ; TextOut (hdc, x + 22 * cxCaps, y,sysmetrics[i].szDesc, lstrlen (sysmetrics[i].szDesc)) ; SetTextAlign (hdc, TA_RIGHT | TA_TOP) ; TextOut (hdc, x + 22 * cxCaps + 40 * cxChar, y, szBuffer, wsprintf (szBuffer, TEXT ("%5d"), GetSystemMetrics (sysmetrics[i].iIndex))) ; SetTextAlign (hdc, TA_LEFT | TA_TOP) ; } EndPaint(hwnd,&ps); }
LRESULT CWindow::OnVScroll(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { SCROLLINFO si; si.cbSize = sizeof(si); si.fMask = SIF_ALL; GetScrollInfo(hWnd, SB_VERT, &si); switch (LOWORD(wParam)) { case SB_THUMBTRACK: case SB_THUMBPOSITION: si.nPos = HIWORD(wParam); break; case SB_PAGEDOWN: si.nPos += si.nPage; break; case SB_PAGEUP: si.nPos -= si.nPage; break; case SB_LINEUP: --si.nPos; break; case SB_LINEDOWN: ++si.nPos; break; } si.fMask = SIF_POS; SetScrollInfo(hWnd, SB_VERT, &si, True); GetScrollInfo(hWnd, SB_VERT, &si); if (iVScrollPos != si.nPos) { ScrollWindow(hWnd, 0, cyChar * (iVScrollPos - si.nPos), NULL, NULL); iVScrollPos = si.nPos; UpdateWindow(hWnd); } return ERROR_SUCCESS; }
static void scroll(uiArea *a, int which, struct scrollParams *p, WPARAM wParam, LPARAM lParam) { int pos; SCROLLINFO si; pos = *(p->pos); switch (LOWORD(wParam)) { case SB_LEFT: // also SB_TOP pos = 0; break; case SB_RIGHT: // also SB_BOTTOM pos = p->length - p->pagesize; break; case SB_LINELEFT: // also SB_LINEUP pos--; break; case SB_LINERIGHT: // also SB_LINEDOWN pos++; break; case SB_PAGELEFT: // also SB_PAGEUP pos -= p->pagesize; break; case SB_PAGERIGHT: // also SB_PAGEDOWN pos += p->pagesize; break; case SB_THUMBPOSITION: ZeroMemory(&si, sizeof (SCROLLINFO)); si.cbSize = sizeof (SCROLLINFO); si.fMask = SIF_POS; if (GetScrollInfo(a->hwnd, which, &si) == 0) logLastError(L"error getting thumb position for area"); pos = si.nPos; break; case SB_THUMBTRACK: ZeroMemory(&si, sizeof (SCROLLINFO)); si.cbSize = sizeof (SCROLLINFO); si.fMask = SIF_TRACKPOS; if (GetScrollInfo(a->hwnd, which, &si) == 0) logLastError(L"error getting thumb track position for area"); pos = si.nTrackPos; break; } scrollto(a, which, p, pos); }
void BContainer::OnVScroll(UINT nSBCode,UINT nPos, CScrollBar* pScrollBar) { // Handle vertical scrollbar messages // These can be tweaked to better fit the implementation int nInc; int yPos; SCROLLINFO si; GetScrollInfo(SB_VERT,&si,SIF_POS | SIF_RANGE | SIF_PAGE); yPos = si.nPos; nInc = 0; switch (nSBCode) { case SB_TOP: nInc = -si.nPos; break; case SB_BOTTOM: nInc = si.nMax-si.nPos; break; case SB_LINEUP: if(si.nPos > 0) nInc = -1; else nInc = 0; break; case SB_LINEDOWN: if(si.nPage+si.nPos < si.nMax+1) nInc = 1; else nInc = 0; break; // case SB_PAGEUP: nInc = min(-1, -m_nVertInc); break; // case SB_PAGEDOWN: nInc = max(1, m_nVertInc); break; case SB_THUMBTRACK: nInc = nPos - si.nPos; break; default: nInc = 0; } // nInc = max(-si.nPos, min(nInc, si.nMax - si.nPos)); if (nInc) { si.nPos += nInc; int iMove = (yPos - si.nPos)*(ELEMENT_HEIGHT+ELEMENT_SIZE_BETWEEN); si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_POS ; SetScrollInfo(SB_VERT,&si,true); ScrollWindow(0, iMove, NULL, NULL); // CWnd::UpdateWindow(); //SetScrollPos(SB_VERT, m_nVscrollPos, TRUE); } CWnd::OnVScroll(nSBCode, nPos, pScrollBar); }
static int scroller( HWND hwndDlg, WPARAM scroll_command ) { libspectrum_word base; SCROLLINFO si; si.cbSize = sizeof(si); si.fMask = SIF_POS; GetScrollInfo( GetDlgItem( hwndDlg, IDC_MEM_SB ), SB_CTL, &si ); int value = si.nPos; /* in Windows we have to read the command and scroll the scrollbar manually */ switch( LOWORD( scroll_command ) ) { case SB_BOTTOM: value = memorysb_max; break; case SB_TOP: value = memorysb_min; break; case SB_LINEDOWN: value += memorysb_step; break; case SB_LINEUP: value -= memorysb_step; break; case SB_PAGEUP: value -= memorysb_page_inc; break; case SB_PAGEDOWN: value += memorysb_page_inc; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: value = HIWORD( scroll_command ); break; default: return 1; } if( value > memorysb_max ) value = memorysb_max; if( value < memorysb_min ) value = memorysb_min; /* Drop the low bits before displaying anything */ base = value; base &= 0xfff0; /* set the new scrollbar position */ memset( &si, 0, sizeof(si) ); si.cbSize = sizeof(si); si.fMask = SIF_POS; si.nPos = base; SetScrollInfo( GetDlgItem( hwndDlg, IDC_MEM_SB ), SB_CTL, &si, TRUE ); update_display( hwndDlg, base ); return 0; }
AutoScroller::~AutoScroller() { if(scrollInfo_.fMask == 0) { scrollInfo_.fMask = SIF_ALL; BOOL res = GetScrollInfo(window_->GetHWND(), winSB(orient_), &scrollInfo_); if(!res) return; } bool autoScroll = scrollInfo_.nPos + static_cast<int>(scrollInfo_.nPage) >= scrollInfo_.nMax; if(autoScroll) { memset(&scrollInfo_, 0, sizeof(scrollInfo_)); scrollInfo_.cbSize = sizeof(scrollInfo_); scrollInfo_.fMask = SIF_ALL; BOOST_VERIFY(GetScrollInfo(window_->GetHWND(), winSB(orient_), &scrollInfo_)); window_->ScrollLines(scrollInfo_.nMax); } }
int CWndMapPartsGrp::OnCreate(LPCREATESTRUCT lpCreateStruct) { SCROLLINFO stScrollInfo; if (CWnd::OnCreate(lpCreateStruct) == -1) { return -1; } GetScrollInfo (SB_HORZ, &stScrollInfo); stScrollInfo.nPage = 1; SetScrollInfo (SB_HORZ, &stScrollInfo); GetScrollInfo (SB_VERT, &stScrollInfo); stScrollInfo.nPage = 1; SetScrollInfo (SB_VERT, &stScrollInfo); MakeImage (m_nMode); return 0; }
void CConsoleWindow::HandleScrollEvent(UINT aMessage, WPARAM aWParam) { int scrollDir = (aMessage == WM_HSCROLL) ? SB_HORZ : SB_VERT; SCROLLINFO scrollInfo; scrollInfo.cbSize = sizeof(scrollInfo); scrollInfo.fMask = SIF_ALL; GetScrollInfo(Handle(), scrollDir, &scrollInfo); int pos = scrollInfo.nPos; switch (LOWORD(aWParam)) { case SB_LINEUP: // Also SB_LINELEFT. scrollInfo.nPos -= (aMessage == WM_HSCROLL) ? iView->CharWidth() : iView->CharHeight(); break; case SB_LINEDOWN: // Also SB_LINERIGHT. scrollInfo.nPos += (aMessage == WM_HSCROLL) ? iView->CharWidth() : iView->CharHeight(); break; case SB_PAGEUP: // Also SB_PAGELEFT. scrollInfo.nPos -= scrollInfo.nPage; break; case SB_PAGEDOWN: // Also SB_PAGERIGHT. scrollInfo.nPos += scrollInfo.nPage; break; case SB_THUMBTRACK: scrollInfo.nPos = scrollInfo.nTrackPos; break; default: break; } scrollInfo.fMask = SIF_POS; SetScrollInfo (Handle(), scrollDir, &scrollInfo, TRUE); GetScrollInfo (Handle(), scrollDir, &scrollInfo); if (scrollInfo.nPos != pos) { if (aMessage == WM_HSCROLL) { iView->SetHorzScrollPosition(scrollInfo.nPos); } else { iView->SetVertScrollPosition(scrollInfo.nPos); } } }
UINT ExecutionLogWindow::GetTrackPos(HWND hwnd, int fnBar) { SCROLLINFO si; si.cbSize = sizeof(si); si.fMask = SIF_TRACKPOS; if (GetScrollInfo(hwnd, fnBar, &si)) { return si.nTrackPos; } return 0; }
void CHTRichEditCtrl::AddLine(LPCTSTR pszMsg, int iLen, bool bLink, COLORREF cr, COLORREF bk, DWORD mask) { int iMsgLen = (iLen == -1) ? _tcslen(pszMsg) : iLen; if (iMsgLen == 0) return; // Get Edit contents dimensions and cursor position long lStartChar, lEndChar; GetSel(lStartChar, lEndChar); int iSize = GetWindowTextLength(); // Get Auto-AutoScroll state depending on scrollbar position bool bAutoAutoScroll = m_bAutoScroll; // Use the 'ScrollInfo' only, if there is a scrollbar available, otherwise we would // use a scrollinfo which points to the top and we would thus stay at the top. bool bScrollInfo = false; SCROLLINFO si; si.cbSize = sizeof si; si.fMask = SIF_ALL; if ((GetStyle() & WS_VSCROLL) && GetScrollInfo(SB_VERT, &si)) { bScrollInfo = true; // use some threshold to determine if at end or "very near" at end, unfortunately // this is needed to get around richedit specific stuff. this threshold (pixels) // should somewhat reflect the font size used in the control. bAutoAutoScroll = (si.nPos >= (int)(si.nMax - si.nPage - 20)); } // Reduce flicker by ignoring WM_PAINT m_bNoPaint = true; BOOL bIsVisible = IsWindowVisible(); if (bIsVisible) SetRedraw(FALSE); // Remember where we are //int iFirstLine = !bAutoAutoScroll ? GetFirstVisibleLine() : 0; POINT ptScrollPos; SendMessage(EM_GETSCROLLPOS, 0, (LPARAM)&ptScrollPos); // Select at the end of text and replace the selection SafeAddLine(iSize, pszMsg, iMsgLen, lStartChar, lEndChar, bLink, cr, bk, mask); SetSel(lStartChar, lEndChar); // Restore previous selection if (bAutoAutoScroll) ScrollToLastLine(); else { //LineScroll(iFirstLine - GetFirstVisibleLine()); SendMessage(EM_SETSCROLLPOS, 0, (LPARAM)&ptScrollPos); } m_bNoPaint = false; if (bIsVisible) { SetRedraw(); Invalidate(); } }
HL_PRIM void HL_NAME(ui_winlog_set_text)( wref *w, const uchar *txt, bool autoScroll ) { HWND text = (HWND)GetProp(w->h,PTEXT); DWORD a,b; SCROLLINFO sinf; POINT pt; sinf.cbSize = sizeof(sinf); sinf.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; GetScrollInfo(text,SB_VERT,&sinf); SendMessage(text,EM_GETSCROLLPOS,0,(LPARAM)&pt); SendMessage(text,EM_GETSEL,(WPARAM)&a,(LPARAM)&b); SetWindowText(text,txt); SendMessage(text,EM_SETSEL,a,b); if( autoScroll ) { if( sinf.nPos + sinf.nPage == sinf.nMax || sinf.nMax == 1 ) { GetScrollInfo(text,SB_VERT,&sinf); pt.y = sinf.nMax - sinf.nPage; } SendMessage(text,EM_SETSCROLLPOS,0,(LPARAM)&pt); } }
void CWFView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { CBTEditDoc* pDoc = GetDocument(); int MinPos,MaxPos; SCROLLINFO ScrollInfo; CPoint ScrollPos = GetScrollPosition(); m_ScrollX = ScrollPos.x; m_ScrollY = ScrollPos.y; // pDoc->GetScrollPosition((SLONG*)&m_ScrollX,(SLONG*)&m_ScrollY); GetScrollInfo( SB_HORZ, &ScrollInfo, SIF_ALL ); MinPos = ScrollInfo.nMin; MaxPos = ScrollInfo.nMax-ScrollInfo.nPage; switch(nSBCode) { case SB_THUMBPOSITION: case SB_THUMBTRACK: m_ScrollX = nPos; break; case SB_LINELEFT: m_ScrollX -= pDoc->GetTextureWidth(); if(m_ScrollX < MinPos) m_ScrollX = MinPos; break; case SB_LINERIGHT: m_ScrollX += pDoc->GetTextureWidth(); if(m_ScrollX > MaxPos) m_ScrollX = MaxPos; break; case SB_PAGELEFT: m_ScrollX -= ScrollInfo.nPage; if(m_ScrollX < MinPos) m_ScrollX = MinPos; break; case SB_PAGERIGHT: m_ScrollX += ScrollInfo.nPage; if(m_ScrollX > MaxPos) m_ScrollX = MaxPos; break; } m_ScrollX /= pDoc->GetTextureWidth(); m_ScrollX *= pDoc->GetTextureWidth(); pDoc->RegisterScrollPosition(m_ScrollX-pDoc->GetTextureWidth()*OVERSCAN,m_ScrollY-pDoc->GetTextureHeight()*OVERSCAN); UpdateAndValidate(); if(pDoc->Get2DMode() == M2D_WORLD) { if(pDoc->GetAutoSync()) { pDoc->Set3DViewPos(); // Bind views. pDoc->Invalidate3D(); } } SetScrollPos( SB_HORZ, m_ScrollX, TRUE ); }
BOOL CDComView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll) { SCROLLINFO info; if (HIBYTE(nScrollCode) == SB_THUMBTRACK) { GetScrollInfo(SB_VERT, &info); nPos = info.nTrackPos; Invalidate(); } return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll); }
/** * @param bIgnoreScrollPos - pass true to disregard any existing scrollbar styles. */ void CImageView::ResizeImageView(BOOL bIgnoreScrollPos) { SCROLLINFO sinfo; RECT rcClient; GetClientRect(m_hwnd, &rcClient); ZeroMemory(&sinfo, sizeof(sinfo)); sinfo.cbSize = sizeof(sinfo); if (! bIgnoreScrollPos) { sinfo.fMask = SIF_POS; GetScrollInfo(m_hwnd, SB_HORZ, &sinfo); } else sinfo.nPos = 0; sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE; sinfo.nMin = 0; sinfo.nMax = m_szAjustedBitmapSize.cx > 0 ? m_szAjustedBitmapSize.cx - 1 : 0; sinfo.nPage = rcClient.right; ValidateScrollInfo(&sinfo); SetScrollInfo(m_hwnd, SB_HORZ, &sinfo, TRUE); GetClientRect(m_hwnd, &rcClient); ZeroMemory(&sinfo, sizeof(sinfo)); sinfo.cbSize = sizeof(sinfo); if (! bIgnoreScrollPos) { sinfo.fMask = SIF_POS; GetScrollInfo(m_hwnd, SB_VERT, &sinfo); } else sinfo.nPos = 0; sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE; sinfo.nMin = 0; sinfo.nMax = m_szAjustedBitmapSize.cy > 0 ? m_szAjustedBitmapSize.cy - 1 : 0; sinfo.nPage = rcClient.bottom; ValidateScrollInfo(&sinfo); SetScrollInfo(m_hwnd, SB_VERT, &sinfo, TRUE); InvalidateRect(m_hwnd, NULL, FALSE); }
void CScreenDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if (nSBCode != SB_ENDSCROLL) { SCROLLINFO hStructure; GetScrollInfo(SB_HORZ, &hStructure); hStructure.nPos = nPos; SetScrollInfo(SB_HORZ, &hStructure); } CDialog::OnHScroll(nSBCode, nPos, pScrollBar); }
void win_scroll_window(HWND window, WPARAM wparam, int scroll_bar, int scroll_delta_line) { SCROLLINFO si; int scroll_pos; // retrieve vital info about the scroll bar memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; GetScrollInfo(window, scroll_bar, &si); scroll_pos = si.nPos; // change scroll_pos in accordance with this message switch(LOWORD(wparam)) { case SB_BOTTOM: scroll_pos = si.nMax; break; case SB_LINEDOWN: scroll_pos += scroll_delta_line; break; case SB_LINEUP: scroll_pos -= scroll_delta_line; break; case SB_PAGEDOWN: scroll_pos += scroll_delta_line; break; case SB_PAGEUP: scroll_pos -= scroll_delta_line; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: scroll_pos = HIWORD(wparam); break; case SB_TOP: scroll_pos = si.nMin; break; } // max out the scroll bar value if (scroll_pos < si.nMin) scroll_pos = si.nMin; else if (scroll_pos > (si.nMax - si.nPage)) scroll_pos = (si.nMax - si.nPage); // if the value changed, set the scroll position if (scroll_pos != si.nPos) { SetScrollPos(window, scroll_bar, scroll_pos, TRUE); ScrollWindow(window, 0, si.nPos - scroll_pos, NULL, NULL); } }
int CImageWnd::GetScrollPos(int nBar) { SCROLLINFO scrollInfo = { 0 }; scrollInfo.cbSize = sizeof(SCROLLINFO); scrollInfo.fMask = SIF_POS; // Get current position GetScrollInfo(nBar, &scrollInfo); return scrollInfo.nPos; }
//--------------------------------------------------------------------------- bool HaveScrollBar(HWND hwnd) { SCROLLINFO si; si.cbSize = sizeof(si); si.fMask = SIF_ALL; BOOL bHaveScrollBar = GetScrollInfo(hwnd, SB_VERT, &si); if( ! bHaveScrollBar ) return false; if( si.nMax == 0 || si.nMax == 100 ) return false; return true; }
void EXWaitingTreeCtrl::PopulateRoot() { PreExpandItem(TVI_ROOT); ExpandItem(TVI_ROOT); // force update, don't scroll SetRedraw(FALSE); SCROLLINFO si; GetScrollInfo(SB_HORZ, &si); EnsureVisible(GetChildItem(TVI_ROOT)); SetScrollInfo(SB_HORZ, &si, FALSE); SetRedraw(); }
BOOL CTrashCleanCtrl::SetSelectedItem(UINT nItemID) { BOOL bRet = FALSE; size_t iCount, jCount; SCROLLINFO si; int nItemHeiht = 0; if (nItemID < 0) goto Clear0; for (iCount = 0; iCount < m_vecTrashItems.size(); ++iCount) { if (!m_vecTrashItems[iCount].bShow) { continue; } for (jCount = 0; jCount < m_vecTrashItems[iCount].vecItems.size(); ++jCount) { if (nItemID == m_vecTrashItems[iCount].vecItems[jCount].nItemId) { m_nSelectedIndex = m_vecTrashItems[iCount].vecItems[jCount].nItemId; m_vecTrashItems[iCount].bShowDetail = TRUE; nItemHeiht = m_vecTrashItems[iCount].vecItems[jCount].rcCheck.top; if (nItemHeiht == 0) nItemHeiht = m_vecTrashItems[iCount].rcBox.bottom; bRet = TRUE; break; } } if (bRet) break; } if (bRet) { si.cbSize = sizeof si; si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS; GetScrollInfo(SB_VERT, &si); si.fMask = SIF_POS; m_nPos = (nItemHeiht - (int)si.nPage / 4); if (m_nPos < 0) m_nPos = 0; si.nPos = m_nPos; SetScrollInfo(SB_VERT, &si, TRUE); } Clear0: return bRet; }