DropTargetDrop does not detect file dropped on form from Windo9ws’ Desktop

Home Forums DropMaster DropTargetDrop does not detect file dropped on form from Windo9ws’ Desktop

Viewing 5 reply threads
  • Author
    Posts
    • #2544
      Andrew Bond
      Participant

        I am having problems getting DropMaster 2.5.1 detecting when I drag and drop a file from Windows’ desktop onto my C++Builder 10.2 Tokyo application.

        I have added a TDMTextTarget object to my form and set flags so that it accepts all formats, including dtfURL.

        I have added a handler from dragging over the form…

        MyForm::DropTargetDragOver(…) detects when a drag a file over the form and I have checked that the format is dtfURL when this handler gets called.

        However, despite setting DropTarget->AcceptText = true; in MyForm::DropTargetDragOver(…), the drop handler MyForm::DropTargetDrop(…) does not fire.

        What am I missing?

        Help urgently needed!

        Thanks in advance

        Andrew

         

         

         

         

      • #2545
        DropMaster Support
        Participant

          Is it possible that your target control is on a page control or something else whose window handle gets recreated at runtime? If so you can try putting the following in your FormCreate event (Delphi notation):

          DropTarget.AcceptorControl := nil;

          DropTarget.AcceptorControl := … (the actual acceptor control);

          which should re-enable everything. If that’s what’s going on, then the control would no longer get the drop.

          dtfURL is probably one format that’s advertised, but it may not be the primary one that gets transmitted. Have you looked at dtfFiles? And in the Demos there are various examples (most of them Delphi, but the techniques are the same) of accepting custom formats from the Windows Explorer which includes the desktop. It may be as simple as using a custom format to accept CF_HDROP.

          Hope this helps.

        • #2546
          Andrew Bond
          Participant

            Thanks for the reply. Your suggestion worked, in that my main form now receives notification when a file is dropped onto certain parts of it.

            I now have a new problem. My application comprises several forms, some of which have their own DropTargets (which pick up dtfCustom items and work correctly).

            When I drop a file onto parts of the App’s that do not have their own DropTarget, my main form gets the notification. However, when I drop onto one of the forms that does have its own DropTarget, that form gets the notification.

            Is there an easy way of allowing the notification to “pass through” these forms and be picked up by the main form, but only when the dropped item is dtfFiles?

            I want to avoid adding special code to redirecting the original notification to the ‘highest’ form.

            Any suggestions would be gratefully received.

            Thanks

            Andrew

          • #2547
            DropMaster Support
            Participant

              No, there’s no centralized handling; each TDMTextTarget or TDMGraphicTarget is responsible for handling a single AcceptorControl.

              You could probably have each of your drop events call a common helper function that would do what you need regardless of where the drop happens, but there’s nothing built into DropMaster to multiplex drop events.

              Hope this helps.

            • #2548
              Andrew Bond
              Participant

                OK, thanks for confirming. I will just have to press the button on that central event handler…

                Thanks for the previous tip though.

                Andrew

              • #2549
                DropMaster Support
                Participant

                  Glad you’ve got things working acceptably.

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.