GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 20-Jul-2004, 13:31
wschalch wschalch is offline
New Member
 
Join Date: Jul 2004
Posts: 1
wschalch is on a distinguished road
Question

CFileDialog::DoModal() blocks in Release configuration


Hello Everybody,

I have a MFC application that uses the CFileDialog class to use an Open File window.

The code I am using is the following:

CPP / C++ / C Code:
	CFileDialog fileDialog( TRUE, L"txt", L"*.txt", OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_NONETWORKBUTTON | OFN_EXPLORER, L"Text Files", this );

	int ret = fileDialog.DoModal();
	if( ret == IDOK )
	{
		m_File = fileDialog.GetPathName();

		UpdateData( FALSE );
	}

When I compile in Debug configuration everything works just fine, but in Release configuration the following happens:

1º) When I run from inside the Visual C++, it works;
2º) When I run directly from the EXE file, it blocks in the DoModal() call of the CFileDialog object;
3º) If I use the old-style file dialog box, it works just fine.

Does anyone know what migth be wrong?

Thanks,
Wagner
Last edited by JdS : 20-Jul-2004 at 17:04. Reason: Please insert [c] & [/c] tags between your example C codes
  #2  
Old 22-Oct-2004, 08:07
SpaceDudeAlien SpaceDudeAlien is offline
New Member
 
Join Date: Oct 2004
Posts: 1
SpaceDudeAlien is on a distinguished road
Lightbulb

IE 6 COM Apartment Threading Model may be the issue


Hi WSCHALCH,

I recently ran into excactly the same issue with the CFileDialog: At a customer site (of course, it couldn't happen in our lab) the application would freeze whenever somebody opened the File Save-As dialog.

After searching the web for answers, I came across a posting which I found very helpful (it's at the end of this posting).
Basically, if you have IE 6 installed and initialize the COM Apartment as multi-threaded, you may (or may not) run into troubles with the CFileDialog class (or the ::GetSaveFileName WIN32 function - it's really the same thing).
Based on that information I changed the threading model to Single Threaded and the application works beautifully ever since!

One thing though: There may be situations where IE 6 does not cause the above situation, i.e. my development PC, running Win2k Pro and IE 6. In difference to the customer site my OS has all SPs and Hotfixes loaded - and it's very likely that one of them fixed the IE 6 COM issue.

And here's the promised link:
www.codeguru.com

Have fun!
 
 

Recent GIDBlogToyota - 2008 August Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:28.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.