Is it possible to draw an horizontal line with drawline?
I've tried the ondrawline event and set the toPoint.Y := FromPoint.Y, but then I get rumble during the dragging. A redraw isn't the solution too.
I'm using D7 + Tchart 7
ps. I want to use the right mouse button to drag a line.
Draw horizontal line with DrawLine tool
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Arnold D,
You can easily do that custom drawin on TChart's canvas doing something like this:
You can easily do that custom drawin on TChart's canvas doing something like this:
Code: Select all
var
Form1: TForm1;
X0,Y0,X1,Y1: Integer;
Down: boolean;
implementation
{$R *.dfm}
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (Button=mbRight) then
begin
X0:=X;
Y0:=Y;
Down:=true;
end;
end;
procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (Button=mbRight) then
begin
X1:=X;
Y1:=Y;
Down:=false;
Chart1.Draw;
end;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
With Chart1.Canvas do
begin
MoveTo(X0,Y0);
LineTo(X1,Y0);
end;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if Down then
begin
X1:=X;
Y1:=Y;
Chart1.Draw;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Down:=false;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |