I had a great help with understanding how to correctly create controls (particularly, ListBox) in VBA with WinAPI. So, according to the structure, how VBA handles windows, we have three handles:
hWin
- UserForm's handlehClient
- UserForm child's handle (Server)hList
- ListBox's handle
The question is - how to listen to Windows messages, incoming from Windows and generated by ListBox?
To listen to the messages, override the function that processes messages sent to a window, which is in this case
hClient
.To listen to a change of selection in
UserForm1
:and in a module: