Reputation: 143
I have a FlowLayoutPanel with AutoScroll = true I need to detect the movement of the mouse on the scrollbar when the scrollbar is visible.
The MouseMove event of the FlowLayoutPanel does not capture events pertaining to the scrollbar.
Is there any way to hook on to the mouse move of the scrollbar?
Upvotes: 1
Views: 1846
Reputation: 6689
class MyFlowLayoutPanel : FlowLayoutPanel
{
const int WM_NCMOUSEMOVE = 0x00A0;
protected override void WndProc(ref Message m)
{
if( m.Msg == WM_NCMOUSEMOVE )
{
Console.WriteLine("MouseOverScrollbar");
}
base.WndProc(ref m);
}
}
Upvotes: 1
Reputation: 18420
I tried this(in LINQPAD) and looks like when mouse is on scrollbar MouseMoveEvent is not raised.
void Main()
{
Application.Run(new Form2());
}
public class Form2:Form
{
public Form2()
{
Label lbl= new Label();
lbl.Location = new Point(200,40);
this.Controls.Add(lbl);
FlowLayoutPanel fl = new FlowLayoutPanel();fl.AutoScroll =true;
fl.MouseMove += (s,e) => { lbl.Text = e.Location.Y.ToString();};
this.MouseMove += (s,e) => { lbl.Text = e.Location.Y.ToString();};
for(int i=0;i<10;i++){fl.Controls.Add(new Button());}
this.Controls.Add(fl);
}
}
These's ScrollBar.MouseMove event but its not available for direct use by us.
Wait while i see if there is any wokaround
Upvotes: 0