Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Drag'n'Drop (https://www.delphipraxis.net/79240-dragndrop.html)

_frank_ 20. Okt 2006 04:00

Re: Drag'n'Drop
 
mal noch eine Ergänzung...

Delphi-Quellcode:
function isChild(parent:TControl;child:TControl):boolean;
var c:TControl;
begin
  c:=Child.Parent;
  result:=False;
  while assigned(c) and not result do
  begin
    if c=parent then result:=true;
    c:=c.Parent;
  end;
end;

procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  accept := (sender<>source) and
            (not isChild(source as TControl,(sender as TControl))) and
            (sender is TWinControl);
end;
- wenn sender=source kommt zugriffsverletzung (control kann nicht sein parent sein ;) )
- man darf das Parent nicht in sein client droppen (isChild-Funktion), sonst AV
- der sender (= TargetControl) muss ein TWinControl sein, sonst gibt es auch Fehler (z.B. wenn man auf ein TLabel zieht) (vermutl. invalidCast to TWinControl)

Gruß Frank

mikegu 20. Okt 2006 17:01

Re: Drag'n'Drop
 
Danke Frank. Auch das wird mir helfen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:32 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz