Scroll bar question - need experts help here
-
Hi, i am trying to disable the horizontal scroll bar in list ctrl. the scroll doesn't appear until i add a lot of items in the list (it appears because the vertical scroll bar appears as well). here is the code i use void CMyListCtrl::OnStyleChanging(int nStyleType,LPSTYLESTRUCT lpStyleStruct) { if (nStyleType != GWL_STYLE) { CListCtrl::OnStyleChanging(nStyleType,lpStyleStr uct); return; } lpStyleStruct->styleNew &= ~WS_HSCROLL; SetWindowLong(m_hWnd,GWL_STYLE,lpStyleStruct->styleNew); } this indeed change the style of the list not to have WS_HSCROLL bar, but the scroll bar is still shown.... please help me i am really desperate, this is the 4th post i am asking for help thanks Yaron Ask not what the application can do for you, ask what you can do for your application
-
Hi, i am trying to disable the horizontal scroll bar in list ctrl. the scroll doesn't appear until i add a lot of items in the list (it appears because the vertical scroll bar appears as well). here is the code i use void CMyListCtrl::OnStyleChanging(int nStyleType,LPSTYLESTRUCT lpStyleStruct) { if (nStyleType != GWL_STYLE) { CListCtrl::OnStyleChanging(nStyleType,lpStyleStr uct); return; } lpStyleStruct->styleNew &= ~WS_HSCROLL; SetWindowLong(m_hWnd,GWL_STYLE,lpStyleStruct->styleNew); } this indeed change the style of the list not to have WS_HSCROLL bar, but the scroll bar is still shown.... please help me i am really desperate, this is the 4th post i am asking for help thanks Yaron Ask not what the application can do for you, ask what you can do for your application
Are you trying to remove the scrollbar so it doesn't even appear when normally it would, or are you just trying to disable it so that it's shown but the user can't scroll with it? Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
-
Are you trying to remove the scrollbar so it doesn't even appear when normally it would, or are you just trying to disable it so that it's shown but the user can't scroll with it? Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
-
I am trying to to remove the horizontal bar so it won't ever appear.... can u help? thanks Ask not what the application can do for you, ask what you can do for your application
Unfortunately, there is no easy answer. Scrollbars in CListCtrl are drawn and handled internally by the list control, and aren't actually controls by themselves. Thus the only way to disable them is to derive from CListCtrl and write your own drawing routine... not a very fun thing to do. What's the cause of the scroll bar appearing in the first place? If you're trying to forcefully remove it, have you looked at fixing what causes it to appear? Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
-
Hi, i am trying to disable the horizontal scroll bar in list ctrl. the scroll doesn't appear until i add a lot of items in the list (it appears because the vertical scroll bar appears as well). here is the code i use void CMyListCtrl::OnStyleChanging(int nStyleType,LPSTYLESTRUCT lpStyleStruct) { if (nStyleType != GWL_STYLE) { CListCtrl::OnStyleChanging(nStyleType,lpStyleStr uct); return; } lpStyleStruct->styleNew &= ~WS_HSCROLL; SetWindowLong(m_hWnd,GWL_STYLE,lpStyleStruct->styleNew); } this indeed change the style of the list not to have WS_HSCROLL bar, but the scroll bar is still shown.... please help me i am really desperate, this is the 4th post i am asking for help thanks Yaron Ask not what the application can do for you, ask what you can do for your application
I had the same issue. What I ended by doing is resizing the columns when the vertical scroll is added. So instead of hardcoding the width of column, you assign it a percentage of the listctrl's width. Then call this function whenever your listctrl needs a vertical slider. The user can still resize the column with the header control (which could cause a horizontal scrollbar to appear).
void CMyDialogDlg::ResizeColumns(const int iPercentageOfListCtrl)
{
CRect rect;
m_cListCtrl.GetClientRect(rect);
int iNewWidth = (rect.right * iPercentageOfListCtrl / 100);
int iOldWidth = m_cListCtrl.GetColumnWidth(0);
if (iOldWidth != iNewWidth) {
m_cListCtrl.SetColumnWidth(0, iNewWidth); // resize the first column
}
}This will resize the first column enough so that the list ctrl doesn't think it needs a horizontal scroll bar. Hope this helps.
-
I had the same issue. What I ended by doing is resizing the columns when the vertical scroll is added. So instead of hardcoding the width of column, you assign it a percentage of the listctrl's width. Then call this function whenever your listctrl needs a vertical slider. The user can still resize the column with the header control (which could cause a horizontal scrollbar to appear).
void CMyDialogDlg::ResizeColumns(const int iPercentageOfListCtrl)
{
CRect rect;
m_cListCtrl.GetClientRect(rect);
int iNewWidth = (rect.right * iPercentageOfListCtrl / 100);
int iOldWidth = m_cListCtrl.GetColumnWidth(0);
if (iOldWidth != iNewWidth) {
m_cListCtrl.SetColumnWidth(0, iNewWidth); // resize the first column
}
}This will resize the first column enough so that the list ctrl doesn't think it needs a horizontal scroll bar. Hope this helps.