// This is a major hack to get the .NET's OFD to show with Thumbnail view by default! // Luckily for us this is a covert hack, and not one where we're working around a bug // in the framework or OS. // This hack works by retrieving a private property of the OFD class after it has shown // the dialog box. // Based off code found here: http://vbnet.mvps.org/index.html?code/hooks/fileopensavedlghooklvview.htm private static void EnableThumbnailView(FileDialog ofd) { // HACK: Must verify this still works with each new revision of .NET try { Type ofdType = typeof(FileDialog); FieldInfo fi = ofdType.GetField("dialogHWnd", BindingFlags.Instance | BindingFlags.NonPublic); if (fi != null) { object dialogHWndObject = fi.GetValue(ofd); IntPtr dialogHWnd = (IntPtr)dialogHWndObject; IntPtr hwndLV = SafeNativeMethods.FindWindowExW(dialogHWnd, IntPtr.Zero, "SHELLDLL_DefView", null); if (hwndLV != IntPtr.Zero) { SafeNativeMethods.SendMessageW(hwndLV, NativeConstants.WM_COMMAND, new IntPtr(NativeConstants.SHVIEW_THUMBNAIL), IntPtr.Zero); } } } catch (Exception) { // Ignore. } }