Solved

CFileDialog returning invalid file name after file selections from the root

Posted on 2000-05-17
6
338 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
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!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 112
fix34  challenge 9 164
Authenticate using sesu from script 7 110
Increment column based of a FK 8 49
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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