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

x
?
Solved

CFileDialog::DoModal Failure when using OFN_ENABLETEMPLATE

Posted on 2008-10-09
3
Medium Priority
?
1,429 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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…
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…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 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