Article | 60000357 |
Type | HowTo |
Product | Engine |
Version | 6 |
Date Added | 12/18/2007 12:00:00 AM |
Fixed | (12/19/2007 12:00:00 AM) |
Submitted by | Florian Rappel |
Summary
We use the VDraw tooltips for some drawing objects in our software. Today the tooltip were displayed exactly in the moment when the cursor moves over an object. Is it possible to set a delay (for example 2 seconds) before the tooltip were displayed?
Solution
This can be achieved with code within your application as the sample shown below. You will need a Timer which will be started on the MouseMove event and on the timer code there will be a code that will show the tooltip. This way the tooltip will be shown after the timeinterval that is set to the timer and the mouse is not moving over the entity.
//On Form Load we initialize the events.
//Note that EnableTooltips is set to False!!!!!
private
{
//........
vdFramedControl.BaseControl.MouseMove += new MouseEventHandler(BaseControl_MouseMove);
mTimer.Interval = 5000;
mTimer.Tick += new EventHandler(mTimer_Tick);
vdFramedControl.BaseControl.ActiveDocument.EnableToolTips = false;
mTimer.Start();
}
//On mouse move we constantly reset the timer
void BaseControl_MouseMove(object sender, MouseEventArgs e)
{
mTimer.Stop();
mTimer.Start();
}
//On the timer's code we write the following in order to show the tooltip
void mTimer_Tick(object sender, EventArgs e)
{
if (!vdFramedControl.BaseControl.Visible) return;
if (vdFramedControl.BaseControl.ActiveDocument.ActiveLayOut.OverAllActiveActions.Count > 1) return;
VectorDraw.Actions.BaseAction action = vdFramedControl.BaseControl.ActiveDocument.ActiveLayOut.OverAllActiveAction;
if (!action.IsVisible) return;
vdFramedControl.BaseControl.ActiveDocument.EnableToolTips = true;
//This will show the tooltip if there is any!!!!
action.MouseMove(new MouseEventArgs(MouseButtons.None, 0, action.GdiMouseLocation.X, action.GdiMouseLocation.Y, 0), action.MouseLocation, action.OrthoPoint);
vdFramedControl.BaseControl.ActiveDocument.EnableToolTips = false;
}
//Don't forget to do the finalizations at the closing of the application
protected override void OnClosing(CancelEventArgs e)
{
mTimer.Tick -= new EventHandler(mTimer_Tick);
vdFramedControl.BaseControl.MouseMove -= new MouseEventHandler(BaseControl_MouseMove);
mTimer.Stop();
mTimer.Dispose();
base.OnClosing(e);
}