Solved

strange problem with CFileDialog

Posted on 2002-07-07
3
271 Views
Last Modified: 2013-11-20
Hi all, i have a problem when using the CFileDialog..
i'm using the same lines of code in my software in quite a few places but in one and only one place it gives me an "Unhandled Exception" error everytime i run the line: dlg.DoModal()... can anyone tell me what is wrong AND how to fix it?

CFileDialog dlg(FALSE,"*.JPG",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"JPEG File(*.jpg)|*.jpg|");
dlg.m_ofn.lpstrTitle = "Save Sample as JPG file";
if(dlg.DoModal()!=IDOK)
{
     return;
}
0
Comment
Question by:rw8
3 Comments
 

Accepted Solution

by:
shahzadakhtar earned 100 total points
ID: 7136989
When the same line of code is working at other places and failing at one particular place, then probably you should look around the above code usage. If you can post the complete function where the above call is crashing then it would be helpful.

Try passing a valid parent window pointer in the last paramter of CFileDialog (righ now it is default to NULL)

[Shahzad}

-----------------------------------------------
Shahzad Akhtar        Tech Lead
Mindfire Solutions    www.mindfiresolutions.com
"Exceptional Off-shore software delivery"
0
 
LVL 12

Expert Comment

by:migel
ID: 7137063
Hi!
try add '|' at the end of filter string
also use def extension without wildcards:
that is
CFileDialog dlg(FALSE,"JPG",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"JPEG File(*.jpg)|*.jpg||");<<
0
 

Author Comment

by:rw8
ID: 7139316
Thanks shahzadakhtar. Yes i believe the problem was from the dialog box itself. I've just created another dialog box doing the same function and it's working fine now.
Thanks very much
0

Featured Post

Independent Software Vendors: 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

Title # Comments Views Activity
while loop over for loop 7 116
Doc'in system (example?) BA 7 120
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 113
Problem to App source 6 89
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…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…

685 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