Solved

CFileDialog returning invalid file name after file selections from the root

Posted on 2000-05-17
6
342 Views
Last Modified: 2013-11-20
For some reason file selection goes great until I select files from the root.  The first time I select files from the root everything works as expected.  The next time I open the CFileDialog the box and DoModal for the class returns FNERR_INVALIDFILENAME.
This is the constructor:
m_pFileDialog=new CFileDialog( TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST, "All Files (*.*)|*.*||");

m_pFileDialog->m_ofn.lpstrTitle="Select Files for SoftPack";

At present this is the only action taken in response to a button click.

void CSoftwareDispatcherDlg::OnBnSoftpackAddfiles()
{
  POSITION pos;
  CString sPathFileName;
  int iret;
  DWORD dwDlgExtError;

  iret=m_pFileDialog->DoModal();
  //see cderr.h for meaning of extended errors returned by   CommDlgExtendedError();
  if(iret==IDCANCEL)
    dwDlgExtError=CommDlgExtendedError();
  pos=m_pFileDialog->GetStartPosition();
  while(pos)
  {
    sPathFileName=m_pFileDialog->GetNextPathName(pos);
    m_lbSoftPackFiles.AddString(sPathFileName);
  }
}
0
Comment
Question by:graber
[X]
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
6 Comments
 
LVL 4

Expert Comment

by:captainkirk
ID: 2817875
I can't get it to fail - seems to work fine. BTW, DoModal can only return IDOK or IDCANCEL... you must be calling GetOpenFileName() or GetSaveFileName() to get FNERR_INVALIDFILENAME returned...
0
 
LVL 2

Author Comment

by:graber
ID: 2818205
CommDlgExtendedError()  will give you the same thing.  Use it after the doModal returns IDCANCEL.
If you want Kap I will send you the source code.  You will need to comment out the Database stuff.  It uses ODBC communication level.  But the file stuff should work the same.  I have made some changes thought.  Originally the CFileDialog point was "newed" in the CDialog class constructor and deleted in destructor.
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2818233
Yeah, if you could zip up the project, the email is khutchinson@tvgnetwork.com

I'll take a look and see what's going on...

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!

 
LVL 2

Author Comment

by:graber
ID: 2818250
Adjusted points from 200 to 300
0
 
LVL 2

Author Comment

by:graber
ID: 2818251
Yeah I would give ya the points for just a code review.  I will zip and send.  Thanks Kap.
Gregg
0
 
LVL 4

Accepted Solution

by:
captainkirk earned 300 total points
ID: 2818261
no problemo...
0

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

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. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 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