Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. all Slider objects are sending OnHScroll() msg

all Slider objects are sending OnHScroll() msg

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aquawicket
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • A aquawicket

      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

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • M Mark Salsbery

        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

        A Offline
        A Offline
        aquawicket
        wrote on last edited by
        #3

        Awsome! it's actually the other way around... if(pScrollBar != NULL){return;} Thanks again mark. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups