Page 1 of 1

Chart Unexpectedly changes color with mouse movement

Posted: Mon Aug 01, 2016 2:42 pm
by 16577360
One of the IDE's I need to maintain is Delphi 6. I also have XE2, Seattle and Berlin 10.1

I recently upgraded to Steema TeeChartVCLFMXSOURCE-2016.18
The installation went ahead without issue, including the D6 build. All OK.

Now after recompiling my software that uses the D6 IDE, sometimes when I mouse move over a chart area it completely changes color, not always, but most times.
It's quite unpredictable, sometimes when the mouse is only over the chart grid area itself, sometimes when the mouse is anywhere over the chart it suddenly completely changes color.

There is a mouse-move event associated with the chart to draw cross-hairs. That procedure has been there untouched for a long time.

Code: Select all

//OnMouseMove Event code:

procedure TTTGraphPagesDlg.Estimated_TT_D2_ChartMouseMove(Sender: TObject;   Shift: TShiftState; X, Y: Integer);
{ This procedure draws the crosshair lines }
procedure DrawCross(AX,AY:Integer);
begin
  with Estimated_TT_D2_Chart,Canvas do
  begin
    Pen.Color:=CrossHairColor;
    Pen.Style:=CrossHairStyle;
    Pen.Mode:=pmXor;
    Pen.Width:=1;
    MoveTo(ax,Estimated_TT_D2_Chart.ChartRect.Top-Height3D);
    LineTo(ax,Estimated_TT_D2_Chart.ChartRect.Bottom-Height3D);
    MoveTo(Estimated_TT_D2_Chart.ChartRect.Left+Width3D,ay);
    LineTo(Estimated_TT_D2_Chart.ChartRect.Right+Width3D,ay);
  end;
end;
var
tmpX, tmpY : Double;
ix : Integer;
Lbl : ShortString;
ReturnedHMS : THrsMinSec;
{start of code}
begin
  if (C2OldX<>-1) then
  begin
    DrawCross(C2OldX,C2OldY);  { draw old crosshair }
    C2OldX:=-1;
  end;

  { check if mouse is inside Chart rectangle }
  if PtInRect( Estimated_TT_D2_Chart.ChartRect, Point(X-Estimated_TT_D2_Chart.Width3D,Y+Estimated_TT_D2_Chart.Height3D)  ) then
  begin
    DrawCross(x,y);  { draw crosshair at current position }
    { store old position }
    C2OldX:=x;
    C2OldY:=y;
    { set label text }
    With Estimated_TT_D2_Chart.Series[2] do
      begin
      GetCursorValues(tmpX,tmpY); { <-- get values under mouse cursor }
      ix := trunc(tmpx);
      Lbl := Format('%2.2d:%2.2d', [(ix div 60),(ix mod 60)]);
      ReturnedHMS := Extended2HrsMinSec(tmpY*60);
      end; {With Estimated_TT_D2_Chart.Series[2]}
  end {if PtInRect}
  else
  StatusBar2.simpleText:= '';

end; {procedure}
Please see attached images that show what happens to the chart display.

Any ideas what has caused this?
____________________________________________

Re: Chart Unexpectedly changes color with mouse movement

Posted: Tue Aug 02, 2016 12:03 pm
by 10050769
Hello VideoTrack,

Many thanks for the code you have sent us.

Could you attach for us the complete project? Or could you arrange for us a simple project where the problem appears?
We need reproduce exactly the problem here.

Thanks for your help,

Re: Chart Unexpectedly changes color with mouse movement

Posted: Wed Aug 03, 2016 3:03 am
by 16577360
Hello Sandra

Thanks

I created a small project using all the same settings, and can get the problem to occur with this project, especially when moving the cursor near the scale graduation marks

It may be downloaded as a zip from this link:
https://www.dropbox.com/s/e0e3oaekzsm76 ... s.zip?dl=0

Thanks
Trevor

Re: Chart Unexpectedly changes color with mouse movement

Posted: Wed Aug 03, 2016 3:07 pm
by 10050769
Hello Trevor,

Many thanks for the project
We can reproduce the problem you experiencing here and we have found a fix for the problem, is only needed modify the Estimated_TT_D1_ChartMouseMove method in same way below:

Code: Select all

procedure DrawCross(AX,AY:Integer);
begin
  with Estimated_TT_D1_Chart,Canvas do
  begin
    Pen.Color:=CrossHairColor;
    Pen.Style:=CrossHairStyle;
    Pen.Color := clRed;
    Pen.Mode:=pmNotXor;
    Pen.Width:=1;
    MoveTo(ax,Estimated_TT_D1_Chart.ChartRect.Top-Height3D);
    LineTo(ax,Estimated_TT_D1_Chart.ChartRect.Bottom-Height3D);
    MoveTo(Estimated_TT_D1_Chart.ChartRect.Left+Width3D,ay);
    LineTo(Estimated_TT_D1_Chart.ChartRect.Right+Width3D,ay);
  end;
end;
As you see I have used as Pen.Mode pmNotXor instead of pmXor and I have set the Pen color to Red.

Could you tell us if it fix the problem in your end?

Hoping this helps you

Thanks in advance

Re: Chart Unexpectedly changes color with mouse movement

Posted: Mon Aug 08, 2016 1:18 pm
by 16577360
Thanks. I tried changing the value, but this made it worse?

Code: Select all

procedure DrawCross(AX,AY:Integer);
begin
  with Estimated_TT_D1_Chart,Canvas do
  begin
    Pen.Color:=CrossHairColor;
    Pen.Style:=CrossHairStyle;
    //Pen.Mode:=pmXor;
    Pen.Mode := pmNotXor;
    Pen.Width:=1;
    MoveTo(ax,Estimated_TT_D1_Chart.ChartRect.Top-Height3D);
    LineTo(ax,Estimated_TT_D1_Chart.ChartRect.Bottom-Height3D);
    MoveTo(Estimated_TT_D1_Chart.ChartRect.Left+Width3D,ay);
    LineTo(Estimated_TT_D1_Chart.ChartRect.Right+Width3D,ay);
  end;
end;
When the mouse was moved over the chart, the charts now went either yellow or pale green:
2016-08-08_23-08-56.jpg
2016-08-08_23-08-56.jpg (225.53 KiB) Viewed 14338 times
2016-08-08_23-10-03.jpg
2016-08-08_23-10-03.jpg (183.72 KiB) Viewed 14338 times
Incidentally, the code: Pen.Mode:=pmXor; has been there for about 10 years.

Re: Chart Unexpectedly changes color with mouse movement

Posted: Mon Aug 08, 2016 1:29 pm
by 16577360
Incidentally, the color change definitely seems to be related to moving the mouse over an adjacent control first, e.g. some text or other graphics object:
2016-08-08_23-25-41.jpg
2016-08-08_23-25-41.jpg (63.31 KiB) Viewed 14347 times

Re: Chart Unexpectedly changes color with mouse movement

Posted: Tue Aug 09, 2016 11:40 am
by 10050769
Hello Trevor,

Many thanks for the information.
After, do some test I have realized you try to simulate a CursorTool.The same problem as you find the client there is in the thread below:
http://www.teechart.net/support/viewtop ... e4c#p50889

Therefore, I would like suggest you try to use a Cursor Tool for your requests and prevent possible problems.
Take a look at the examples under "All features\Welcome !\Tools\Cursor\". Also I have attached a simple example that Yeray made for the client of thread above.
MouseMoveUpdate.zip
(1.74 KiB) Downloaded 684 times
Could you tell us if it works in your end?

Thanks in advance

Re: Chart Unexpectedly changes color with mouse movement

Posted: Fri Aug 12, 2016 7:31 am
by 16577360
Thank you, that new code seems to work OK. Appreciate your assistance
Trevor

Re: Chart Unexpectedly changes color with mouse movement

Posted: Fri Aug 12, 2016 8:10 am
by 10050769
Hello Trevor,

I'm glad the code works for you :).

Feel free to contact us if you have more questions.
Thanks in advance