【向高手求解】 弄了半天,如何解决这种ToolTip闪烁问题?

Cherishny 2009-02-19 04:01:22

// List<RectangleF> lr ……Picture MoseMove 事件中
for (int i = 0; i < lr.Count; i++)
{
if (lr[i].Contains(e.Location))
{
//toolTip.IsBalloon = true;
//toolTip.ToolTipIcon = ToolTipIcon.Info;
toolTip.ForeColor = Color.Red;
//toolTip.ToolTipTitle = "详细信息";
toolTip.Show("【标准工时】: " + dic[i].RefDuration + "秒\n【平均工时】: " + dic[i].Practicetime / dic[i].Finishcount + "秒\n【日期】: " + Convert.ToDateTime(dic[i].BrushDate).ToShortDateString(), pic, e.X - pic.Location.X + 10, e.Y - pic.Location.Y + 10, 10000);
this.labMemo.Text = "【工号】:" + empcode + "\n【日期】:" + Convert.ToDateTime(dic[i].BrushDate).ToShortDateString() + "\n【个人达成率】:" + Math.Round(dic[i].RefDuration / (dic[i].Practicetime / dic[i].Finishcount), 2) * 100 + "%";
break; }
else
{
toolTip.Hide(pic);
}
}

这样不闪烁

//toolTip.IsBalloon = true;
//toolTip.ToolTipIcon = ToolTipIcon.Info;
加这两句就不停闪

去掉
 
break;
else
{
toolTip.Hide(pic);
}

也闪

请问高手们原理是什么造成的?


...全文
2303 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
蜘蛛网咖 2010-01-14
  • 打赏
  • 举报
回复
设置一个外部变量,如果内容不变,就不要show了。
bool isref = false;
int messageindex = -1;
private void TextArea_MouseMove(object sender, MouseEventArgs e)
{
isref = false;
int index = 0;
int Top = 0;
int Left = 0;
TextArea editorarea = (TextArea)sender;
TextEditorControl editor = editorarea.MotherTextEditorControl;
try
{
List<KeyWordInfo> keyposList = TempService.FindKeyword(editor.Text, "$");
if (keyposList != null)
{
foreach (KeyWordInfo keypos in keyposList)
{
SetTextEditorRectangle(keypos, editor);
Point visPoint = editor.ActiveTextAreaControl.TextArea.VirtualTop;
Rectangle sjrect = new Rectangle(keypos.rect.Left - visPoint.X * 8, keypos.rect.Top - visPoint.Y,
keypos.rect.Width, keypos.rect.Height);
if ((Cursor.Position.X >= sjrect.Left) && (Cursor.Position.X <= sjrect.Right)
&& (Cursor.Position.Y >= sjrect.Top) && (Cursor.Position.Y <= sjrect.Bottom))
{
Point p0 = new Point(0, 0);
index = GetEnumNo(keypos.KeyWordName);
Top = sjrect.Bottom + 2;
Left = sjrect.Left + 5;
isref = true;
break;
}
}
}
if (!isref)
{
notesTip1.Hide(this);
messageindex = -1;
}
else
{
if (messageindex != index)
{
messageindex = index;
notesTip1.Show(KeyWordNotes.Notes[index], this, Left, Top);
}

}
}
catch
{

}
}
Cherishny 2009-02-24
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 hbxtlhx 的回复:]
你可以类似于这样处理啊:

C# code
protected override void OnMouseMove(MouseEventArgs e)
{
Rectangle rect = new Rectangle(20, 20, 100, 100);
if (rect.Contains(e.Location))
{
this.toolTip1.SetToolTip(this, "tooltip");
}
else
{
this.toolTip1.SetToolTip(this, null);
}
base.OnMouseMove(e);
}
[/Quote]
我要在一系列的rect 中显示tip
单个的肯定没问题
关键就是 那个循环
Cherishny 2009-02-20
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 hake303 的回复:]
通过捕获鼠标事件来决定显不显示不行吗?
[/Quote]
我就是 通过鼠标事件 决定是否显示的
定义一系列的区域,鼠标所在的点在给定区域就显示 不在就不显示
hake303 2009-02-20
  • 打赏
  • 举报
回复
通过捕获鼠标事件来决定显不显示不行吗?
david_anwei 2009-02-20
  • 打赏
  • 举报
回复
呵呵 前段时间还想做这种应用呢 !
Cherishny 2009-02-20
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 homejiji 的回复:]
是不是show方法的问题?
tooltip我一般用toolTip.SetToolTip来设置切换显示的内容。。
设置延迟时间。。
toolTip.AutoPopDelay = 5000;
toolTip.ShowAlways = false;
。。。
[/Quote]
谢谢你!

这种我试过了 鼠标离开不会马上就消失 会停留一段时间 不是我要的效果

我要鼠标只有在特定区域才显示 信息 超出后马上消失
Cherishny 2009-02-20
  • 打赏
  • 举报
回复

就是这种
Cherishny 2009-02-20
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 hbxtlhx 的回复:]
代码这样写的意图是什么,想达到什么样的效果?
[/Quote]
我是做统计图的时候 做了一个控件
鼠标放在 柱状图上 显示它的一些相关信息
北京的雾霾天 2009-02-20
  • 打赏
  • 举报
回复
代码这样写的意图是什么,想达到什么样的效果?

readfuture 2009-02-20
  • 打赏
  • 举报
回复
没遇到过,友情帮顶
homejiji 2009-02-20
  • 打赏
  • 举报
回复
是不是show方法的问题?
tooltip我一般用toolTip.SetToolTip来设置切换显示的内容。。
设置延迟时间。。
toolTip.AutoPopDelay = 5000;
toolTip.ShowAlways = false;
。。。
Cherishny 2009-02-20
  • 打赏
  • 举报
回复
没人弄过吗……
xhueducls 2009-02-20
  • 打赏
  • 举报
回复
确实会出现这个问题,即使鼠标不动也会不停的闪烁,搞不懂
skison 2009-02-20
  • 打赏
  • 举报
回复
最好是记录上次的状态(比如isShowing,lastShowingText) 比较2次状态有无改变,都是在球里面就别动tooltips ,有change再动
skison 2009-02-20
  • 打赏
  • 举报
回复
鼠标移动一次,就Set一次形状和图标,这没必要,set时就在重绘制了。text也是 先判断有改变没
就算有变化也要先判断是否相同,类似在很多属性器set中也是,set时先判断是否相同,特别是对于图片等大数据东西
北京的雾霾天 2009-02-20
  • 打赏
  • 举报
回复
你可以类似于这样处理啊:

protected override void OnMouseMove(MouseEventArgs e)
{
Rectangle rect = new Rectangle(20, 20, 100, 100);
if (rect.Contains(e.Location))
{
this.toolTip1.SetToolTip(this, "tooltip");
}
else
{
this.toolTip1.SetToolTip(this, null);
}
base.OnMouseMove(e);
}
liangjing851212 2009-02-19
  • 打赏
  • 举报
回复
路过,没弄过这。。。
Cherishny 2009-02-19
  • 打赏
  • 举报
回复
再加一点 在自己的机子上不闪的情况,同事机子上有的不闪有的闪
很郁闷
Cherishny 2009-02-19
  • 打赏
  • 举报
回复
怎么没人 遇到过吗?
simen_frankly 2009-02-19
  • 打赏
  • 举报
回复
帮顶,学习了~~

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧