0

I am developing Delphi application in the older Delphi versions (Delphi 6, the essential thing here is that older Delphi versions have no Messaging unit) and I am using approach described https://delphidabbler.com/articles/article-11 and available as demo application at https://github.com/delphidabbler/article-demos/tree/master/article-11.

The essential thing is that Delphi form registers itself as the listener of WM_DROPFILES by:

  1. setting in the form create:

    DragAcceptFiles(Self.Handle, True);

  2. declaring and implementing handler:

    procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;

As can be seen from demo application, then this approach works. But I have MDI application: main form has FormStyle:=fsMDIForm and the children forms have FormStyle:=fsNormal and putting the mentioned code in the child forms leads to no results - message procedure is not called. I have tried to put this code both in main and children forms and try to observe, whether handlers from both forms are being called, but I can see that the handler from the main form is being called only.

Maybe MDI organization does not allow catching file-drop messages in the child forms at all?

TomR
  • 2,696
  • 6
  • 34
  • 87
  • 1
    Have you tried running your application outside the Delphi IDE ? `ShellAPI` is based on COM technology and thus only the main form can receive WM_DROPFILES. But OLE technology allows drag-and-drop even for dialogs. You can find a great example of this in the book `Don Taylor, Jim Mischel, John Penman, Terence Goggin, John Shemitz. High Performance Delphi 3 Programming. Coriolis Group Book, 1997` – IVO GELOV May 16 '23 at 11:59
  • Thx, I will check this. This if from previous millenium. – TomR May 16 '23 at 12:40
  • 5
    If your demo app tells you to do this in form create then it's already wrong. Because of VCL window re-creation. That window handle isn't going to be stable. Instead, call `DragAcceptFiles` from an overridden `CreateWnd` passing `True`. Then again from `DestroyWindowHandle` passing `False`. – David Heffernan May 16 '23 at 13:48
  • 1
    Use this lib: http://melander.dk/delphi/dragdrop – Delphi Coder May 17 '23 at 07:49

0 Answers0