Jump to content
Chelly

Catch WM_DROPFILES in TRichEdit

Recommended Posts

Hi, I upgraded the builder from XE6 to 12.

How can I catch the WM_DROPFILES message when I drag an image file (like PNG or JPG) and drop it into a TRichEdit? Other types of files are correctly catching the WM_DROPFILES, but image files don't work.

It seems like the image file is automatically converted to RTF text. How can I stop this behavior?

Share this post


Link to post

Are you subclassing the RichEdit to receive WM_DROPFILES? Are you registering the RichEdit with DragAcceptFiles() to receive WM_DROPFILES?

 

Unlike other UI controls, a RichEdit can send an EN_DROPFILES notification to its parent window when you drop files onto the RichEdit. Are you able to receive that notification?

Share this post


Link to post
40 minutes ago, Remy Lebeau said:

Are you subclassing the RichEdit to receive WM_DROPFILES? Are you registering the RichEdit with DragAcceptFiles() to receive WM_DROPFILES?

 

Unlike other UI controls, a RichEdit can send an EN_DROPFILES notification to its parent window when you drop files onto the RichEdit. Are you able to receive that notification?

Thank you for your answer.
I have used DragAcceptFiles() and set the parent window to receive the notification, but it still can't handle the WM_DROPFILES message.
Only image files are not accepted.

By the way, the same code works correctly in XE6.
 

Share this post


Link to post

XE6 and D12 use different versions of the Windows richedit control as far as I remember, that may explain the change in behaviour you see.

Share this post


Link to post
12 hours ago, PeterBelow said:

XE6 and D12 use different versions of the Windows richedit control as far as I remember, that may explain the change in behaviour you see.

Yes, the version of RichEdit in 12 is 4.1, starting from 11. However, I couldn't find any update logs about image drag-and-drop behavior on the Microsoft website.

Share this post


Link to post

Well, it has to be something you do in your code then. I just created a new VCL app (D12.2), dropped a TRichedit on it, build and ran and it inserts an image (jpg in this  case) dragged from Explorer to it just fine. If you now handle WM_DROPFILES or such try to disable that.

Share this post


Link to post
6 hours ago, PeterBelow said:

Well, it has to be something you do in your code then. I just created a new VCL app (D12.2), dropped a TRichedit on it, build and ran and it inserts an image (jpg in this  case) dragged from Explorer to it just fine. If you now handle WM_DROPFILES or such try to disable that.

Read the OP's opening message again more carefully. They want to handle WM_DROPFILES manually and disable the default behavior for inserting dropped image files.

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×