如何将文件从资源管理器拖放到MFC C ++ VS2010中的两个文本框? [英] How can I drag and drop a file from explorer to two textboxes in MFC C++ VS2010 ?
本文介绍了如何将文件从资源管理器拖放到MFC C ++ VS2010中的两个文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想实现拖放到我的应用程序。但在我的情况下,我有两个文本框,我想在其中删除不同的文件。我尝试使用OnDropFiles()函数,如果我只有一个文本框,它就能成功运行。
请帮助我或建议我如何做到这一点。
提前致谢
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
推荐答案
您可以:
1.处理HDROP指向DROPFILES结构的指针,该结构作为OnDropFile()函数中的参数。请参阅 http://msdn.microsoft.com/en -us / library / windows / desktop / bb773269%28v = vs.85%29.aspx [ ^ ]
然后你可以制作你的文本框坐标和DROPFILEs结构的pt POINT之间的命中测试,以找到它已落地。
参见:
如何在您的程序和资源管理器之间实现拖放 [ ^ ]
2.或者,而不是像我想的那样处理主窗口中的drop事件,你可以处理它在文本框类中。
另外,我很惊讶你混合普通的Win32(SetDlgItemText)和MFC代码(OnDropFile())......
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())...
这篇关于如何将文件从资源管理器拖放到MFC C ++ VS2010中的两个文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文