VirtualListView - add a public property: VScrollPos, TASListView - track the row index the mouse is currenlty pointing to

This commit is contained in:
adelikat 2013-12-08 18:14:00 +00:00
parent 37852c3e63
commit 394650aae6
2 changed files with 20 additions and 2 deletions

View File

@ -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)

View File

@ -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);
/// <summary>
/// Gets and Sets the Vertical Scroll position of the control.
/// </summary>
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...