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