Autor Beitrag
Green
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: So 21.05.06 18:41 
also ich hbe folgendes problem:
ich will mit der Maus einen Rahmen in einem TImage ziehen wie auf dem Desktop, nur das dieser immer ein QUADRAT sein muss, das heisst Höhe=Breite,
hab schon viel versucht aber es will irgendwie nicht...

kann mir jemand helfen?


Moderiert von user profile iconGausi: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Di 23.05.2006 um 15:28
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: So 21.05.06 19:25 
Hier mal ein Quick-and-Dirty Ansatz (mit Form als Canvas):

Edit: erstes Listing gelöscht, war Käse, das hier ist ok:
ausblenden Delphi-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:
procedure TForm1.FormCreate(Sender: TObject);
begin
  canvas.Pen.mode :=pmNotXor;
  canvas.pen.style:= psDot;  //Gepunktete Linien
  canvas.pen.color:=clRed;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
canvas.brush.style :=bsClear;   //Für transparentes Quadrat
if shift = [ssleft] then        //Zeichnen mit linker Maustaste
  begin
    x1 := x; y1 := y;
    x2 := x; y2 := y;
    canvas.rectangle (x1,y1,x2,y2);
  end;
if shift =[ssright] then      //Quadrat löschen mit rechter Maustaste
  canvas.rectangle(x1,y1,x2,y2);
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if shift = [ssleft] then begin
  canvas.rectangle (x1,y1,x2,y2);
  x2 := x;   y2 := y1+x-x1;    //Quadrat durch X-Verschiebung der Maus
  canvas.rectangle (x1,y1,x2,y2);
  end
end;

Vielleicht kannst du mit diesem Gerüst was anfangen. Gibt sicher noch bessere Lösungen, hab aber so schnell nix gefunden


Zuletzt bearbeitet von aim65 am So 21.05.06 20:40, insgesamt 1-mal bearbeitet
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: So 21.05.06 20:37 
also vom prinzip her gut, aber es entsteht irgendwie immer zu weit unten...
also nicht da wo ich klick sondern doppeltsoweit unten...
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: So 21.05.06 20:42 
Haben uns gekreuzt - siehe mein Edit oben.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: So 21.05.06 20:44 
ABSLOUT GENIAL!!!! danke :)

mfG Green

p.s.: hast was gut bei mir :D
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Do 16.11.06 14:41 
Forget it - war im falschen Thread....