Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Setting acceptable file drops to an application

I want to set my application to accept only files having a particular extension by drag and drop. I have to use CWnd's 'DragAcceptFiles'in the InitInstance. Prior to calling this function, I have to set this filter that my application would reject files of any other extension, except the one I specified. I want this functionality to be in the application class, and not to be handled by various views. how to go about doing this?
Thanks.
0
pcasxd0
Asked:
pcasxd0
  • 3
  • 3
1 Solution
 
Tommy HuiCommented:
By calling DragAcceptFiles(), you are telling Windows that the window is a drop target. It does not tell Windows which files are acceptable and which aren't. In fact, there isn't an easy way to do this. If the UI feedback isn't important, you can skip over the files you don't want.
0
 
pcasxd0Author Commented:
How can I 'skip'over the files I don't want?
0
 
Tommy HuiCommented:
When you are processing the WM_DROPFILES message, it is up to you to go through all the files by using DragQueryFile and DragFinish(). The DragQueryFile returns the filename. If the filename is not what you want, then don't do anything with it.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
pcasxd0Author Commented:
One last doubt... can the application class handle the WM-DROPFILES command, or do I have to write an independent function like it? (I want to handle this in the app class, rather than the view classes)
Thanks..
0
 
Tommy HuiCommented:
I don't think the application class can handle it. Although you can simulate that by having the view class call a member function in the application.
0
 
pcasxd0Author Commented:
Thank you for the convincing answer. I'll do that.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now