I need to find a way to check if the mouse moves in c#, while the left button is down.
我需要找到一种方法来检查鼠标是否在c#中移动,而左键是否已关闭。
1 个解决方案
#1
22
Here's an example (WPF):
这是一个例子(WPF):
public MainWindow()
{
InitializeComponent();
this.MouseMove += new MouseEventHandler(MainWindow_MouseMove);
}
void MainWindow_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
//do something
}
}
#1
22
Here's an example (WPF):
这是一个例子(WPF):
public MainWindow()
{
InitializeComponent();
this.MouseMove += new MouseEventHandler(MainWindow_MouseMove);
}
void MainWindow_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
//do something
}
}