110,534
社区成员
发帖
与我相关
我的任务
分享
new Action(() =>
{
System.Threading.Thread.Sleep(2000);
this.Invoke((Action)delegate { this.panel1.Cursor = System.Windows.Forms.Cursors.Hand; });
}).BeginInvoke(null, null);
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1() { InitializeComponent(); }
async void panel1_MouseDown(object sender, MouseEventArgs e)
{
var mouseUp = false;
MouseEventHandler s = (sender1, e1) => { mouseUp = true; };
panel1.MouseUp += s;
await Task.Delay(2000);
panel1.MouseUp -= s;
if (mouseUp)
{
return;
}
Cursor = Cursors.Hand;
if (e.Button == MouseButtons.Left)
{
MessageBox.Show("mouse down");
}
}
void panel1_MouseClick(object sender, MouseEventArgs e)
{
if (Cursor == Cursors.Hand)
{
return;
}
MessageBox.Show("mouse click");
}
void panel1_MouseUp(object sender, MouseEventArgs e)
{
if (Cursor != Cursors.Hand)
{
return;
}
MessageBox.Show("mouse up");
Cursor = Cursors.Arrow;
}
}
}