F
Frank Rizzo
I have a Combo Box, with DropDownStyle=DropDownList. I have a
requirement that a user not be able to click certain items in the
dropdown, e.g. the dropped part of the combo box should act like nothing
happened.
To that end, I inherited the from IMessageFilter interface and
implemented PreFilterMessage method to look at messages. The plan was
simple:
1. check to make sure that the message has the same Hwnd as that of the
combo box
2. Catch the WM_LBUTTONDOWN event and if the mouse if over the
forbidden item, return true (e.g. ignore the event).
Except that I ran into an unexpected problem. The dropped down portion
of the combobox has a different Hwnd.
The documentation (
http://msdn.microsoft.com/library/d...oxreference/comboboxmessages/cbn_dropdown.asp
) states that a message CBN_DROPDOWN is sent down with the WM_COMMAND.
For whatever reason, this data does not come down via the
IMessageFilter.PreFilterMessage method. It does come down via the
overridden WndProc method.
However, the WndProc method does not seem to catch the WM_LBUTTONDOWN
event for the dropped portion of the combobox. The
IMessageFilter.PreFilterMessage does catch that message, but only if I
don't override the Form's WndProc method.
So I am caught between a rock and a hard place. Why do these methods
catch only selected messages? Am I missing something simple here?
Thanks.
requirement that a user not be able to click certain items in the
dropdown, e.g. the dropped part of the combo box should act like nothing
happened.
To that end, I inherited the from IMessageFilter interface and
implemented PreFilterMessage method to look at messages. The plan was
simple:
1. check to make sure that the message has the same Hwnd as that of the
combo box
2. Catch the WM_LBUTTONDOWN event and if the mouse if over the
forbidden item, return true (e.g. ignore the event).
Except that I ran into an unexpected problem. The dropped down portion
of the combobox has a different Hwnd.
The documentation (
http://msdn.microsoft.com/library/d...oxreference/comboboxmessages/cbn_dropdown.asp
) states that a message CBN_DROPDOWN is sent down with the WM_COMMAND.
For whatever reason, this data does not come down via the
IMessageFilter.PreFilterMessage method. It does come down via the
overridden WndProc method.
However, the WndProc method does not seem to catch the WM_LBUTTONDOWN
event for the dropped portion of the combobox. The
IMessageFilter.PreFilterMessage does catch that message, but only if I
don't override the Form's WndProc method.
So I am caught between a rock and a hard place. Why do these methods
catch only selected messages? Am I missing something simple here?
Thanks.