简体   繁体   中英

Can't get file dropping to work in mfc dialog

I have a simple mfc project built on a CDialog. I also have a class I call CDroppable that inherits from CStatic with an added OnDropFiles()-function.

What I do is I add a normal CStatic to my dialog, add a control variable, then change the control variable in the .h-file of the dialog to be a CDroppable instead of CStatic (I think this is fairly standard). I also modify the Accept Files behavior to true for the CStatic.

In my opinion this should mean that if I drag a file over the dialog anywhere outside the accepting window I should get the "invalid" icon, and inside the accepting window I should be able to drop it. That is at least how it worked in VS2005. However now in VS2010 I can't get it to work. The entire application displays the invalid drag icon. I can set Accept Files on the dialog itself and it will accept files correctly, but I don't want the entire dialog to accept files, I want CDroppable to accept files.

Is it some obvious thing I have missed to activate? Some setting that needs to be changed?

MFC, making simple things impossible (tm)

Actually I found what was wrong.

I had a group box around the droppable area to indicate where it was. This was obviously a stupid idea as even though I had set it to transparent which I assumed would be enough, it still was in the way of the droppable area. I had to set it to disabled and after that it magically worked.

Sorry to take your time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM