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() 
{
    CFileDialog::OnInitDialog();
    
    // heres the code to enable detail view

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

    // thats it !!

    return TRUE;
}


Comments

  • 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 ??

    Reply
  • 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

      yes

      Reply
    Reply
  • 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?
    Thanks.

    Reply
  • 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


    Hi!

    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.

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

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

    Originally posted by: Rajneesh

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

    Reply
  • 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.

    Bernie

    Reply
  • 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.

      Reply
    Reply
  • This rocks !

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

    Originally posted by: Yair Konfino

    what i needed.
    works great.
    thanks a lot.

    Reply
  • 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 ,
    Alex

    Reply
  • 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>

    int id = FCIDM_BROWSERFIRST + FVM_DETAILS;


    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • 10 Rules that Make or Break Enterprise App Development Projects In today's app-driven world, application development is a top priority. Even so, 68% of enterprise application delivery projects fail. Designing and building applications that pay for themselves and adapt to future needs is incredibly difficult. Executing one successful project is lucky, but making it a repeatable process and strategic advantage? That's where the money is. With help from our most experienced project leads and software engineers, …

  • As more and more organizations migrate to the cloud, many are faced with hidden costs emerging from unexpected places. Two non-obvious and non-trivial factors can drive up costs. First are separate charges for everything from server memory to intrusion detection. Second are the high personnel costs for early-generation, manually operated clouds. These costs can rack up quickly, creating total cost of ownership (TCO) surprises. Keeping TCO low in the cloud is essentially a matter of management strategy. IT …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds