Click here to Skip to main content
13,189,506 members (27,578 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 2 Nov 2004

Common File Dialog in Thumbnails View

, 2 Nov 2004
Rate this:
Please Sign up or sign in to vote.
An article on how to change File Dialog Initial view.


There are all these Image Preview File Dialogs out there. They are all deprecated since Windows 2000 Thumbnails view mode. (My two cents). But how to make the Dialog default to thumbnail view? Or any other view for that matter?


I'm posting this since it is something I needed. The only info I could find after some searching was for VB. Thanks to VBnet. So here is my adoption to C++. I used WTL, but MFC or any other C/C++ could pretty much copy-paste the code from FileDialogEx.H.

Using the code

In ATL/WTL, just include FileDialogEx.H and use the CFileDialogEx class where you used the CFileDialog class before. Note the last added parameter is an enum that states the Initial list view wanted. It defaults to SHVIEW_Default which means don't do anything, just let Windows be. In MFC and other frameworks, you should have the GetOpen/SaveFileDialog hooked, and at the hook routine, override the WM_NOTIFY message. There, do what the CFileDialogEx::OnNotify does. Make sure to chain back to the default processing as to not disrupt the file dialog functionality.

// Any Example of an open Handler
LRESULT OnOpen(WORD /*wNotifyCode*/, WORD /*wID*/, 
             HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    CMyFileDialog fileDlg(
        true ,          // TRUE for FileOpen, FALSE for FileSaveAs
        "*.*" ,         // LPCTSTR lpszDefExt = NULL,
        NULL ,          //,LPCTSTR lpszFileName = NULL,
        0 ,             //dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
        "All Files\0*.*",//LPCTSTR lpszFilter = NULL,
        m_hWnd ,         //HWND hWndParent = NULL
        SHVIEW_THUMBNAIL // which initial view 
    ) ;

    fileDlg.DoModal() ;
    return 0 ;

Points of Interest

The Windows Common File Dialog code does funny things with the Files-List "SHELLDLL_DefView" (OCX). It will destroy and rebuild it multiple times during the life span of the File Dialog. Mainly, the list is not available on the CDN_INITDONE Notify code where it is natural. This is why the code checks any WM_NOTIFY for the presence of the list until found, and then it rests in peace. The WM_COMMAND codes sent to the List are extracted by Spy++ and are magic numbers that could be changed, I guess, in future versions of Windows. Well, I hope MS monitors the CodeProject site and will keep them be.

Finally, this and the previous File Dialog Customization on Code-Project can give a user high degree of control over her/his File Dialog. So next time I see a Paint program with a 64x64 Image preview and defaults to icon view, I'll personally be upset with them. Now they have no good excuse.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Boaz Harrosh
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralNot working in Vista Pin
T800G13-Aug-08 11:43
memberT800G13-Aug-08 11:43 
QuestionHow to do it with MFC Pin
ralfsch7-Jul-08 3:37
memberralfsch7-Jul-08 3:37 
QuestionDo it work under XP and Vista Pin
ralfsch7-Jul-08 3:36
memberralfsch7-Jul-08 3:36 
GeneralOther Sample in MSDN Nov 04 Example Pin
Brian Lion12-Dec-05 22:47
memberBrian Lion12-Dec-05 22:47 
Generallast listview's state Pin
Martial Spirit1-Jul-05 20:23
memberMartial Spirit1-Jul-05 20:23 
GeneralDoesn't work Pin
xkret23-Jan-05 21:58
memberxkret23-Jan-05 21:58 
QuestionStolen? Pin
Cuba2-Nov-04 23:19
memberCuba2-Nov-04 23:19 
AnswerRe: Stolen? Pin
BoazHarrosh11-Nov-04 0:19
memberBoazHarrosh11-Nov-04 0:19 
AnswerRe: Stolen? Pin
RancidCrabtree12-Nov-04 5:46
memberRancidCrabtree12-Nov-04 5:46 
GeneralRe: Stolen? Pin
BoazHarrosh15-Nov-04 20:39
memberBoazHarrosh15-Nov-04 20:39 
GeneralRe: Stolen? Pin
RancidCrabtree16-Nov-04 10:14
memberRancidCrabtree16-Nov-04 10:14 
GeneralRe: Stolen? Pin
BoazHarrosh16-Nov-04 11:16
memberBoazHarrosh16-Nov-04 11:16 
AnswerRe: Stolen? Pin
Pablo Aliskevicius13-Nov-04 21:26
memberPablo Aliskevicius13-Nov-04 21:26 
AnswerRe: Stolen? Pin
armk24-Apr-05 6:34
memberarmk24-Apr-05 6:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171016.2 | Last Updated 2 Nov 2004
Article Copyright 2004 by Boaz Harrosh
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid