I'm working on a file organizer of sorts. The user can drag icons from the desktop into a list view, and drag items out of the list view to remove them.
Dragging icons from the desktop to the list was straightforward, it's the other part that's giving me trouble. What I want to happen is:
- User drags item
- User releases mouse button
- Application detects whether or not item was dragged outside of listview
- If it was dragged outside of the listview, remove it from the list
The problem occurs on step two. If the user drags an item outside of the form then the MouseUp event won't fire until the cursor is back over the form. It feels very unintuitive to move the mouse before your icon vanishes, and I'd really prefer the icon to disappear instantly.
I've been messing around with a bunch of Window API calls (WndProc, SetCapture, etc.), to try and detect when the user releases the mouse button, but I haven't had any luck yet. I can't help but think there must be a simpler way to do this.