Ok, I have the answer:
[DllImport("user32.dll", EntryPoint="SendMessageA",
CallingConvention=CallingConvention.StdCall,CharSet=CharSet.Ansi)]
private static extern uint SendMessage(uint Hdc, uint Msg_Const, uint
wParam, uint lParam);
[DllImport("user32.dll", EntryPoint="FindWindowExA",
CallingConvention=CallingConvention.StdCall,CharSet=CharSet.Ansi)]
private static extern uint FindWindowEx(uint hwndParent, uint
hwndChildAfter, string lpszClass, string lpszWindow);
protected override void WndProc(ref Message m)
{
// Leting the Form take care off all messages.
base.WndProc(ref m);
if( m.Msg == 289 ) // Notify of message loop
{
uint dialogHandle = (uint)m.LParam; // Handle of the file dialog
if( dialogHandle != m_lastDialogHandle ) // Only when not already changed
{
// Getting the handle of the ListBox in the OpenFileDialog dialog.
uint listviewHandle = FindWindowEx(dialogHandle, 0,
"SHELLDLL_DefView", "");
// Sending message to the ListBox to set the view to Thumbnails
//Icons=0x7029, List=0x702b, Details=0x702c, Thumbnails=0x702d,
Tiles=0x702e
SendMessage(listviewHandle, 0x0111/*WM_COMMAND*/, (uint)0x702d, 0);
// Sending message to the ListBox to select all items.
SendMessage(listviewHandle, 0x0111/*WM_COMMAND*/, (uint)0x00017021,
(uint)0);
// Remember last handle
m_lastDialogHandle = dialogHandle;
}
}
}