Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CFileDialog returning invalid file name after file selections from the root

Posted on 2000-05-17
6
Medium Priority
?
346 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 900 total points
ID: 2818261
no problemo...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

705 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