How can I handle any of the tree view notifications listed here in a C# class that is derived from the .NET TreeView control?
I tried to handle the click notification, for example, like this:
class ExtendedTreeView : TreeView
{
private const Int32 NM_FIRST = (Int32)(0U - 0U);
private const Int32 NM_CLICK = unchecked((Int32)((UInt32)NM_FIRST - 2U));
protected override void WndProc(ref Message m)
{
if (m.Msg == NM_CLICK)
{
MessageBox.Show("NM_CLICK");
}
base.WndProc(ref m);
}
}
But the message box is never shown. This is the first time I try to use Win32 API to modify the behaviour of a .NET control, so I have no idea what goes wrong.
Is this the correct approach to handle these notifications?
FYI: I know that the .NET TreeView control has a click event. This is just a first test. Later I want to enable the TVS_EX_MULTISELECT
style. Since the .NET TreeView control does not fire any AfterSelect
events when TVS_EX_MULTISELECT
is enabled, I want to investigate the behaviour of the TVN_SELCHANGED
and TVN_ITEMCHANGED
notifications later.