Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8453593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:48:36+00:00 2026-06-10T11:48:36+00:00

I’m facing some weird (at least for me) behavior on using the Common Item

  • 0

I’m facing some weird (at least for me) behavior on using the Common Item Dialogs in my MFC Windows application running on Windows 7 or Vista.

According to the MSDN http://msdn.microsoft.com/en-us/library/windows/desktop/bb776913(v=vs.85).aspx I’m using the new interfaces to display file open and save dialogs:

bool OpenFileDialog(CString& strFile, CString strTitle, CStringArray& astrFilter, CStringArray& astrFilterExtension, ULONG nFlags, HWND hParentWnd)
{
USES_CONVERSION;

INT_PTR  nResult = 0;
INT_PTR  nFilterCount = astrFilter.GetCount();

IFileDialog* pfod = 0;
HRESULT hr = ::CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfod));

if(SUCCEEDED(hr))
{
    // New dialog starting with Vista/Windows 7
    COMDLG_FILTERSPEC*  pOpenTypes = 0;

    if((nFilterCount > 0) && (nFilterCount == astrFilterExtension.GetCount()))
    {
        pOpenTypes = new COMDLG_FILTERSPEC[nFilterCount];

        for(int nIdx = 0; nIdx < nFilterCount; nIdx++)
        {
            pOpenTypes[nIdx].pszName = astrFilter[nIdx].GetBuffer();
            pOpenTypes[nIdx].pszSpec = astrFilterExtension[nIdx].GetBuffer();
        }
    }

    // Set the file types to display.
    if(pOpenTypes)
    {
        hr = pfod->SetFileTypes(nFilterCount, pOpenTypes);

        if(SUCCEEDED(hr))
            hr = pfod->SetFileTypeIndex(0);
    }

    if(!strFile.IsEmpty())
        pfod->SetFileName(strFile);

    if(!strTitle.IsEmpty())
        pfod->SetTitle(strTitle);

    if(SUCCEEDED(hr))
    {
        // Ensure the dialog only returns file system paths.
        DWORD dwFlags;
        hr = pfod->GetOptions(&dwFlags);

        if(SUCCEEDED(hr))
        {
            dwFlags |= FOS_FORCEFILESYSTEM;

            if(nFlags & OFN_FILEMUSTEXIST)
                dwFlags |= FOS_FILEMUSTEXIST;

            if(nFlags & OFN_PATHMUSTEXIST)
                dwFlags |= FOS_PATHMUSTEXIST;

            hr = pfod->SetOptions(dwFlags);

            if(SUCCEEDED(hr))
            {
                // Create an event handling object, and hook it up to the dialog.
                IFileDialogEvents*  pfde = NULL;
                DWORD dwCookie;

                // Actually only added for debugging purposes

                /*hr = CDialogEventHandler_CreateInstance(IID_PPV_ARGS(&pfde));

                if(SUCCEEDED(hr))
                {
                    // Hook up the event handler.
                    hr = pfod->Advise(pfde, &dwCookie);

                    if(!SUCCEEDED(hr))
                    {
                        pfde->Release();
                        pfde = 0;
                    }
                }*/

                // Now show the dialog. Usually called with hParent == 0
                if(hParentWnd)
                    hr = pfod->Show(::GetWindow(hParentWnd, GW_OWNER));
                else
                    hr = pfod->Show(0);

                // do something with the path when the dialog was closed...

So the dialog appears and works fine if I want to select a file from a normal drive. I can navigate through the folders and select any file I want. On leaving the dialog I also get the correct file information.

But it doesn’t work for one of the Libraries in the navigation pane on the left side. Whenever I try to select a Library like Documents, Videos or Pictures the dialog doesn’t update the right pane which shows the folder/library content.

What I noticed is that on clicking a Library in the file open/save dialog the OnFolderChanging() event of the IFileDialogEvents interface is fired but the OnFolderChange() and OnSelectionChange() are not. Those events are fired if I click and navigate on a “normal” drive like C.

I also tried to call the dialogs early in my InitInstance method to avoid possible side-effects with my other code but this didn’t help either.

Is there someone who had the same behavior and was able to resolve this?

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:48:37+00:00Added an answer on June 10, 2026 at 11:48 am

    So I finally found the answer to this issue. Creating the new MFC project for the application was the actual hint to solve this. The reason was that the “Stack reserve size” was too big. The settings in the old VS6.0 project had the stack size increased to more than 100MB. Apparently the IFileDialog based dialogs do not work properly when the reserved stack size is simply too large (other thing might don’t work also as expected). So I had to set it back to 15MB in my case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.