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;