Hello.
I know that "HideSelection" property is missing in CF. But i still need to handle situation when an item is selected that it remains selected (greyed) even when the control looses focus.
I have tried using this peace of code, but with no success. I get an exception in GetFocus() method and i dont know what im doing wrong.
Any help is much appreciated !
[DllImport("User32.dll")]
static extern IntPtr GetFocus();
[DllImport("User32.dll")]
static extern Int32 GetWindowLong(IntPtr hwnd, Int32 integer1);
[DllImport("User32.dll")]
static extern IntPtr SetWindowLong(IntPtr hwnd, Int32 integer1, int integer2);
private bool doneOnce;
protected override void OnGotFocus(System.EventArgs e)
{
base.OnGotFocus(e);
if (this.itemsTreeView != null)
{
this.itemsTreeView.Focus();
if (doneOnce == false)
{
doneOnce = true;
IntPtr hWnd = GetFocus();
Int32 lS = GetWindowLong(hWnd, -16);
lS = lS | 0x20;
SetWindowLong(hWnd, -16, lS);
}
}
}
I have put this code in my "code behind" view that holds TreeView control.