Detail View in FileOpen Dialog

Environment: VC5 WinNT4/Win2000 ( Should work with VC6 and other Win platforms)

I wanted to have the standard file open dialog startup in detail view by default. The code gurus showed me how to customize the file open dialog but not a single article described how to start the fileopen dialog in detail view. I saw many people had specifically asked the same question but there were no answers. So, I set myself to figure out how to do this.

You can use any of the excellent articles describing how to extend the standard fileopen dialog as a starting point. Then add a few lines of code presented below to your extended dialogs OnInitDialog() method and presto! the fileopen dialog will have the detail button ( view) activated when it is shown.

The Magic, as you can see is done by posting the WM_COMMAND message to the parent of the extended fileopen dialog ( which is really the original file open dialog) with the ID (40964) of the push button for detail view. This simulates a click of the detail button and the detail view is activated for you.

The trick is simple. But I must warn you that the id of the push button for the detail view was not documented - at least I did not find it anywhere. I used spy++ tool (comes with VC5) in message mode to discover its id. I have tested this on WinNT and Win 2000. It may not work on other platforms.

BOOL MyFileOpenDialog::OnInitDialog() 
    // heres the code to enable detail view

    CWnd *parent = GetParent();
    if ( parent != NULL ) {
       parent->PostMessage(WM_COMMAND, 40964, NULL);

    // thats it !!

    return TRUE;


  • sort by date

    Posted by darksouljedi on 06/27/2006 06:15am

    can someone help me please ? i want to sort automaticaly in my fileopen dialog. which id can help me ??

  • More Thumbnail View Inquiries

    Posted by CamasImagingGroup on 09/07/2005 12:06am

    Can anyone tell me how to programatically select Thumbnail View for the FileOpen dialog? I still haven't been able to figure this out. Thanks in advance. Darwin

    • test

      Posted by ok1997 on 09/09/2007 05:11am


  • How should I select a folder using CFileDialog?

    Posted by Legacy on 02/08/2004 12:00am

    Originally posted by: Hu Zhou

    When a folder is left-clicked in a CFileDialog the folder opens. When it is right-clicked there shows a pop-up menu with an option of Select, but choosing it still opens the folder, and the DoModal() does not return.
    How should I make a selection of a folder?

  • Is there any class for common dialogues in .NET Framework?

    Posted by Legacy on 09/26/2003 12:00am

    Originally posted by: kali prasada raju


    In my application,i want to save a file which is generated by executing some exe fine in the background.
    I want to prompt the user,so that he can select a place for saving this file.Is there any FileOpen dialogue in C# like
    VB common dialoges.

    Any suggestions will be highly appreciable.

    Thanks in advance.

  • how do i add a CView to the file open dialog?

    Posted by Legacy on 07/31/2003 12:00am

    Originally posted by: Rajneesh

    I want to add a CView to the file open dialog , some thing similar to FilePreview.

  • Thumbnails view ..

    Posted by Legacy on 07/16/2003 12:00am

    Originally posted by: Bernie Mills

    I am interested in this code however would like a default of thumbnails view.

    How exactly did you get the code 40964 again?

    I have tried this on VS.NET2003 and XP and it works fine.

    I would obviously like to obtain the code for Thumbail view.

    I have used spy before however I just can't seem to get it to give up the code for Thumbails.

    Any comments would be appreciated.


  • What's the ID for Thumbnails view

    Posted by Legacy on 06/09/2003 12:00am

    Originally posted by: MIchael

    What's the ID for the thumbnails view.

    • According to Microsoft's tech support, is not possible...

      Posted by franrein on 05/07/2004 09:42am

      to change to a specific view programmatically.

  • This rocks !

    Posted by Legacy on 03/11/2003 12:00am

    Originally posted by: Yair Konfino

    what i needed.
    works great.
    thanks a lot.

  • How to save the last setting ?

    Posted by Legacy on 11/26/2002 12:00am

    Originally posted by: Alex Dikopoltsev

    This is very nice. In addition I would like to record the last setting of the file dialog box , so next time I open it I will set the last record parameters (ie: details/list, size, type and etc). Is it possible ?
    ThanX ,

  • The identity of ID #40964

    Posted by Legacy on 10/23/2002 12:00am

    Originally posted by: Mike Schrag

    I believe the hardcoded WM_COMMAND value (40964)
    is actually derived from the following constants
    located in the header file: <shlobj.h>


  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date