Click here to Skip to main content
15,885,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I want to implement drag-and-drop to my app. But in my case,I have two textboxes and I want to drop different files in them. I tried with OnDropFiles() function, and it successfully work if I have just one textbox .
Please help me or advice me how can I do that.

Thanks in advance
Posted
Comments
[no name] 8-Apr-14 7:58am    
Advice for how to do what? If you did it for one textbox there should be no trouble at all for you to do the same thing for another textbox.
dejmk 8-Apr-14 9:26am    
I still don't know how to chose in what texbox to drop ,when I'm in "DropFiles()" function:

SetDlgItemText(IDC_EDIT_OPEN,szDroppedFile);
or
SetDlgItemText(IDC_EDIT_SAVE,szDroppedFile);
[no name] 8-Apr-14 11:00am    
Well since we cannot see your code or your monitor or read your mind, how would you expect us to know what your "DropFile" function looks like or does?

1 solution

You can either:

1. Handle the HDROP pointer to a DROPFILES structure that comes as a parameter in your OnDropFile() function. See http://msdn.microsoft.com/en-us/library/windows/desktop/bb773269%28v=vs.85%29.aspx[^]

You can then make a hit test between your textboxes coordinates and the pt POINT of the DROPFILEs structure to find in which it has landed.

See also:
How to Implement Drag and Drop Between Your Program and Explorer[^]

2. Or, instead of handling the drop event in the main window, as I suppose you did, you might handle it in the textbox classes.

On a side note, I am surprised you are mixing plain Win32 (SetDlgItemText) and MFC code (OnDropFile())...
 
Share this answer
 
v2
Comments
dejmk 19-Apr-14 3:37am    
Can you please explain more the second solution? Or give me some example?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900