Issue with Ole Drag&Drop

General TRichView support forum. Please post your questions here
Post Reply
EtereDeveloper
Posts: 1
Joined: Tue Feb 19, 2013 3:19 pm

Issue with Ole Drag&Drop

Post by EtereDeveloper »

Hi
I've an issue with Ole D&D.
I've a TEmbeddedObjContainer that act as container panel for all my controls I want to embed in the editor, at the top of that container there is a TOleDragPanel that hancled D&D.. TOleDragPanel is a simple TPanel descendant that overrides some method to automatically handle D&D (code below).
What happens is that once ownerForm.rv.BeginOleDrag is get called once (it is in the MouseMove method) , there's a chance that D&D starts automatically without entering in the MouseMove event. This is true expecially when moving mouse at the very lower-right part of the object border when it is selected.

Is there a way to prevent D&D start without explicit fn call ?

Code: Select all

  TOleDragPanel = class(TPanel)
  protected
    function selectCtrl(): TControl;
    function ownerForm(): TStoryEditorForm;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    procedure DblClick; override;
  end;

{ TOleDragPanel }

procedure TOleDragPanel.DblClick;
begin
  inherited;
  TEmbeddedObjContainer(Self.Parent.Parent).ShowDialogClick(self);
end;

procedure TOleDragPanel.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  inherited;
//writeln('TOleDragPanel(',IntToHex(integer(pointer(self)),8),').MouseDown()');
  if Button = mbLeft then begin
    ownerForm.rv.SelectControl(selectCtrl);
    ownerForm.oleDrag.ObjEditor := Self.ObjEditor;
    ownerForm.oleDrag.CollapsedSize := TEmbeddedObjContainer(selectCtrl).CollapsedSize;
    ownerForm.oleDrag.ExpandedSize := TEmbeddedObjContainer(selectCtrl).ExpandedSize;
    ownerForm.oleDrag.NowCollapsed := TEmbeddedObjContainer(selectCtrl).Collapsed;
    ownerForm.oleDrag.mouseDownCtrl := Self;
    ownerForm.oleDrag.mouseDownPoint := Point(X, Y);
  end;
end;

procedure TOleDragPanel.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
  inherited;
//writeln('TOleDragPanel(',IntToHex(integer(pointer(self)),8),').MouseMove()');
  if (ssLeft in Shift) and (ownerForm.oleDrag.mouseDownCtrl = Self) and
    (Sqr(ownerForm.oleDrag.mouseDownPoint.X-X)+Sqr(ownerForm.oleDrag.mouseDownPoint.Y-Y)>10) then begin
    ownerForm.rv.BeginOleDrag;
  end;
end;

function TOleDragPanel.ownerForm: TStoryEditorForm;
begin
  result := TEmbeddedObjContainer(Self.Parent.Parent).OwnerForm;
end;

function TOleDragPanel.selectCtrl: TControl;
begin
  result := TControl(Self.Parent.Parent);
end;

function TOleDragPanel.ObjEditor: INewsObjEditor;
begin
  result := TEmbeddedObjContainer(Self.Parent.Parent).ObjEditor;
end;
[/code]
Sergey Tkachenko
Site Admin
Posts: 17571
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

There is an option rvoDisallowDrag in rv.Options.
However, it also prevents BeginOleDrag from working. You can temporary exclude this option before calling this function, and return it back when dragging is finished.
Post Reply