Re: Tooltips and MouseMove event
Peter Osucha <[email protected]> Mon, 9 Jul 2007 11:31:16 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <[email protected]> |
Following up one more... =20
It seems that the MouseMove() fires in response to whatever underlies
the ToolTip object at intervals equal to the AutoPopDelay.
So if I have the AutoPopDelay set to 3000 (3 seconds), then every 3
seconds (and its pretty darn exact occurring at 3000000 ticks every
time), the MouseMove() event fires for the object holding the Tooltip.
In my project, I am determining info about what to display as the
tooltip text based on the MouseMove() event - end result is that the
ToolTip never goes away (the AutoPopDelay interval after which the
tooltip is supposed to go away causes the MouseMove() event to fire
which in turn sets the tooltip text again).
Can anyone think of a way around this problem? I thought I'd just look
for an event of the ToolTip object to set a flag in - one that occurs
before it causes the MouseMove() event to fire. However, there doesn't
seem to be an event to use (the PopUp event always fires before showing
the tooltip so I can't use that).
Peter
If anyone is bored to death and wants to play with this, below is the
code (drop a panel control on a form, use the code below for the form,
and add the small class called TestGraphic whose code is also below...
--------using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication5
{
public partial class Form1 : Form
{
ToolTip _tt =3D new ToolTip ( );
TestGraphic _tg;
TestGraphic _tg2;
TimeSpan _ts =3D new TimeSpan();
long _ticks;
public Form1 ( )
{
InitializeComponent ( );
_tt =3D new ToolTip ( );
_tt.ShowAlways =3D false;
_tt.Active =3D true;
_tt.AutomaticDelay =3D 500;
_tt.AutoPopDelay =3D 4000;
_tt.BackColor =3D Color.LightBlue;
_tt.InitialDelay =3D 500;
_tt.ReshowDelay =3D 500;
_tt.Popup +=3D new PopupEventHandler ( _tt_Popup );
_tt.Draw +=3D new DrawToolTipEventHandler ( _tt_Draw );
_tg =3D new TestGraphic ( panel1 );
}
void _tt_Draw ( object sender, DrawToolTipEventArgs e )
{
Console.WriteLine("Drawing...");
}
void _tt_Popup ( object sender, PopupEventArgs e )
{
Console.WriteLine ( "About to Popup..." +
DateTime.Now.Ticks.ToString ( ) );
}
private void panel1_MouseMove ( object sender, MouseEventArgs e
)
{
Console.WriteLine ( "MouseMove..." );
string ttt =3D string.Empty;
long nowTicks =3D DateTime.Now.Ticks;
_ts =3D new TimeSpan ( nowTicks - _ticks );
ttt =3D string.Format ( "NowTicks: {0}, PrevTicks: {1}, =
Diff:
{2}", nowTicks, _ticks, nowTicks - _ticks );
if ( nowTicks !=3D _ticks )
{
_tt.SetToolTip ( panel1, ttt );
}
_ticks =3D nowTicks;
}
}
}
------------------------ Test graphic class
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace WindowsApplication5
{
class TestGraphic=20
{
private Control _canvas;
public TestGraphic ( Control canvas )
{
_canvas =3D canvas;
_canvas.Paint +=3Dnew PaintEventHandler(_canvas_Paint);
}
private void _canvas_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawEllipse ( new Pen ( Brushes.Black ), new
Rectangle ( 50, 50, 150, 80 ) );
}
}
}
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This list is hosted by DevelopMentor=AE http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com