all Slider objects are sending OnHScroll() msg
-
Hi.. I've got a dialog window with horizontal and vertical scroll bars to move the window... That all works fine.. The only problem is I have some slider controlls inside the window that move it too.. and that isn't wanted.. I'm thinkin any time I move one of my slider objects.. it sends a message to OnHScroll(); or OnVScroll(); depending. I only want the window scroll bars to send the message. Not the dialog slider objects void CEdrumMonDlg::OnSize(UINT nType, int cx, int cy) //Creates the window scroll bars if the window size is changed { CDialog::OnSize(nType, cx, cy); m_nCurHeight = cy; m_nCurWidth = cx; int nScrollMax; int nScrollMax2; if (cy < m_rect.Height()) { nScrollMax = m_rect.Height() - cy; } else nScrollMax = 0; if (cx < m_rect.Width()) { nScrollMax2 = m_rect.Width() - cx; } else nScrollMax2 = 0; SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_ALL; // SIF_ALL = SIF_PAGE | SIF_RANGE | SIF_POS; si.nMin = 0; si.nMax = nScrollMax; si.nPage = si.nMax/10; si.nPos = 0; SetScrollInfo(SB_VERT, &si, TRUE); SetScrollPos(SB_VERT,m_nScrollPos,TRUE); SCROLLINFO si2; si2.cbSize = sizeof(SCROLLINFO); si2.fMask = SIF_ALL; // SIF_ALL = SIF_PAGE | SIF_RANGE | SIF_POS; si2.nMin = 0; si2.nMax = nScrollMax2; si2.nPage = si2.nMax/10; si2.nPos = 0; SetScrollInfo(SB_HORZ, &si2, TRUE); SetScrollPos(SB_HORZ, m_nScrollPos2,TRUE); } void CEdrumMonDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int nDelta; int nMaxPos = m_rect.Height() - m_nCurHeight; switch (nSBCode) { case SB_LINEDOWN: if (m_nScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/100,nMaxPos-m_nScrollPos); break; case SB_LINEUP: if (m_nScrollPos <= 0) return; nDelta = -min(nMaxPos/100,m_nScrollPos); break; case SB_PAGEDOWN: if (m_nScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/10,nMaxPos-m_nScrollPos); break; case SB_THUMBPOSITION: nDelta = (int)nPos - m_nScrollPos; break; case SB_PAGEUP: if (m_nScrollPos <= 0) return; nDelta = -min(nMaxPos/10,m_nScrollPos); break; default: return; } m_nScrollPos += nDelta; SetScrollPos(SB_VERT,m_nScrollPos,TRUE); ScrollWindow(0,-nDelta); CDialog::OnVScroll(nSBCode, nPos, pScrollBar); } void CEdrumMonDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) //pretty much same as OnVScroll
-
Hi.. I've got a dialog window with horizontal and vertical scroll bars to move the window... That all works fine.. The only problem is I have some slider controlls inside the window that move it too.. and that isn't wanted.. I'm thinkin any time I move one of my slider objects.. it sends a message to OnHScroll(); or OnVScroll(); depending. I only want the window scroll bars to send the message. Not the dialog slider objects void CEdrumMonDlg::OnSize(UINT nType, int cx, int cy) //Creates the window scroll bars if the window size is changed { CDialog::OnSize(nType, cx, cy); m_nCurHeight = cy; m_nCurWidth = cx; int nScrollMax; int nScrollMax2; if (cy < m_rect.Height()) { nScrollMax = m_rect.Height() - cy; } else nScrollMax = 0; if (cx < m_rect.Width()) { nScrollMax2 = m_rect.Width() - cx; } else nScrollMax2 = 0; SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_ALL; // SIF_ALL = SIF_PAGE | SIF_RANGE | SIF_POS; si.nMin = 0; si.nMax = nScrollMax; si.nPage = si.nMax/10; si.nPos = 0; SetScrollInfo(SB_VERT, &si, TRUE); SetScrollPos(SB_VERT,m_nScrollPos,TRUE); SCROLLINFO si2; si2.cbSize = sizeof(SCROLLINFO); si2.fMask = SIF_ALL; // SIF_ALL = SIF_PAGE | SIF_RANGE | SIF_POS; si2.nMin = 0; si2.nMax = nScrollMax2; si2.nPage = si2.nMax/10; si2.nPos = 0; SetScrollInfo(SB_HORZ, &si2, TRUE); SetScrollPos(SB_HORZ, m_nScrollPos2,TRUE); } void CEdrumMonDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int nDelta; int nMaxPos = m_rect.Height() - m_nCurHeight; switch (nSBCode) { case SB_LINEDOWN: if (m_nScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/100,nMaxPos-m_nScrollPos); break; case SB_LINEUP: if (m_nScrollPos <= 0) return; nDelta = -min(nMaxPos/100,m_nScrollPos); break; case SB_PAGEDOWN: if (m_nScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/10,nMaxPos-m_nScrollPos); break; case SB_THUMBPOSITION: nDelta = (int)nPos - m_nScrollPos; break; case SB_PAGEUP: if (m_nScrollPos <= 0) return; nDelta = -min(nMaxPos/10,m_nScrollPos); break; default: return; } m_nScrollPos += nDelta; SetScrollPos(SB_VERT,m_nScrollPos,TRUE); ScrollWindow(0,-nDelta); CDialog::OnVScroll(nSBCode, nPos, pScrollBar); } void CEdrumMonDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) //pretty much same as OnVScroll
I "think" pScrollBar is NULL if the message doesn't come from a scroll bar so maybe try just returning from your OnHScroll/OnVScroll handlers if pScrollBar is NULL. Mark
-
I "think" pScrollBar is NULL if the message doesn't come from a scroll bar so maybe try just returning from your OnHScroll/OnVScroll handlers if pScrollBar is NULL. Mark
Awsome! it's actually the other way around... if(pScrollBar != NULL){return;} Thanks again mark. :)