Solved

CFileDialog::DoModal Failure when using OFN_ENABLETEMPLATE

Posted on 2008-10-09
3
1,351 Views
Last Modified: 2013-11-20
I recently converted my MFC code from VS2003 to VS2005. I have a custom file open save dialog (CCustomFileDialog) and I enable the template resouce as shown in code below. The custom dialog show up OK but if I do CtrlC to copy a file or delete a file from within the dialog and then cancel out from the dialog, it closes OK but it errors out (CDERR_FINDRESFAILURE in CFileDialog::DoModal) when I try to open the custom dialog again.

If I open the dialog and selct file, open it or cancel out without doing (copy, delete etc), I am able to open the custom dialog again and again without any problems. I have attached the relevant code below. I would really appreciate if somebody could please point out what the problem could be.

Note:
This happens only on some of customer computers not on development computer.
It worked fine on same customer's computer when the code was in VS2003.
CCustomFileDialog::CCustomFileDialog( ...):CFileDialog(true) 

{ 

...

m_ofn.Flags |= (OFN_ENABLETEMPLATE); 

m_ofn.lpTemplateName = MAKEINTRESOURCE (IDD_FILE_OPENSAVE); // IDD_FILE_OPENSAVE is custom file open save dialog

m_ofn.hInstance = AfxGetResourceHandle(); 

...

}
 

CCustomFileDialog *pDlg = NULL; 

pDlg = new CFileDialogSC(...); 

if (pDlg->DoModal()== IDOK)

{

...

}

char buffer[256]; 

sprintf(buffer, "DoModal Failled Error %d", CommDlgExtendedError()); 

MessageBox(NULL, buffer, "", MB_OK); 
 

delete pDlg;

Open in new window

0
Comment
Question by:scdev
  • 2
3 Comments
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
Comment Utility
The MSDN says

----------------------------------------------
CDERR_FINDRESFAILURE The common dialog box function failed to find a specified resource.
----------------------------------------------

what not really isn't surprising ;-)

I assume the error comes because the 'new' OpenFileDialog comming with VS200´8 needs some more resources which could not be found in the resources included by your (VC6) resource file. To verify that, you should check your resource includes (e. g. by opening your .rc file in the text editor). If any of these includes points to a system resource file where both VC6 and VC8 have a own resource file you might have found the issue. Then, you would need to edit the project-specific resource include path in the project properties - if any - or check for the general include paths to make the new VC8 resource folder prior to that of the VC6 path. Or you were editing the include statement so taht it was pointing to the right reedource include file.

   
0
 

Author Comment

by:scdev
Comment Utility
knock, knock?
0
 

Accepted Solution

by:
scdev earned 0 total points
Comment Utility
BAD:
m_ofn.hInstance = AfxGetResourceHandle ();

GOOD:
      m_ofn.hInstance = AfxFindResourceHandle(MAKEINTRESOURCE (IDD_FILE_OPEN), RT_DIALOG);
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now