Author: Lou Adler
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:
1
2 procedure TForm1.OpenDialog1FolderChange(Sender: TObject);
3 var
4 H, H2: THandle;
5 begin
6 H := FindWindowEx(GetParent(OpenDialog1.Handle), 0, PChar('SHELLDLL_DefView'),
7 nil);
8 H2 := FindWindowEx(H, 0, PChar('SysListView32'), nil);
9 if (H <> 0) and (H2 <> 0) then
10 begin
11 SendMessage(H, WM_COMMAND, $702C, 0);
12 Windows.SetFocus(H2);
13 PostMessage(H2, WM_KEYDOWN, VK_SPACE, 0);
14 end;
15 end;
|