2
votes

I'm having trouble getting drag drop from Explorer to work in my app. When I create a simple VCL form app I can use the demo code in here and it works fine. My own drop target is a control aligned deep within frames and embedded forms and moving the working demo routine to this form does not work. I've tried placing a TPanel on the deeply embedded form after moving the forms other controls aside so that I can try the demo code here: way of dropping onto TPanel, this does not work either. If I place the line

DragAcceptFiles(Handle,true);

in the FormCreate of my MAIN form, the cursor indicates that I can accept files, but the same line does not seem to enable receipt of dragged files for any other deeper controls. Can anyone suggest what I might be missing? Thanks.

1
The TPanel demo you linked to passes Panel1.Handle instead of the form's Handle. The target can be any TWinControl.Ondrej Kelle
As @TOndrej says, plus: handles get recreated all the time as a result of changes to a control's properties. You may have to override the CreateWindowHandle and DestroyWindowHandle of your target control to Register/Revoke it as a drop target. Oh, and in my code I use WindowHandle instead of Handle, but I don't think that should make any real difference.Marjan Venema
@TOndrej Yes, I used the demo code unmodified after placing a new TPanel (Panel1) on my embedded form. Should that have worked?Brian Frost
@Marjan: I never need to revoke. The Panel demo should have worked though, surely?Brian Frost

1 Answers

0
votes

As Marjan (and others) commented above, this turned out to be a Windows handle issue. Moving 'DragAcceptFiles()' into a later event such as FormShow solved the problem.