Vagueness in TDrawLineTool Documentation - Help!
Posted: Thu Aug 24, 2006 6:46 pm
The DrawLine Tool documentation is frustratingly poor. It has taken me 2 full days to get things to a point where they partially work. First I will describe what I want, then I will describe what I have.
I am using TChart 7.07 with Delphi 6 on windows XP Pro.
I would like a user to be able to hold down the left mouse button and draw a line from point A to Point B. When they lift the mouse the line is finalized. Then I would like them to be able to draw another separate line that is not necessarily connected to the first line. I would also like the user to be able to left click (In a different Mouse Mode) on an existing line to select it and drag that line to a new location without drawing another new line.
After 2 days of noodling and experimentation, I have been able to achieve the following:
a) I can draw multiple separate lines with the left mouse button as above, but, whether or not my mouse button is down, there is always a line between the last point that I lifted my mouse button up and the current mouse position (It is as though I am holding the mouse button down and drawing a line). This is undesirable behaviour.
b) I can select a line. but I cannot drag it around, as this blows away the selection.
pertinent code follows:
According to the documentation, it sounded like one would not have to write any of this code to allow simple line drawing, selecting and moving, but that behaviour did nothing near what I wanted it to.
Please help soon as this is taking way longer than it should.
I am using TChart 7.07 with Delphi 6 on windows XP Pro.
I would like a user to be able to hold down the left mouse button and draw a line from point A to Point B. When they lift the mouse the line is finalized. Then I would like them to be able to draw another separate line that is not necessarily connected to the first line. I would also like the user to be able to left click (In a different Mouse Mode) on an existing line to select it and drag that line to a new location without drawing another new line.
After 2 days of noodling and experimentation, I have been able to achieve the following:
a) I can draw multiple separate lines with the left mouse button as above, but, whether or not my mouse button is down, there is always a line between the last point that I lifted my mouse button up and the current mouse position (It is as though I am holding the mouse button down and drawing a line). This is undesirable behaviour.
b) I can select a line. but I cannot drag it around, as this blows away the selection.
pertinent code follows:
Code: Select all
procedure TMDIChartForm.MainChartMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
CurrStartPoint.X := x;
CurrStartPoint.Y := y;
TrendLineTool.EnableSelect := True;
TrendLineTool.SelectNewLines := True;
TrendLineTool.EnableDraw := True;
TrendLineTool.Active := True;
end;
end;
Code: Select all
procedure TMDIChartForm.MainChartMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
TempPoint: TPoint;
TempLine: TDrawLine;
begin
if Button = mbLeft then
begin
TempPoint.X := x;
TempPoint.Y := y;
TempLine := TDrawLine.Create(TrendLineTool.Lines);
TempLine.StartPos := TrendLineTool.ScreenPoint(CurrStartPoint);
TempLine.EndPos := TrendLineTool.ScreenPoint(TempPoint);
TrendLineTool.Lines.Add;
TrendLineTool.Lines.Items[TrendLineTool.Lines.Count - 1] := TempLine;
TrendLineTool.Repaint;
TrendLineTool.EnableDraw := False;
end;
end;
Please help soon as this is taking way longer than it should.