110,533
社区成员
发帖
与我相关
我的任务
分享
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool isInRect = false;
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.X > 3 && e.X < 20 && e.Y > 3 && e.Y < 20)
{
Cursor = Cursors.Hand;
isInRect = true;
}
else
{
isInRect = false;
Cursor = Cursors.Default;
}
}
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
if (isInRect && e.Button == MouseButtons.Left)
{
MessageBox.Show("click in rect.");
}
}
}