Updated to reflect a more functional description of my request.
Functionally I need a read only ComboBox
that does not directly inherit from the System.Windows.Forms.ComboBox
class. I need the text box portion to be read only, so the user can copy out text that was entered into the box but not change it. And this is not a case of using DropDown
vs DropDownList
mode.
Using this article and some experimentation, I have the text box portion taken care of but still need to prevent changes from the drop down component due to technical reasons listed below. I still need one of the following:
- Disable the drop down button on a
ComboBox
- to prevent it from opening - Prevent the drop down from opening in a
ComboBox
when clicked - Prevent the selection of an item from the drop down from changing the selection in the control (possibly by intercepting and ignoring the clicked item notification message)
I'm using the KryptonToolkit for visual prettiness in my application. For the KryptonComboBox
control, it has an internal, extended System.Windows.Forms.ComboBox
class that intercepts the draw calls. It exposes access to the ComboBox
object, so I can get access to it's Handle
.
I'm using the A Complete Read Only ComboBox code as a base to create a read only capable version of the KryptonComboBox
. Instead of using the KryptonComboBox.Handle
in the SendMessage()
calls, you have to use the KryptonComboBox.ComboBox.Handle
to get the actual handle to the Windows control. By doing that I'm able to set the read only mode on the text box part of the ComboBox correctly.
BUT! Since the base class of the extended control is KryptonComboBox
and not ComboBox
, when the WndProc()
is called it's for messages of the KryptonComboBox
. So I am unable to prevent the control from acting (changing the selection) on the clicked drop down item when it is in read only mode.
How do I intercept (and potentially ignore) WM_COMMAND messages from an existing ComboBox control. Specifically I want to have a message 273 chain ignored under certain circumstances. Is there a way to functionally do the same thing to an "external" ComboBox
control that I could from an inherited control? Since I have the Handle
for the ComboBox
, could I use something like SetWindowsHookEx()
to intercept the messages?