Hallo,
bin ein bischen verzweifelt, weil ich nicht dahinter kommen, warum immer ein EAbstractError auftritt, wenn ich das zweite Panel der insgesamt 4 Panels per Drag and Drop löschen möchte.
Es soll immer das Panel entfernt werden, welches auf das Formular gezogen und fallen gelassen wird.
Benutze D7.
Wäre sehr nett, wenn das mal jemand ergründen könnte:
<B>Quellcode</B>
<PRE>
unit UnitP2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
procedure FormDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure FormDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
tmpWCntrl: TControl;
procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
tmpWCntrl:= Source as TPanel;
tmpWCntrl.Parent:= nil;
tmpWCntrl.Free;
end;
procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if (Source is TPanel) then
Accept:= true
else
Accept:= false;
end;
end.
</PRE>
<B>Formular</B>
<PRE>
object Form1: TForm1
Left = 491
Top = 117
Width = 112
Height = 284
Caption = 'Form1'
Color = clBtnFace
DragMode = dmAutomatic
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnDragDrop = FormDragDrop
OnDragOver = FormDragOver
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 16
Top = 8
Width = 73
Height = 49
Caption = 'Panel1'
DragMode = dmAutomatic
TabOrder = 0
end
object Panel2: TPanel
Left = 16
Top = 72
Width = 73
Height = 49
Caption = 'Panel2'
DragMode = dmAutomatic
TabOrder = 1
end
object Panel3: TPanel
Left = 16
Top = 136
Width = 73
Height = 49
Caption = 'Panel3'
DragMode = dmAutomatic
TabOrder = 2
end
object Panel4: TPanel
Left = 16
Top = 200
Width = 73
Height = 49
Caption = 'Panel4'
DragMode = dmAutomatic
TabOrder = 3
end
end
</PRE>
bin ein bischen verzweifelt, weil ich nicht dahinter kommen, warum immer ein EAbstractError auftritt, wenn ich das zweite Panel der insgesamt 4 Panels per Drag and Drop löschen möchte.
Es soll immer das Panel entfernt werden, welches auf das Formular gezogen und fallen gelassen wird.
Benutze D7.
Wäre sehr nett, wenn das mal jemand ergründen könnte:
<B>Quellcode</B>
<PRE>
unit UnitP2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
procedure FormDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure FormDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
tmpWCntrl: TControl;
procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
tmpWCntrl:= Source as TPanel;
tmpWCntrl.Parent:= nil;
tmpWCntrl.Free;
end;
procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if (Source is TPanel) then
Accept:= true
else
Accept:= false;
end;
end.
</PRE>
<B>Formular</B>
<PRE>
object Form1: TForm1
Left = 491
Top = 117
Width = 112
Height = 284
Caption = 'Form1'
Color = clBtnFace
DragMode = dmAutomatic
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnDragDrop = FormDragDrop
OnDragOver = FormDragOver
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 16
Top = 8
Width = 73
Height = 49
Caption = 'Panel1'
DragMode = dmAutomatic
TabOrder = 0
end
object Panel2: TPanel
Left = 16
Top = 72
Width = 73
Height = 49
Caption = 'Panel2'
DragMode = dmAutomatic
TabOrder = 1
end
object Panel3: TPanel
Left = 16
Top = 136
Width = 73
Height = 49
Caption = 'Panel3'
DragMode = dmAutomatic
TabOrder = 2
end
object Panel4: TPanel
Left = 16
Top = 200
Width = 73
Height = 49
Caption = 'Panel4'
DragMode = dmAutomatic
TabOrder = 3
end
end
</PRE>