Recent

Author Topic: How to use drag&drop on TRICHMEMO ?  (Read 381 times)

docno

  • New Member
  • *
  • Posts: 17
How to use drag&drop on TRICHMEMO ?
« on: July 26, 2024, 10:13:15 am »
Hello,
I want to use drag&drop on richmemo control.
I want open a file (text file) dropped from explorer in my richmemo.

When i drop something on richmemo i cant have any event fired and an icon is show in editor.
I cant have filename.
No event ondragdrop or ondragover or enddrag...

Any clue ?

I work on windows 10 x64 with lazarus 3.4

rvk

  • Hero Member
  • *****
  • Posts: 6323
Re: How to use drag&drop on TRICHMEMO ?
« Reply #1 on: July 26, 2024, 12:18:50 pm »
For the standard RichEdit dll you would need to pass ES_NOOLEDRAGDROP to disable OLE drag and drop, when creating the richedit window.
After that you would be able to use the normal Lazarus component events.

Normally you could do that by overriding the CreateParams and changing the Params.Style (adding ES_NOOLEDRAGDROP) before creation of the TRichMemo.

But because of the way Lazarus uses widget factoring code (for multi platform), you don't have easy control over these parameters.

At least as I can see the component is created in TWin32WSCustomRichMemo.CreateHandle and the parameters can't be easily manipulated there.

Maybe someone with knowledge about the widget construct can help here.

The way TJVRichEdit does it in Delphi is here https://github.com/project-jedi/jvcl/blob/master/jvcl/run/JvRichEdit.pas.
(search for OLEDragDrop)


Dzandaa

  • Sr. Member
  • ****
  • Posts: 349
  • From C# to Lazarus
Re: How to use drag&drop on TRICHMEMO ?
« Reply #2 on: July 26, 2024, 01:55:27 pm »
Hi,
Here is an example of Drag and Drop with a TImage and a TRichMemo

If you drag your a rtf File directly on the TRichMemo, it insert the Icon of the file, if you Drag a rtf (or picture) on the Form,
it add the rtf (or picture) to TRichMemo or TImage. 

Hope that help.

B->
Regards,
Dzandaa

 

TinyPortal © 2005-2018