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. List view and scroll bar

List view and scroll bar

Scheduled Pinned Locked Moved C / C++ / MFC
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
    Anonymous
    wrote on last edited by
    #1

    Hello, I have a list view, and at run time I want to know if the horizontal scroll bar is visible. I would also like to get the height of the horizontal scrollbar. Thanks

    P 1 Reply Last reply
    0
    • A Anonymous

      Hello, I have a list view, and at run time I want to know if the horizontal scroll bar is visible. I would also like to get the height of the horizontal scrollbar. Thanks

      P Offline
      P Offline
      Peter Occil
      wrote on last edited by
      #2

      Hello, I have a list view, and at run time I want to know if the horizontal scroll bar is visible. This is not so easy. Try this function.

      // IsScrollBarVisible returns the show state of a
      // scroll bar (TRUE if visible, FALSE if hidden)
      // Params:
      // HWND hwnd - window with scrollbar
      // UINT fnBar - which scrollbar (SB_HORZ-horizontal,
      // SB_VERT-vertical, SB_CTL-scrollbar control)
      BOOL IsScrollBarVisible(HWND hwnd, UINT fnBar){
      SCROLLINFO si;
      if(fnBar==SB_CTL)
      return IsWindowVisible(hwnd);
      si.cbSize=sizeof(SCROLLINFO);
      si.fMask=SIF_PAGE|SIF_RANGE;
      GetScrollInfo(hwnd,fnBar,&si);
      if(si.nMin==si.nMax)
      return FALSE;
      if(si.nMin>si.nMax)
      return FALSE;
      if(si.nPage>=(si.nMax-si.nMin))
      return FALSE;
      return TRUE;
      }

      Call IsScrollBarVisible(hwndListView,SB_HORZ) to check if the horizontal scrollbar is visible. Written only a few minutes ago, untested, so beware. I would also like to get the height of the horizontal scrollbar. This, by comparison, is easy. Simply call

      GetSystemMetrics(SM_CYHSCROLL)

      . Peter O.

      A 1 Reply Last reply
      0
      • P Peter Occil

        Hello, I have a list view, and at run time I want to know if the horizontal scroll bar is visible. This is not so easy. Try this function.

        // IsScrollBarVisible returns the show state of a
        // scroll bar (TRUE if visible, FALSE if hidden)
        // Params:
        // HWND hwnd - window with scrollbar
        // UINT fnBar - which scrollbar (SB_HORZ-horizontal,
        // SB_VERT-vertical, SB_CTL-scrollbar control)
        BOOL IsScrollBarVisible(HWND hwnd, UINT fnBar){
        SCROLLINFO si;
        if(fnBar==SB_CTL)
        return IsWindowVisible(hwnd);
        si.cbSize=sizeof(SCROLLINFO);
        si.fMask=SIF_PAGE|SIF_RANGE;
        GetScrollInfo(hwnd,fnBar,&si);
        if(si.nMin==si.nMax)
        return FALSE;
        if(si.nMin>si.nMax)
        return FALSE;
        if(si.nPage>=(si.nMax-si.nMin))
        return FALSE;
        return TRUE;
        }

        Call IsScrollBarVisible(hwndListView,SB_HORZ) to check if the horizontal scrollbar is visible. Written only a few minutes ago, untested, so beware. I would also like to get the height of the horizontal scrollbar. This, by comparison, is easy. Simply call

        GetSystemMetrics(SM_CYHSCROLL)

        . Peter O.

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

        Thanks, works great!

        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