Detail View in FileOpen Dialog | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Nov 21, 2001
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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;
}
CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.