Recent

Author Topic: Drag & drop into RichMemo  (Read 272 times)

bungayst

  • New Member
  • *
  • Posts: 10
Drag & drop into RichMemo
« on: August 12, 2022, 04:07:23 pm »
I want to be able to Drag text into a RichMemo. The drag and drop is easy, inserting the text at the location under the mouse cursor is the difficult bit. Anyone done this?

bungayst

  • New Member
  • *
  • Posts: 10
Re: Drag & drop into RichMemo
« Reply #1 on: August 24, 2022, 04:38:36 pm »
[SOLVED] Thanks for all the help.

CaretPos has nothing to do with it, which is misleading.

To drag and drop text from a TreeView node into a RichMemo;

procedure TForm1.RichMemo1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
  iNode  : String;

begin
  inode := TTreeview(Source).Selected.Text; //Treeview is the Source.

  RichMemo1.SelStart:=RichMemo1.CharAtPos(X,Y);
  RichMemo1.SelText:=iNode;

end;

« Last Edit: August 25, 2022, 03:24:04 pm by bungayst »

 

TinyPortal © 2005-2018