Autor Beitrag
Ice
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Di 18.02.03 09:55 
Hallo Leute,

mit folgendem Code versuche ich Linien zu zeichnen, so das sie am Cursor hängen, allerdings möchte ich mehrere Linien hintereinander zeichnen und speichere so die Koordinaten der älteren und versuche sie dann neu zu zeichnen aber irgenwie funktioniert das nicht.
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
procedure TMainDia.PaintBox1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Draw then
  begin
   PaintBox1.Canvas.MoveTo(x,y);
   Buttonpressed := true;
   XOld:=x;
   YOld:=y;
   inc(countW,1);
  end;
end;

procedure TMainDia.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
 i : integer;
begin
  if Draw then
  begin
   PaintBox1.Canvas.MoveTo(XOld,YOld);
   PaintBox1.Canvas.LineTo(x,y);
   Pos1[CountW].X := XOld;
   Pos1[CountW].Y := YOld;
   Pos2[CountW].X := X;
   Pos2[CountW].Y := Y;
   for i := 1 to CountW do
    begin
     PaintBox1.Canvas.MoveTo(Pos1[CountW].X,Pos1[CountW].Y);
     PaintBox1.Canvas.LineTo(Pos2[CountW].X,Pos2[CountW].Y);
    end;
    Buttonpressed := false;
  end;
end;

procedure TMainDia.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
 i : integer;  
begin
  if (Draw) and (Buttonpressed) then
  begin
   PaintBox1.Canvas.FloodFill(8,16,clgray,fsBorder);
   PaintBox1.Canvas.MoveTo(XOld,YOld);
   PaintBox1.Canvas.LineTo(x,y);
   for i := 1 to CountW do
    begin
     PaintBox1.Canvas.MoveTo(Pos1[CountW].X,Pos1[CountW].Y);
     PaintBox1.Canvas.LineTo(Pos2[CountW].X,Pos2[CountW].Y);
    end;
  end;
end;

könnt ihr mir da helfen?

Vielen Dank schonmal

mfg
Ice

Moderiert von user profile iconTino: Code-Tags hinzugefügt.
Ice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Di 18.02.03 11:52 
Hallo,

habe den fehler selber gefunden, anstatt CountW muss natürlich i in der for schleife benutzt werden..... :oops:

mfg
Ice