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: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114:
| unit ansicht;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Verschieben(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure VerschiebenLinie(Sender: TObject; Shift: TShiftState; X, Y: Integer);
private { Private-Deklarationen } public { Public-Deklarationen } end;
var Form1: TForm1; Edits : ARRAY OF TEdit; Lists : ARRAY OF TListBox; GBox : ARRAY OF TGroupBox;
i,k : integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin i:=0; k:= 50; end;
procedure TForm1.Button1Click(Sender: TObject); begin SetLength(GBox, Length(GBox)+1); GBox[i]:=TGroupBox.Create(self); with gbox[i] do begin Parent := Form1; Name := 'GB'+inttostr(i+1); Left := k; top := 20; height := 150; width := 100; Caption := ''; OnMouseDown := Verschieben; OnMouseMove := VerschiebenLinie; end; SetLength(Edits, Length(Edits)+1); Edits[i]:=TEdit.Create(self); with Edits[i] do begin Parent := gbox[i]; Name := 'EDT'+inttostr(i+1); Left := 5; top := 10; height := 20; width := 90; end; SetLength(Lists, Length(Lists)+1); Lists[i]:=TListBox.Create(self); with Lists[i] do begin Parent := gbox[i]; Name := 'LBox'+inttostr(i+1); Left := 5; top := 35; height := 105; width := 90; end;
i:=i+1; k:=k+110;
end;
procedure TForm1.Verschieben(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); const sc_dragmove = $f012; begin ReleaseCapture; TWinControl(Sender).perform(wm_syscommand,sc_dragmove, 0); label1.Caption := Sender.ClassName ; end;
procedure TForm1.VerschiebenLinie(Sender: TObject; Shift: TShiftState; X, Y: Integer); var x1,y1,x2,y2 : integer; begin
x1:= ???? x2:= ???? y2:= label1.Top; x2:= label1.Left; form1.Canvas.MoveTo(x1,y1); form1.Canvas.LineTo(x1+10,y1); form1.Canvas.LineTo(x2-10,y2); form1.Canvas.LineTo(x2,y2); form1.Repaint;
end;
end. |