Now I know we've done this before for edit controls etc... but what about this combo box.
This is Fasecero's example of a combo box created by using the CreateWindowExW command, and in this example the whole window is sub classed.
That's great for the combo box, but not for the button controls, they become "unresponsive" to a click.
Now I understand why, and I can work around it by changing the sub routine "subclassProc" and add in a
CASE MyButton section which makes the buttons work again.
But what if you have a lot of buttons, and each button has a lot of code?
if, in the section "OnInit" we comment out SetWindowSubclass(w1.hwnd, &subclassProc, subclassID, COMBO_1)
the button works again, but we cannot detect which combo box item is selected.
So how do we change this example to only sub class the combo box?
BTW I named the example "close" for no real reason.
It's a tongue twister but I will try to explain it. subclassProc was bad designed. It's a mistake I can't stop doing it again and again. subclassProc is always called before w1_handler, and the message from the button is not forwarded to w1_handler bacause DefSubclassProc is never called
Fixed subclass procedure
CASE CBN_SELCHANGE ' the user has selected another index
RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
Also, the last parameter of SetWindowSubclass does not need to be COMBO_1 and you can pass a 0.
SetWindowSubclass(w1.hwnd, &subclassProc, subclassID, 0)
Works for me! Well done again, Fasecero
Yes, thanks Fasecro!
Just tried it this morning and works great.
I thought I would spend some time documenting / explaining Fasecero's Unicode combo box example.
Hopefully as you read through the code, it will help you understand better what is being done here and why.
Read the code first, then compile / run, and select a couple of items from the combo box, finally close the program.
You can then read the text file 1.txt (in the same folder) which should show you how a combo box works.
Going through the code like this helped me to understand it better - hope it helps someone too!