Reputation: 25
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);
}
Upvotes: 2
Views: 5068
Reputation: 16162
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 calling tooltip1.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.
Upvotes: 1