Setting acceptable file drops to an application

Posted on 1997-10-28
Last Modified: 2013-11-20
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?
Question by:pcasxd0
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 15

Accepted Solution

Tommy Hui earned 50 total points
ID: 1308988
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.

Author Comment

ID: 1308989
How can I 'skip'over the files I don't want?
LVL 15

Expert Comment

by:Tommy Hui
ID: 1308990
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.
Industry Leaders: 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!


Author Comment

ID: 1308991
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)
LVL 15

Expert Comment

by:Tommy Hui
ID: 1308992
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.

Author Comment

ID: 1308993
Thank you for the convincing answer. I'll do that.

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 54
Installing Microsoft R server on REDHAT or SUSE Linux 4 162
has22 challenge 11 111
Problem to open Excel file 15 266
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question