Solved

CFileDialog::DoModal Failure when using OFN_ENABLETEMPLATE

Posted on 2008-10-09
3
1,389 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
[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
  • 2
3 Comments
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 22685512
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
ID: 22956326
knock, knock?
0
 

Accepted Solution

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

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

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Suggested Courses

710 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