//隐藏toolTip
if (this.IsHandleCreated)
{
this.BeginInvoke(new MethodInvoker(() =>
{
if (this.IsHandleCreated && !this.IsDisposed)
{
if (this.toolTip1.Active)
{
this.toolTip1.Hide(this);
}
}
}));
}
if (e.PropertyName == "TooltipText") //tooltipText改变事件
{
string tooltipText = this.webView.TooltipText;
Point elementPos = new Point(Cursor.Position.X - this.Location.X, Cursor.Position.Y - this.Location.Y);
if (!String.IsNullOrEmpty(tooltipText))
{
this.Invoke(new MethodInvoker(() =>
{
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
timer.Interval = 600;
timer.Tick += (timer_sender, timer_e) =>
{
Point nowPos = new Point(Cursor.Position.X - this.Location.X, Cursor.Position.Y - this.Location.Y);
//if ((nowPos.X <= elementPos.X + 20 && nowPos.X >= elementPos.X - 20) && (nowPos.Y <= elementPos.Y + 20 && nowPos.Y >= elementPos.Y - 20)) //鼠标停留了500ms(范围限定在一定范围)
if (this.webView.TooltipText == tooltipText) //600毫秒后,tooltipText没变
{
this.toolTip1.Show(tooltipText, this, nowPos.X + 15, nowPos.Y + 15);
}
(timer_sender as System.Windows.Forms.Timer).Stop();
(timer_sender as System.Windows.Forms.Timer).Dispose();
};
timer.Start();
}));
}
}