How to disable the Vertical Scroll Bar in a Owner Draw ListCtrl. If I check NoScroll option in the Resource editor the Header Ctrl Vanishes. Whatever may be the size of the ListCtrl I dont want the Scroll Bar.
Thanx
Printable View
How to disable the Vertical Scroll Bar in a Owner Draw ListCtrl. If I check NoScroll option in the Resource editor the Header Ctrl Vanishes. Whatever may be the size of the ListCtrl I dont want the Scroll Bar.
Thanx
Create the listcontrol without the LVS_NOSCROLL style so that the header is drawn and that portion of the CListCtrl is not used for displaying data. Call the following function after creation of the control, after resizing, and after (windows message of system changing ...)
I tried to use this myself. I wanted to remove the horizontal bar and keep the vertical. but the behavour was not what I exspected. The scroll bars are different when displayed this way. There seems to be a few messages that are passed on after the CListCtrl scrolls with the default scroll bars but not when added this way.
If you find a work around please let me know.
void CView_List::PositionHeader()
{
HWND hwndListView = m_MyListCtrl.m_hWnd;
HWND hwndHeader = ::GetWindow(hwndListView, GW_CHILD);
DWORD dwStyle = GetWindowLong(hwndListView, GWL_STYLE);
// To ensure that the first item will be visible, create the control
// without the LVS_NOSCROLL style and then add it here.
dwStyle |= LVS_NOSCROLL | WS_HSCROLL;
SetWindowLong(hwndListView, GWL_STYLE, dwStyle);
// Only do this if the ListView is in report view and you were able to
// get the header hWnd.
if(((dwStyle & LVS_TYPEMASK) == LVS_REPORT) && hwndHeader)
{
RECT rc;
HD_LAYOUT hdLayout;
WINDOWPOS wpos;
::GetClientRect(hwndListView, &rc);
hdLayout.prc = &rc;
hdLayout.pwpos = &wpos;
Header_Layout(hwndHeader, &hdLayout);
::SetWindowPos(hwndHeader,
wpos.hwndInsertAfter,
wpos.x,
wpos.y,
wpos.cx,
wpos.cy,
wpos.flags | SWP_SHOWWINDOW);
ListView_EnsureVisible(hwndListView, 0, FALSE);
}
}