Disable the scroll bar on the Owner tab

I have my own DrawLoader to which I add a lot of elements (and this takes time) when the elements are added, the vertical scroll bar continues to decrease, I want to turn off the scroll bar when I start adding, and then turn it back on.

I tried -

LONG old_style=GetWindowLong(hPlayList,GWL_STYLE); LONG new_style= old_style&~WS_VSCROLL; SetWindowLong(hPlayList,GWL_STYLE,new_style); SetWindowPos(hPlayList,HWND_TOP,lstRc.left,lstRc.right,lstRc.right-lstRc.top,lstRc.bottom-lstRc.top, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); UpdateWindow(hPlayList); 

and

 ShowScrollBar(hPlayList,SB_VERT,FALSE); 

But the scrollbar is still showing, when I add items, the listbox is created as,

 hPlayList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTBOX, NULL, LBS_OWNERDRAWFIXED |WS_VSCROLL | WS_HSCROLL |WS_CHILD | WS_TABSTOP | WS_VISIBLE|LBS_NOTIFY|LBS_HASSTRINGS, lbsPos.x, lbsPos.y,350, 400, hWnd, (HMENU) LIST_ID, GetModuleHandle(NULL), NULL); 

and I use SendMessage () to add items.

I tried too

 ShowWindow(hPlayList,SW_HIDE); 

and

 SendMessage(hPlayList,WM_SETREDRAW,(WPARAM)FALSE,0); 
+4
source share
1 answer

You can use the WM_SETREDRAW message with wParam (fRedraw) set to FALSE before adding rows. when you are done set it to TRUE and UpdateWindow or RedrawWindow .

This message may be useful if the application needs to add multiple items to the list . An application can call this message with wParam set to FALSE, add items, and then call the message again when wParam is set to TRUE. Finally, the application can call RedrawWindow (hWnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN) to cause the list to be redrawn.

+3
source

Source: https://habr.com/ru/post/1402093/


All Articles