private void ListView_SubItemHitTest(MouseEventsTypes met) { LVHITTESTINFO lvh = new LVHITTESTINFO(); lvh.pt = PointToClient(Control.MousePosition); IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(lvh)); Marshal.StructureToPtr(lvh, ptr, true); SendMessage(Handle, LVM_SUBITEMHITTEST, IntPtr.Zero, ptr); lvh = (LVHITTESTINFO)Marshal.PtrToStructure(ptr, typeof(LVHITTESTINFO)); Marshal.FreeHGlobal(ptr); // check if the item is valid if ((lvh.iItem >= 0) || (lvh.iSubItem >= 0)) { ItemSubItemClickEventArgs args = new ItemSubItemClickEventArgs(lvh.iItem, lvh.iSubItem, met); this.OnItemSubItemClick(args); } else { this.Cursor = Cursors.Default; } }
private void ListView_SubItemHitTest(MouseEventsTypes met) { LVHITTESTINFO lvh = new LVHITTESTINFO(); lvh.pt = PointToClient(Control.MousePosition); IntPtr ptr = Marshal.AllocHGlobal( Marshal.SizeOf(lvh) ); Marshal.StructureToPtr(lvh, ptr, true); SendMessage(Handle, LVM_SUBITEMHITTEST, IntPtr.Zero, ptr); lvh = (LVHITTESTINFO)Marshal.PtrToStructure(ptr, typeof(LVHITTESTINFO)); Marshal.FreeHGlobal(ptr); // check if the item is valid if ((lvh.iItem >= 0) || (lvh.iSubItem >= 0)) { ItemSubItemClickEventArgs args = new ItemSubItemClickEventArgs(lvh.iItem, lvh.iSubItem, met); this.OnItemSubItemClick(args); } else this.Cursor = Cursors.Default; }