工具提示闪烁。
我有一个音频文件的波形。在波形结束时,我想在顶部提示中波形结束前 50 像素的区域中显示一些文本。我希望工具提示仅显示在从波形结束前 50 个像素到波形结束的区域中。我已经编写了一些代码,但它会导致工具提示闪烁,即当我移动鼠标时,工具提示不断出现。请帮助停止闪烁。 代码是:
private void Waveform_MouseMove(object sender, MouseEventArgs e)
{
bool IsMatching = false;
ToolTip tooltip1 = new ToolTip();
if (e.X <= this.Width && e.X >= this.Width - 50)
{
tooltip1.Show("end here", this, e.X, e.Y);
IsMatching = true;
}
if(!IsMatching)
tooltip1.Hide(this);
}
I have a waveform of an audio file. At the end of the waveform I want to display some text in the area 50 pixels before the end of the waveform, in the tooptip. I want the tooltip to be shown only in the area which lies from 50 pixels before the end of waveform to the end of the waveform. I have written some code but it causes the flickering of the tooltip i.e. as and when i move the mouse the tooltip keeps appearing. Please help to stop the flickering.
The code is:
private void Waveform_MouseMove(object sender, MouseEventArgs e)
{
bool IsMatching = false;
ToolTip tooltip1 = new ToolTip();
if (e.X <= this.Width && e.X >= this.Width - 50)
{
tooltip1.Show("end here", this, e.X, e.Y);
IsMatching = true;
}
if(!IsMatching)
tooltip1.Hide(this);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在表单中声明
tooltip1
,而不是每次鼠标移动时都创建一个新实例,也可以在每次调用tooltip1.Hide()
时创建一个新实例没有隐藏旧的工具提示,您正在隐藏新创建的工具提示“已经未显示......”。另请考虑将表单 DoubleBuffer 设置为
true
,它用于减少闪烁。Declare the
tooltip1
at the form instead of creating a new instance whenever mouse move, also when you create a new instance every time, when you are callingtooltip1.Hide()
you are not hiding the old tool tip, you are hiding the newly created one "which is already not shown..".Also consider setting the form DoubleBuffer to
true
, it is used to reduce the flicker.