From 394650aae688ff7e280cfeb57856419621da9c65 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 8 Dec 2013 18:14:00 +0000 Subject: [PATCH] VirtualListView - add a public property: VScrollPos, TASListView - track the row index the mouse is currenlty pointing to --- .../CustomControls/TasListView.cs | 9 ++++++++- .../CustomControls/VirtualListView.cs | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs b/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs index f9cc9c5a28..e7cdffa592 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs @@ -30,7 +30,14 @@ namespace BizHawk.Client.EmuHawk } } - // TODO: Get row + var headerHeight = 24; //Are these always true? Don't know, is there a way to programmatically determine them? + var rowHeight = 18; + + PointedRowIndex = ((y - headerHeight) / rowHeight) + this.VScrollPos; + if (PointedRowIndex >= ItemCount) + { + PointedRowIndex = null; + } } protected override void OnMouseLeave(EventArgs e) diff --git a/BizHawk.Client.EmuHawk/CustomControls/VirtualListView.cs b/BizHawk.Client.EmuHawk/CustomControls/VirtualListView.cs index 5cb8a3bc81..194342884e 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/VirtualListView.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/VirtualListView.cs @@ -534,6 +534,17 @@ namespace BizHawk.Client.EmuHawk if (handler != null) handler(this, e); } + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern int GetScrollPos(IntPtr hWnd, System.Windows.Forms.Orientation nBar); + + /// + /// Gets and Sets the Vertical Scroll position of the control. + /// + public int VScrollPos + { + get { return GetScrollPos((IntPtr)this.Handle, System.Windows.Forms.Orientation.Vertical); } + } + protected override void WndProc(ref System.Windows.Forms.Message m) { NMHDR nm1; bool messageProcessed = false; @@ -572,7 +583,7 @@ namespace BizHawk.Client.EmuHawk case (int)WindowsMessage.WM_SCROLL: //http://stackoverflow.com/questions/1851620/handling-scroll-event-on-listview-in-c-sharp - OnScroll(new ScrollEventArgs((ScrollEventType)(m.WParam.ToInt32() & 0xffff), 0)); + OnScroll(new ScrollEventArgs((ScrollEventType)(m.WParam.ToInt32() & 0xffff), m.WParam.ToInt32())); break; //obscure message loop flakiness when exceptions are thrown from the message loop...