How to "notify" parent window about "scroll event" of child window "list box" control in WIN32 API?

StackOverflow https://stackoverflow.com/questions/18252708

  •  24-06-2022
  •  | 
  •  

Pergunta

How to "notify" the parent window about the "scroll event" of its child window, a "list box" control, each time it is scrolled up or down in WIN32 API?

I am trying to make a dictionary using the WIN32 API. I created a parent window, and then created a child window list box control in it.

I want to add "50 word lists" at a time to the list box control from the database, so that the application does not take time at all during the start up.

And then, I want to keep a track of the "scroll bar position" (the "SCROLLINFO" structure's "nPos" value) of the list box control as the user scrolls up or down the word lists, so that I can call a function that adds 50 more words at the end of the list box when it has been almost scrolled up to the bottom.

In the main window procedure function, inside the "switch" statement I used the "WM_VSCROLL" window message hoping to catch the child window list box control’s scroll event. The child window list box control has "LBS_NOTIFY" style. But all in vain! The list box control’s scroll event is not being notified to its parent window. The parent window also is not doing anything in the "WM_VSCROLL" message for its child window list box control’s scroll event.

Please kindly help me, guide me, show me with code examples how to "notify" the parent window about the "scroll event" of its child window, a "list box" control, each time it is scrolled up or down in WIN32 API.

Foi útil?

Solução

Scrolling messages are only sent to the window that is actually being scrolled, in this case the ListBox. LBS_NOTIFY only applies to a few select messages, which do not include scrolling messages. You would have to subclass the ListBox via either SetWindowLongPtr(GWL_WNDPROC) or SetWindowSubclass() and have your subclass procedure catch the scrolling messages and forward the info to the parent window as needed.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top