Drag and Drop

Real Studio - 2012 Release 2.1

In my application I am using a Drag & Drop in a Push Button which is inside a Tab Panel…
Occasionally, when I am dragging a file, the file is dropped outside of the push button but within the window because of mouse stickiness.
When this happens, the application hangs and becomes unresponsive.
I need to force quit the application.
Any help ?

P.Chellappan

Possibly stuck in a repainting situation?
Check what is in the activate event, for example

There is no code in the activate or paint event.

Strange. Why don’t you use a larger Canvas for the same purpose ?

Add your file handling to the window.
Why restrict it to the button only? (Unless you have several buttons)

Size of the Window is 900x600
Size of the Tab Panel is 800x525
Size of the Drag & Drop Button is 400x80 (Quite big)
I am restricting the file handling to the button because rest of the space is used for Parameter inputs. It looks better this way.

A Push Button ? As a Drop Area ?

You’re the boss, but the choice seems… strange.

OK. I think I got it !

In the place where you deal with the Drop Object (PushButton’s DropObject ?) check where the Mouse is up and reject the drop if the Mouse is released outside of the target PushButton.

I hope this is the answer of the question.

I am using a Push Button because I am giving the user a choice of either selecting a file or dropping a file. Is there any other way of doing this ?

As it is, if I drag a file over the PushButton and drag it out and release the mouse button, the DropObject event does not fire.
Only if I release the mouse within the PushButton does it fire. So can you please explain how the above solution will work ?

Move the DropObject code to the window.
Unless you plan to allow the user to drop more than one kind of thing (in which case you can still test what kind of thing they dropped in that code anyway)

all controls above the window will pass the message through.

Doesn’t explain why things currently hang… you definitely have some code somewhere that is going into a tight loop.
If you cannot recreate this in debug mode (hit pause in the IDE when it goes unresponsive??) , add some logging code to all your methods and check what is happening many many times.

Ok. Thanks. I will try it out.

Is there any other way of doing this ?
Yes, use a Canvas to do that.

If you do so, you can add MouseEnter / MouseExit (etc. ?) to make a user report: (in the MouseEnter Event) tell the user the MouseCursor is above the Canvas and (s)he can drop the file above the Canvas. Using the MouseExit Event will allow you to set back the standard image in the Canvas Backdrop.

Using a Canvas with code in MouseEnter / MouseExit Events will allow the user to not (as much as possible) not release the Mouse outside of the Canvas and no code will be executed (unless you voluntary do that elsewhere, in the Window for example).

BTW: how the user know (s)he can drop something in your PushButton ?

Did you noticed the kind of file where the application hangs ?
In other words: you do not disclosed the kind of file you want to drop nor how you enforce it (how you reject unwanted dropped items). This may explain that.
Did you drag a folder (by error), sometimes ?