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. Scrollbar looses grip

Scrollbar looses grip

Scheduled Pinned Locked Moved C / C++ / MFC
csscomhelptutorial
2 Posts 1 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.
  • D Offline
    D Offline
    Daffy d
    wrote on last edited by
    #1

    Hi there! I’m currently playing with a PICO scope. (it’s a small parallel port oscilloscope that runs at 20KHz max.) I’m trying to make a custom graphical interface showing the results acquired from the scope (was hoping to use it in a dynamometer project I was planning) . This part of the deal runs great. But I wanted to add a horizontal scroll bar to make navigation trough the data easier. So l borrowed from Roger Allens tutorial. On scrollbars (http://www.codeproject.com/miscctrl/Scrollbar.asp) And everything works almost according to plan. Unfortunately I’m using a quite large data buffer. -16 KB to 512 KB. Ant that’s where things get strange. It seems that things behave quite normal when I’m below 32KB. But as soon as I get above 32 KB the scrollbar position returns to 0 and starts counting over - When using “SB_THUMBTRACK” and “SB_THUMBPOSITION” But behaves normal (counts and scrolls all the way up to 512KB) when using all the other “positioning” options (like SB_PAGE & SB_LINE) The problem looks like the variable holding the bar position has a max of 32768 and than turns over to 0. (but only when dragging the bar) That would be a 16 bit signed variable. But the SCROLLINFO.nPos which I use is a int so that shouldn’t be the problem. My code is as I said pulled more or less directly from Rogers tutorial and looks like this : // m_datasize is the size of the collected data 16 KB to 512 KB. int i_CurPos = GetScrollPos(SB_HORZ); int iPrevPos = i_CurPos; CRect myRect; GetClientRect(&myRect); switch(nSBCode) { case SB_LEFT: i_CurPos = 0; break; case SB_RIGHT: i_CurPos = GetDocument()->m_datasize; break; case SB_LINELEFT: i_CurPos = max(i_CurPos -6, 0); break; case SB_LINERIGHT: i_CurPos = min(i_CurPos + 6,(GetDocument()->m_datasize+ myRect.Width() - 110)); break; case SB_PAGELEFT: i_CurPos = max(i_CurPos - myRect.Width(), 0); break; case SB_PAGERIGHT: i_CurPos = min(i_CurPos + myRect.Width(), (GetDocument()- \ >m_datasize + myRect.Width() - 110)); //- myRect.Width()-1)); break; // The part that doesn’t work case SB_THUMBTRACK: case SB_THUMBPOSITION: i_CurPos = nPos ; break; // The part that doesn’t work } SetScrollPos(SB_HORZ, i_CurPos); ScrollWindow(iPrevPos - i_CurPos, 0) ; A

    D 1 Reply Last reply
    0
    • D Daffy d

      Hi there! I’m currently playing with a PICO scope. (it’s a small parallel port oscilloscope that runs at 20KHz max.) I’m trying to make a custom graphical interface showing the results acquired from the scope (was hoping to use it in a dynamometer project I was planning) . This part of the deal runs great. But I wanted to add a horizontal scroll bar to make navigation trough the data easier. So l borrowed from Roger Allens tutorial. On scrollbars (http://www.codeproject.com/miscctrl/Scrollbar.asp) And everything works almost according to plan. Unfortunately I’m using a quite large data buffer. -16 KB to 512 KB. Ant that’s where things get strange. It seems that things behave quite normal when I’m below 32KB. But as soon as I get above 32 KB the scrollbar position returns to 0 and starts counting over - When using “SB_THUMBTRACK” and “SB_THUMBPOSITION” But behaves normal (counts and scrolls all the way up to 512KB) when using all the other “positioning” options (like SB_PAGE & SB_LINE) The problem looks like the variable holding the bar position has a max of 32768 and than turns over to 0. (but only when dragging the bar) That would be a 16 bit signed variable. But the SCROLLINFO.nPos which I use is a int so that shouldn’t be the problem. My code is as I said pulled more or less directly from Rogers tutorial and looks like this : // m_datasize is the size of the collected data 16 KB to 512 KB. int i_CurPos = GetScrollPos(SB_HORZ); int iPrevPos = i_CurPos; CRect myRect; GetClientRect(&myRect); switch(nSBCode) { case SB_LEFT: i_CurPos = 0; break; case SB_RIGHT: i_CurPos = GetDocument()->m_datasize; break; case SB_LINELEFT: i_CurPos = max(i_CurPos -6, 0); break; case SB_LINERIGHT: i_CurPos = min(i_CurPos + 6,(GetDocument()->m_datasize+ myRect.Width() - 110)); break; case SB_PAGELEFT: i_CurPos = max(i_CurPos - myRect.Width(), 0); break; case SB_PAGERIGHT: i_CurPos = min(i_CurPos + myRect.Width(), (GetDocument()- \ >m_datasize + myRect.Width() - 110)); //- myRect.Width()-1)); break; // The part that doesn’t work case SB_THUMBTRACK: case SB_THUMBPOSITION: i_CurPos = nPos ; break; // The part that doesn’t work } SetScrollPos(SB_HORZ, i_CurPos); ScrollWindow(iPrevPos - i_CurPos, 0) ; A

      D Offline
      D Offline
      Daffy d
      wrote on last edited by
      #2

      Sorry I forgot the setup of the scroll bar :-O Its done like this. SCROLLINFO si ; si.cbSize = sizeof(SCROLLINFO) ; si.fMask = SIF_PAGE | SIF_RANGE ; si.nPage = myRect.Width() - 110; // The 110 is because I type measurement related info in a small box there. si.nMax = pDoc->m_datasize + myRect.Width() - 110; si.nMin = 0 ; I hope someone can help. Thanks.

      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