private void HandleClick(Point pt, Keys modifierKeys) { IShellItem item = null; try { TVHITTESTINFO structure = new TVHITTESTINFO { pt = pt }; IntPtr wParam = PInvoke.SendMessage(treeController.Handle, 0x1111, IntPtr.Zero, ref structure); if (wParam != IntPtr.Zero) { if ((structure.flags & 0x10) == 0 && (structure.flags & 0x80) == 0) { treeControl.HitTest(pt, out item); if (item != null) { IntPtr pidl; if (PInvoke.SHGetIDListFromObject(item, out pidl) == 0) { using (IDLWrapper wrapper = new IDLWrapper(pidl)) { TreeViewMiddleClicked(wrapper, modifierKeys); } } } } } } finally { if (item != null) { Marshal.ReleaseComObject(item); } } }
private void HandleClick(Point pt) { IShellItem item = null; IntPtr ptr = IntPtr.Zero; try { TVHITTESTINFO structure = new TVHITTESTINFO { pt = pt }; ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, ptr, false); IntPtr wParam = PInvoke.SendMessage(treeController.Handle, 0x1111, IntPtr.Zero, ptr); if (wParam != IntPtr.Zero) { structure = (TVHITTESTINFO)Marshal.PtrToStructure(ptr, typeof(TVHITTESTINFO)); if ((structure.flags & 0x10) == 0 && (structure.flags & 0x80) == 0) { treeControl.HitTest(pt, out item); if (item != null) { TreeViewMiddleClicked(item); } } } } finally { if (item != null) { Marshal.ReleaseComObject(item); } if (ptr != IntPtr.Zero) { Marshal.FreeHGlobal(ptr); } } }