How handle when mouse leaves form during drag and drop

0

I have my form set up to be able to drop files into a textbox, and also drag the files out of the textbox, thus clearing the textbox. The kicker is that the drag out of the textbox has to be dropped on the form. If I try to drag it outside the form, then it crashes. I would like for the drag and drop to ignore when the mouse is moved outside of the form. Any ideas? Here's the error I get when I drag the file out of the textbox and out of the form:

Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))

vb.net
asked on Stack Overflow Oct 12, 2013 by JoeB

1 Answer

0

You can keep the cursor inside of the form. Cursor.Clip

MouseDown event:

Cursor.Clip = Me.RectangleToScreen(Me.ClientRectangle)

MouseUp Event:

Cursor.Clip = Nothing
answered on Stack Overflow Oct 12, 2013 by OneFineDay • edited Oct 12, 2013 by OneFineDay

User contributions licensed under CC BY-SA 3.0