trichview.com

trichview.support




Re: Drag & Drop Controls in richviewedit


Return to index


Author

Message

Marc

Posted: 11/22/2003 0:47:02


Hi Sergey/Karsten


I have implemented controls drag&drop using TRichViewEdit built-in methods.

I have done this with TGifImage (anders) and TPNGImage controls. Sergey,

let me know what you think of the code.


For your inserted control you need to assign the onMouseMove and OnMouseUp

events. The onMouseUp is used to select the control when the user clicks

on it, and the OnMouseMove (with left mouse button down) calls 'rve.rvdata.dodrag'

to start drag and drop.


Like this:


procedure TfmDiary.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,

  Y: Integer);

  var

  Item: TCustomRVItemInfo;

  ItemNo, StartItemNo, EndItemNo, StartOffs, EndOffs,ItemOfs:   Integer;

  RVData:TCustomRVFormattedData;

  p,p1:Tpoint;

begin

if rve.selectionexists then

begin

rve.GetSelectionBounds(StartItemNo, StartOffs, EndItemNo, EndOffs, True);

p:=(sender as Timage).ClientToScreen(Point(x, y));

p1:=rve.ScreenToClient(Point(p.x, p.y));

P1.Y:=P1.Y+(rve.vscrollpos*rve.VSmallStep);

rve.Getitemat(P1.x,P1.y,RVData,itemNo,itemOfs,true);

if ssleft in shift then

begin

  if (ItemNo>=StartItemNo) and (ItemNo<=EndItemNo) then rve.rvdata.dodrag

end

else

begin

   if (ItemNo>=StartItemNo) and (ItemNo<=EndItemNo) then (sender as timage).cursor:=crarrow

   else (sender as timage).cursor:=cribeam;

end;

end

else

(Sender as timage).cursor:=cribeam;

end;


procedure TfmDiary.Image1MouseUp(Sender: TObject; Button: TMouseButton;

  Shift: TShiftState; X, Y: Integer);

begin

        Case button of

        mbLeft:

         begin

                rve.selectcontrol((sender as timage));

         end;

        end;

end;





Powered by ABC Amber Outlook Express Converter