Multiple file select in CFileDialog

Posted on 2004-08-20
Last Modified: 2013-11-20
I have a strange bug with using a subclass of CFileDialog to allow the user of my app to
select files.

I have a subclass called CFilePreDialog and basically the "standard" CFileDialog file browser pops
up and the user selects a JPEG file and then clicks "Open".  Works great.  Now, using the standard
windows feature, the user may "hold down CTRL and hilite multiple files" and then click "Open" and
all these files are selected.  This works great if the number of files is 2 or 3 or 4, but at some point
(may depend on file size? but not sure) it doesn't work.  Generally, if you try to hilite and select 8
or 10 files, it won't work.  The panel vanishes, and it acts exactly as if the user had pressed the
"cancel" button on the panel.

So what's up with this?  Why would the number of files selected matter?
Question by:tullhead
  • 4
  • 2
  • 2
LVL 44

Expert Comment

ID: 11855107
buffer problem? (space to put the selected files into)

Accepted Solution

jimwasson earned 250 total points
ID: 11855216
You need to be sure your buffer is large enough.

m_ofn.lpstrFile = stringbuffer
m_ofn.nMaxfile = length stringbuffer

Expert Comment

ID: 11855224
Oops. Sorry AndyAinscow -- I had an "old" page and didn't see your comment.
Technology Partners: 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!

LVL 44

Expert Comment

ID: 11855684
no probs.
LVL 44

Expert Comment

ID: 11855695
ps. thanks for apologies.

Author Comment

ID: 11857736
jimwasson that was exactly what I needed, it has fixed it.  Thanks.
LVL 44

Expert Comment

ID: 11868483
tullhead - if you don't understand a comment then ask for further explanation.  The second comment by jimwasson apologised for making a duplicate of what I suggested was the problem.  That should have given you a strong hint that I deserved a thanks at least.  

Author Comment

ID: 11872212
Thank you AndyAinscow - I should have thanked you before.  
But I suspected there was something too full, some buffer somewhere,
so your comment wasn't too helpful.  I gave the points to jimwasson
because he told me exactly where the problem was.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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 52
how to you can convert your project to a Maven project and the Maven plugin should download the source 1 50
sum28 challenge 31 117
Capture logon name 13 100
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 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