From fd45a904f46083d603ee73295f774309edf1210e Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 7 Apr 2007 16:45:10 +0000 Subject: [PATCH] - fixing AV during Drag and Drop operation - looking on non TWinControl objects while drop (0008628) git-svn-id: trunk@10914 - --- lcl/include/dragdock.inc | 8 +++++--- lcl/include/dragobject.inc | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lcl/include/dragdock.inc b/lcl/include/dragdock.inc index 6d19d70be2..f0f30a7653 100644 --- a/lcl/include/dragdock.inc +++ b/lcl/include/dragdock.inc @@ -245,10 +245,12 @@ Begin {$IFDEF VerboseDrag} DebugLn('DragTo P=',Position.X,',',Position.Y); {$ENDIF} - if (ActiveDrag = dopNone) - and (Abs(DragStartPos.X - Position.X) < DragThreshold) - and (Abs(DragStartPos.Y - Position.Y) < DragThreshold) then begin + if (DragControl = nil) or ((ActiveDrag = dopNone) and + (Abs(DragStartPos.X - Position.X) < DragThreshold) and + (Abs(DragStartPos.Y - Position.Y) < DragThreshold)) then + begin // dragging not yet started + // or CancelDrag happened (DragControl = nil) exit; end; diff --git a/lcl/include/dragobject.inc b/lcl/include/dragobject.inc index 0a9d72a3f3..790be835d8 100644 --- a/lcl/include/dragobject.inc +++ b/lcl/include/dragobject.inc @@ -72,8 +72,23 @@ begin end; procedure TDragObject.CaptureChanged(OldCaptureControl: TControl); +var + i: integer; + IsDragging: Boolean; begin - DragDone(OldCaptureControl.Dragging); + // if this is TWinControl, and it have controls (not TWinControls) + // then we should check Dragging in those controls + IsDragging := OldCaptureControl.Dragging; + if (not IsDragging) and (OldCaptureControl is TWinControl) then + begin + for i := 0 to TWinControl(OldCaptureControl).ControlCount - 1 do + begin + IsDragging := IsDragging or TWinControl(OldCaptureControl).Controls[i].Dragging; + if IsDragging then + break; + end; + end; + DragDone(IsDragging); end; procedure TDragObject.KeyDown(var Key: Word; Shift: TShiftState);