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
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.
LRESULT OnOpen(WORD , WORD ,
HWND , BOOL& )
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.