Double Click bug

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
strobbekoen
Newbie
Newbie
Posts: 23
Joined: Tue Feb 10, 2009 12:00 am

Double Click bug

Post by strobbekoen » Thu Mar 19, 2009 12:51 am

Hi,

I have a chart with a cursor tool (followmouse is true).
I use the double click chart event to zoom sections of the chart depending where the cursor is (in my case the chart is zoomed when the cursor/mouse is in a colorband). The problem is that the cursor is in 'selection' mode after the double click event, but only if the chart was zoomed during the double click handler.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Mar 19, 2009 10:07 am

Hi strobbekoen,

I think that you should use a custom zoom. Something as follows:

Code: Select all

var
  Form1: TForm1;
  DrawRect: Boolean;
  XStart, XEnd, YStart, YEnd: Integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  XStart := -1;
  XEnd := -1;
  YStart := -1;
  YEnd := -1;

  DrawRect := false;

  Chart1.Zoom.Allow := false;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var ZoomRect: TRect;
begin
  If DrawRect then
  begin
    DrawRect := false;
    ZoomRect.Left := XStart;
    ZoomRect.Top := YStart;
    ZoomRect.Right := XEnd;
    ZoomRect.Bottom := YEnd;
    Chart1.ZoomRect(ZoomRect);
  end;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  if DrawRect then
  begin
    Chart1.Canvas.Pen.Color := clWhite;
    Chart1.Canvas.Brush.Style := bsClear;
    Chart1.Canvas.Rectangle(XStart,YStart,XEnd,YEnd);
  end;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if DrawRect then
  begin
    XEnd := X;
    YEnd := Y;
    Chart1.Draw;
  end
  else
  begin
    XStart := X;
    YStart := Y;
  end;
end;

procedure TForm1.Chart1DblClick(Sender: TObject);
begin
  DrawRect := True;
end;
Also, let me suggest you to consider another possibility. You could use mousewheel to zoom the chart as described here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

strobbekoen
Newbie
Newbie
Posts: 23
Joined: Tue Feb 10, 2009 12:00 am

Post by strobbekoen » Thu Mar 19, 2009 2:33 pm

Thanks for the tip :)

Post Reply