Question

I am writing a fairly simple wrapper around Win32 controls/dialogs/windows.

The issue I have is that ListBox's and ComboBox's seem to behave rather differently.

In the base Widget class that I am inheriting from, I override the existing WNDPROC for the control and then handle messages in the new WNDPROC, primarily promoting them to boost::signal events.

The issue is that, while ComboBox's WndProc receives the CBN_SELCHANGE - as expected - ListBox's WndProc does not receive the LBN_SELCHANGE command.

I realize that the dialog/window that owns the control will likely receive this, but I've kind of gone down this rabbit hole already and it feels like a pretty neat solution. Need I back out and have the owners of the controls handle the WM_COMMAND messages (and from there promote it to an event on the control itself).

This is a learning exercise, so please don't remind me about MFC or comment on the value of doing this.

Was it helpful?

Solution

Notification messages are typically sent to a control's parent. Presumably all the windows (i.e. both parent windows and controls) are using the same window procedure? In this case the usual solution is: in the notification handler in your window procedure check if the notification came from the current window. If it did, raise an event; if it didn't resend the message back to the control it came from (where it will be raised as an event).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top