2010. május 17., hétfő

Open a TOpenDialog in detail view


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?


Add this code to the OnFolderChange event of the dialog:

procedure TForm1.OpenDialog1FolderChange(Sender: TObject);
  H, H2: THandle;
  H := FindWindowEx(GetParent(OpenDialog1.Handle), 0, PChar('SHELLDLL_DefView'), nil);
  H2 := FindWindowEx(H, 0, PChar('SysListView32'), nil);
  if (H <> 0) and (H2 <> 0) then
    SendMessage(H, WM_COMMAND, $702C, 0);
    PostMessage(H2, WM_KEYDOWN, VK_SPACE, 0);

Nincsenek megjegyzések:

Megjegyzés küldése