Page 1 of 1

TCursorTool.YValue not set

Posted: Fri Jun 18, 2010 8:31 am
by 10055200
Hi,

I have a problem with setting TCurosorTool.YValue property.

I have the code like:

Code: Select all

      Cursor.Visible := true;
      Cursor.Series := TCustomSeries(Chart.SeriesList[Idx]);
      
      // prevent calling event handler on changing Cursor
      T := Trigger.OnChange; 
      Cursor.OnChange := nil;

      if (Level * Koef > Chart.LeftAxis.Maximum) then
        Cursor.YValue := Chart.LeftAxis.Maximum else
      if (Level * Koef < Chart.LeftAxis.Minimum) then
        Cursor.YValue := Chart.LeftAxis.Minimum else
        Cursor.YValue := Level * Koef ;

      // set old event handler
      Cursor.OnChange := T;
First time when I call this code the cursor's YValue is always set at 0, regardles the product of Level*Koef is different than zero. So if I add breakpoint and add Cursor.YValue to watch list I can see 0 all the time. If I inspect the Level * Koef I get something that is it different from 0 (eg. -8,9) but cursor Y value remains 0 (and only the first time I call this).

Thanks for your help.

Br

Re: TCursorTool.YValue not set

Posted: Fri Jun 18, 2010 8:54 am
by 10055200
I attached some screenshot of debugging:

Image

Re: TCursorTool.YValue not set

Posted: Fri Jun 18, 2010 4:00 pm
by yeray
Hi PoLabs,

Maybe you need to force a Chart repaint so that the internal values will be calculated.
If you still have problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.

Re: TCursorTool.YValue not set

Posted: Mon Jun 21, 2010 7:30 am
by 10055200
Hi,

I added Chart.Repaint after OnChange := nil and it works now. I guess there needs to be done some recalulations before setting YValue value of cursor.

Thanks again. ;)

Br,
PoLabs

Re: TCursorTool.YValue not set

Posted: Mon Jun 21, 2010 8:13 am
by yeray
Hi PoLabs,

You're welcome!