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. Scollbox size and position

Scollbox size and position

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsshelp
3 Posts 3 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.
  • I Offline
    I Offline
    insanely420
    wrote on last edited by
    #1

    Greetings... I have a custom control similar to a grid and I am using only Win32 techniques. It has two scrollbars - horizontal and vertical on top and bottom. When I have more rows to show then the client area I show make my vertical scrollbar visible using ShowWindow function with SW_SHOW flag. I am using the following method to set the size of scroll box of the vertical scroll bar. #define CUST_DEFHIEGHT 25 // the defaul height of each row in the window. #define CUST_DEFWIDTH 50 // the default width of wach column in the window. int nRowNotVis; // how many rows are not visible. SCROLLINFO scf; // Get the total client rect of the window. GetClientRect ( hwnd, &rectWin ); // where hwnd is my custom control. // Then I calculate how many rows are not being shown. nRowNotVis = (INT)((row * CUST_DEFHIEGHT) - (rectWin.bottom-(2*CUST_DEFHIEGHT)))/CUST_DEFHIEGHT; // where row is the total number of rows my Grid has. // I have left 1 row space in the top and bottom each coz I need them for other purpose. // Then I use the following code to set the info abdout the scrollbar. scf.cbSize = sizeof ( SCROLLINFO ); scf.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; scf.nPage = row-nRowNotVis; scf.nMin = 0; scf.nMax = nRowNowVis+1; scf.nPos = 0; SendMessage ( hwndVScroll, SBM_SETSCROLLINFO, (WPARAM)FALSE, (LPARAM)&scf ); // Doing this does not change the size of the scroll box in the scroll bar and // the size remains the same as the scrollbar. What is going wrong ? The same thing happens when I use set the value of the Horizontal scrollbar // now for the horizontal scroll bar. scf.cbSize = sizeof ( SCROLLINFO ); scf.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; scf.nPage = col-nCol; scf.nMin = 0; scf.nMax = nCol+1; scf.nPos = 0; Where nCol is the number of columns not shown in the Window and col is the number of column in the window ? Please help me ? I am able to scroll the contents in the window properly but my scrollbox size is not getting effected so I am not able to position it properly also. Thanks in advance. Ritesh Nadhani

    M D 2 Replies Last reply
    0
    • I insanely420

      Greetings... I have a custom control similar to a grid and I am using only Win32 techniques. It has two scrollbars - horizontal and vertical on top and bottom. When I have more rows to show then the client area I show make my vertical scrollbar visible using ShowWindow function with SW_SHOW flag. I am using the following method to set the size of scroll box of the vertical scroll bar. #define CUST_DEFHIEGHT 25 // the defaul height of each row in the window. #define CUST_DEFWIDTH 50 // the default width of wach column in the window. int nRowNotVis; // how many rows are not visible. SCROLLINFO scf; // Get the total client rect of the window. GetClientRect ( hwnd, &rectWin ); // where hwnd is my custom control. // Then I calculate how many rows are not being shown. nRowNotVis = (INT)((row * CUST_DEFHIEGHT) - (rectWin.bottom-(2*CUST_DEFHIEGHT)))/CUST_DEFHIEGHT; // where row is the total number of rows my Grid has. // I have left 1 row space in the top and bottom each coz I need them for other purpose. // Then I use the following code to set the info abdout the scrollbar. scf.cbSize = sizeof ( SCROLLINFO ); scf.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; scf.nPage = row-nRowNotVis; scf.nMin = 0; scf.nMax = nRowNowVis+1; scf.nPos = 0; SendMessage ( hwndVScroll, SBM_SETSCROLLINFO, (WPARAM)FALSE, (LPARAM)&scf ); // Doing this does not change the size of the scroll box in the scroll bar and // the size remains the same as the scrollbar. What is going wrong ? The same thing happens when I use set the value of the Horizontal scrollbar // now for the horizontal scroll bar. scf.cbSize = sizeof ( SCROLLINFO ); scf.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; scf.nPage = col-nCol; scf.nMin = 0; scf.nMax = nCol+1; scf.nPos = 0; Where nCol is the number of columns not shown in the Window and col is the number of column in the window ? Please help me ? I am able to scroll the contents in the window properly but my scrollbox size is not getting effected so I am not able to position it properly also. Thanks in advance. Ritesh Nadhani

      M Offline
      M Offline
      mishgun
      wrote on last edited by
      #2

      After changing internal scrollbar parameters (nMin, nMax, nPage) you should use MoveWindow, SetWindowPos etc. to set correct position and size of scrollbars nobody is perfect

      1 Reply Last reply
      0
      • I insanely420

        Greetings... I have a custom control similar to a grid and I am using only Win32 techniques. It has two scrollbars - horizontal and vertical on top and bottom. When I have more rows to show then the client area I show make my vertical scrollbar visible using ShowWindow function with SW_SHOW flag. I am using the following method to set the size of scroll box of the vertical scroll bar. #define CUST_DEFHIEGHT 25 // the defaul height of each row in the window. #define CUST_DEFWIDTH 50 // the default width of wach column in the window. int nRowNotVis; // how many rows are not visible. SCROLLINFO scf; // Get the total client rect of the window. GetClientRect ( hwnd, &rectWin ); // where hwnd is my custom control. // Then I calculate how many rows are not being shown. nRowNotVis = (INT)((row * CUST_DEFHIEGHT) - (rectWin.bottom-(2*CUST_DEFHIEGHT)))/CUST_DEFHIEGHT; // where row is the total number of rows my Grid has. // I have left 1 row space in the top and bottom each coz I need them for other purpose. // Then I use the following code to set the info abdout the scrollbar. scf.cbSize = sizeof ( SCROLLINFO ); scf.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; scf.nPage = row-nRowNotVis; scf.nMin = 0; scf.nMax = nRowNowVis+1; scf.nPos = 0; SendMessage ( hwndVScroll, SBM_SETSCROLLINFO, (WPARAM)FALSE, (LPARAM)&scf ); // Doing this does not change the size of the scroll box in the scroll bar and // the size remains the same as the scrollbar. What is going wrong ? The same thing happens when I use set the value of the Horizontal scrollbar // now for the horizontal scroll bar. scf.cbSize = sizeof ( SCROLLINFO ); scf.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; scf.nPage = col-nCol; scf.nMin = 0; scf.nMax = nCol+1; scf.nPos = 0; Where nCol is the number of columns not shown in the Window and col is the number of column in the window ? Please help me ? I am able to scroll the contents in the window properly but my scrollbox size is not getting effected so I am not able to position it properly also. Thanks in advance. Ritesh Nadhani

        D Offline
        D Offline
        dlhson
        wrote on last edited by
        #3

        1.You don't need to use SendMessage because this's your program and your thread. Only use SetScrollRange, SetScrollPos... 2.I guess that you forgot to call RedrawWindow and UpdateWindow Hung Son A Vietnamese student i-g.hypermart.net dlhson2001@yahoo.com

        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