Scollbox size and position
-
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
-
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
-
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
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
andUpdateWindow
Hung Son A Vietnamese student i-g.hypermart.net dlhson2001@yahoo.com