开发者

How to capture mouse movements C# form application?

How to capture mouse movements C# form ap开发者_C百科plication?


Here's a snippet:

Point mouseLocation;

public Form1( )
{
    InitializeComponent();

    this.MouseMove += new MouseEventHandler(Form1_MouseMove);
}

void Form1_MouseMove(object sender , MouseEventArgs e)
{
    mouseLocation = e.Location;
}

@AdriannStander gives 3 excellent links for research -- I simply like writing code snippets ;)


This one works for ALL controls within the form. NOT just the form itself!

    ....
InitializeComponent();
        foreach (Control ctrl in this.Controls)
                {
                    ctrl.MouseMove += new MouseEventHandler(globalMouseMove);
                }
    ....

     private void globalMouseMove(object sender, MouseEventArgs e)
            {
                //TODO
            }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜