Multiple file select in CFileDialog

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?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

jimwassonConnect With a Mentor Commented:
You need to be sure your buffer is large enough.

m_ofn.lpstrFile = stringbuffer
m_ofn.nMaxfile = length stringbuffer
AndyAinscowFreelance programmer / ConsultantCommented:
buffer problem? (space to put the selected files into)
Oops. Sorry AndyAinscow -- I had an "old" page and didn't see your comment.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

AndyAinscowFreelance programmer / ConsultantCommented:
no probs.
AndyAinscowFreelance programmer / ConsultantCommented:
ps. thanks for apologies.
tullheadAuthor Commented:
jimwasson that was exactly what I needed, it has fixed it.  Thanks.
AndyAinscowFreelance programmer / ConsultantCommented:
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.  
tullheadAuthor Commented:
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.
All Courses

From novice to tech pro — start learning today.