locked
File types for a dialog are not displayed... RRS feed

  • Question

  • Here's my source code...

     

    COMDLG_FILTERSPEC aFileTypes[] = {
        { L"Ray Tracing Interface files", L"*.rti" },
        { L"All files", L"*.*" }
    };
     
    pDlg->SetFileTypes ( _countof(aFileTypes), aFileTypes );
    
    

    Every item in the dialog is displaying correctly except for the "Files of type" listbox (only the extensions).  The friendly name is displayed however.  Thanks.

     


    PAC
    • Edited by PACMAN_1 Thursday, November 10, 2011 6:38 PM
    Thursday, November 10, 2011 6:29 PM

Answers

  • This may be because of Windows "hide known filetype extensions" options. The file extension can be hidden in Explorer and in File dialogs. This  is a Windows option.

    You can change it. In Windows Explorer, hit Alt to display the menu bar, then select menu tools/options, select 2nd tab, uncheck "hide file extension for known types".

    • Proposed as answer by D A M Thursday, November 10, 2011 10:25 PM
    • Marked as answer by PACMAN_1 Thursday, November 10, 2011 10:49 PM
    Thursday, November 10, 2011 10:13 PM

All replies

  • Are you sure you are compiling your code for the right version of Windows (_WIN32_WINNT >= 0x0600)? You really haven't shown enough code but I'm assuming pDlg is an IFileDialog*.
    Thursday, November 10, 2011 7:11 PM
  • I'm compiling for target version Windows 7...
    #pragma once
    
    // Including SDKDDKVer.h defines the highest available Windows platform.
    
    // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
    // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
    
    #include <SDKDDKVer.h>
    
    

    And this is the declaration for pDlg...
     
    CComPtr<IFileSaveDialog> pDlg;
    
    
    Thanks for your reply.

    PAC

    • Edited by PACMAN_1 Thursday, November 10, 2011 7:40 PM
    Thursday, November 10, 2011 7:21 PM
  • So you're compiling for Windows 7. Are you compiling on Windows 7? I'm on Windows 7 and I don't see a "Files of type" listbox, I see a "Save as type" combobox. And the code you show + the additional code required to actually make it function works OK for me.
    Thursday, November 10, 2011 8:19 PM
  • Here is what the isolated problem looks like...

    Operationally it works.  The user just can't see the extensions.  I've noticed that Paint has the same dialog layout, but VS10/SP1 has the file extensions in a list box to the right of the file name.  Maybe there is some incompatibility between Windows 7 and earlier layouts for common dialogs.  I'm caught in a snafu.  Thanks.


    PAC
    • Edited by PACMAN_1 Thursday, November 10, 2011 8:26 PM
    Thursday, November 10, 2011 8:25 PM
  • Thanks D A M,  Yes, I am on Windows 7.  Sorry about misconstruing the label for the list box, you are correct.  See the picture in my previous reply.
    PAC
    Thursday, November 10, 2011 8:33 PM
  • So when you say "operationally it works" does that mean that the filter is applied correctly? When you save the file without giving it an extension does it append the correct one? Sorry I can't be of more help but as I said it works for me. About your comment regarding VS10/SP1; I think that is an IFileOpenDialog.
    Thursday, November 10, 2011 9:27 PM
  • "Yes" to all your questions.  I even did an error check on the result of pDlg->SetFileTypes ( _countof(aFileTypes), aFileTypes ); and it returned S_OK for success, but still no extensions are shown in the "Save as type" list box.  (???)
    PAC
    Thursday, November 10, 2011 9:59 PM
  • This may be because of Windows "hide known filetype extensions" options. The file extension can be hidden in Explorer and in File dialogs. This  is a Windows option.

    You can change it. In Windows Explorer, hit Alt to display the menu bar, then select menu tools/options, select 2nd tab, uncheck "hide file extension for known types".

    • Proposed as answer by D A M Thursday, November 10, 2011 10:25 PM
    • Marked as answer by PACMAN_1 Thursday, November 10, 2011 10:49 PM
    Thursday, November 10, 2011 10:13 PM
  • Looks like Pierre is correct. I always show extensions so I didn't notice that but turning them off reproduced your problem.
    Thursday, November 10, 2011 10:25 PM
  • Many thanks to Pierre and D A M...


    PAC
    Thursday, November 10, 2011 10:48 PM