Open a TOpenDialog in detail view (Views: 27)
Problem/Question/Abstract: I use the standard OpenDialog to select a file to open. To see the creation date of a file, I have to change the view to Details (in fact my preferred view) every time. I was looking for an attribute (in the Options) to configure, that always detail view is selected when the OpenDialog is activated. However I didn't find anything. Does somebody have a hint for this problem? Answer: Add this code to the OnFolderChange event of the dialog: procedure TForm1.OpenDialog1FolderChange(Sender: TObject); var H, H2: THandle; begin H := FindWindowEx(GetParent(OpenDialog1.Handle), 0, PChar('SHELLDLL_DefView'), nil); H2 := FindWindowEx(H, 0, PChar('SysListView32'), nil); if (H <> 0) and (H2 <> 0) then begin SendMessage(H, WM_COMMAND, $702C, 0); Windows.SetFocus(H2); PostMessage(H2, WM_KEYDOWN, VK_SPACE, 0); end; end; |