Hi,
@Johny:
Delphi-Quellcode:
{ = DragAndDrop = }
var
xPos, yPos: integer;
procedure TForm_Workspace_Canvas.Shape_BannerMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
xPos := x; // x-Koordinate erfassen
yPos := y; // y-Koordinate erfassen
end;
procedure TForm_Workspace_Canvas.Shape_BannerMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if HiWord(GetAsyncKeyState(VK_LBUTTON)) > 0 then
begin
Form_Workspace_Canvas.Left := Form_Workspace_Canvas.Left + X - xPos; // Verschieben
Form_Workspace_Canvas.Top := Form_Workspace_Canvas.Top + Y - yPos; // Verschieben
end;
end;
procedure TForm_Workspace_Main.Menu_NewClick(Sender: TObject);
var
Form_Workspace_Canvas : TForm;
Shape_Banner : TShape;
begin
// Form erzeugen
Form_Workspace_Canvas := TForm.CreateNew(Application);
Form_Workspace_Canvas.Left := 205;
Form_Workspace_Canvas.Top := 35;
Form_Workspace_Canvas.Height := 725;
Form_Workspace_Canvas.Width := 815;
Form_Workspace_Canvas.BorderStyle := bsNone;
Form_Workspace_Canvas.Show;
// Shape auf der Form erzeugen
Shape_Banner := TShape.Create(Form_Workspace_Canvas);
with Shape_Banner do
begin
Parent := Form_Workspace_Canvas;
Left := 0;
Top := 0;
Width:= 807;
Height:= 9;
Brush.Color := clGray;
Brush.Style := bsSolid;
Name := 'Shape_Banner';
OnMouseDown:=Shape_BannerMouseDown; //Neu
OnMouseMove:=Shape_BannerMouseMove; //Neu
end;
end;
Habe einfach deinen Code zusammenkopiert und 2 Zeilen eingefügt.. falls da also noch andere fehler sind, ich bin unschuldig
@Silent:
Ich würde das ganze in etwa so lösen:
Delphi-Quellcode:
var //Global!
MyForms: Array of TForm;
procedure AddNewForm(Caption: String);
begin
SetLength(MyForms,Length(MyForms)+1);
MyForms[High(MyForms)]:=TForm.Create(self);
MyForms[High(MyForms)].Parent:=self;
MyForms[High(MyForms)].Width:=150;
MyForms[High(MyForms)].Height:=150;
MyForms[High(MyForms)].Caption:=Caption;
end;
Au'revoir,
Aya~