Page 1 of 1

Hint for Annotation

Posted: Tue Jul 13, 2010 5:04 pm
by 10546565
I would like to create a custom hint for an annotation.

Is there any way to get a OnHint event for a annotation?

Ed Dressel

Re: Hint for Annotation

Posted: Wed Jul 14, 2010 9:55 am
by narcis
Hi Ed,

No but you could use OnMouseMove event and annotation's Clicked method to check if the mouse is over an annotation tool and use delphi tooltips or windows hints then to display whatever you want.

Re: Hint for Annotation

Posted: Fri Jul 03, 2015 12:57 pm
by 13049883
There is no OnMouseMove event (at least in version 3) for annotation and since it is not of Control type, I cannot assign .Net ToolTip.
P.S.: not sure whether this should be placed in the .Net forum.

Re: Hint for Annotation

Posted: Fri Jul 03, 2015 2:38 pm
by narcis
Hello icecream,
icecream wrote:There is no OnMouseMove event (at least in version 3) for annotation and since it is not of Control type, I cannot assign .Net ToolTip.
I actually meant using TChart's MouseMove event and calling Annotation's Clicked method in it. Given that Annotation.Clicked is not a public method in .NET, you can create your custom annotation tool class like this:

Code: Select all

  public class MyAnnotation : Annotation
  {
    public MyAnnotation(Chart c) : base(c) { }

    public bool Clicked(Point p)
    {
      return Clicked(p.X, p.Y);
    }
  }
which can be used to implement what I suggested this way:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      tChart1.MouseMove += TChart1_MouseMove;

      Bar bar1 = new Bar(tChart1.Chart);
      bar1.FillSampleValues();

      tool = new MyAnnotation(tChart1.Chart);
      tool.Text = "HELLO WORLD";
    }

    MyAnnotation tool;
    private void TChart1_MouseMove(object sender, MouseEventArgs e)
    {
      if(tool.Clicked(e.Location))
      {
        MessageBox.Show("ANNOTATION CLICKED!");
      }
    }
icecream wrote:P.S.: not sure whether this should be placed in the .Net forum.
When I read .NET in your post I rushed moving it to the .NET forum. I forgot about the VCL history it could have behind. :?