Recent

Author Topic: [SOLVED] Avoid dragging objects into RichMemo  (Read 868 times)

GLR

  • New member
  • *
  • Posts: 8
[SOLVED] Avoid dragging objects into RichMemo
« on: September 19, 2025, 10:33:00 am »
Hi!

How can I avoid dragging objects (pictures, files etc.) into a RichMemo?
I have tried all of the events onDrag... (e.g. DragOver with option accept:=FALSE) to no avail.

GLR
« Last Edit: September 23, 2025, 08:27:39 pm by GLR »

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Avoid dragging objects into RichMemo
« Reply #1 on: September 20, 2025, 02:41:54 pm »
Just attach all drag/drop events and implement them empty. There should be a comment or so to prevent the compiler from removing them.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

GLR

  • New member
  • *
  • Posts: 8
Re: Avoid dragging objects into RichMemo
« Reply #2 on: September 21, 2025, 08:23:59 pm »
Sorry, it does not work.

There are four:
- RichEditStartDrag
- RichEditEndDrag
- RichEditDragDrop
- RichEditDragOver

It is also strange that none of there events is triggered by a drag into the RichMemo. They are only triggered when you move the element inside the RichMemo.
« Last Edit: September 21, 2025, 08:27:40 pm by GLR »

jamie

  • Hero Member
  • *****
  • Posts: 7405
Re: Avoid dragging objects into RichMemo
« Reply #3 on: September 21, 2025, 09:58:48 pm »
all events here work.

I get a Drag cursor over the memo or a rejection cursor, depending on the OnDragOver is answered in the Richmemo

If you are not getting any response, then maybe you have a widget issue? I am on Windows, and it works.

The only other issue I can think of is you messed up your LFM file which happens many times if you edit the name of the component not using the OI to do so but instead manually change it in the source editor.

 You may have two being loaded, one that isn't visible with the events attached to it and the other you see.

 Checkout your LMF file.

 Jamie


The only true wisdom is knowing you know nothing

GLR

  • New member
  • *
  • Posts: 8
Re: Avoid dragging objects into RichMemo
« Reply #4 on: September 22, 2025, 11:50:09 am »
There has to be another reason, because I can insert RichMemo in every other project I have and it is always the same behavior. (I use Lazarus 4.0, Win 11 / 64).

I suppose it is a version problem.

I have richmemopackage 1.0 (LCL 4.0.0.4, FCL 1.0.1), richmemo_design 0.0 (richmemopackage 1.0, IDEInf 1.0, FCL 1.0.1).

jamie

  • Hero Member
  • *****
  • Posts: 7405
Re: Avoid dragging objects into RichMemo
« Reply #5 on: September 22, 2025, 01:00:48 pm »
I dont know what version i have but it came from the online package manager in laz.
The only true wisdom is knowing you know nothing

GLR

  • New member
  • *
  • Posts: 8
Re: Avoid dragging objects into RichMemo
« Reply #6 on: September 23, 2025, 01:57:22 pm »
Thank you for your support.

The problem is not really vital, since when dragging into the RichMemo there are only about 3 chars or linefeeds inserted (in all cases), which are irrelevant.
The user sees that about nothing is imported.
I can handle the import via clipboard with the hasFormat command and everything which is not text is ignored.

GLR

  • New member
  • *
  • Posts: 8
Re: Avoid dragging objects into RichMemo
« Reply #7 on: September 23, 2025, 06:35:04 pm »
I got the solution in the German Forum:

Code: Pascal  [Select][+][-]
  1. implementation
  2. uses ActiveX;
  3.  
  4. procedure TForm1.FormActivate(Sender: TObject);
  5. begin
  6.   RevokeDragDrop(RichMemo1.Handle);
  7. end;

 

TinyPortal © 2005-2018