{"id":276,"date":"2008-05-11T12:02:20","date_gmt":"2008-05-11T12:02:20","guid":{"rendered":"http:\/\/6teen.ru\/?p=30"},"modified":"2008-05-11T12:02:20","modified_gmt":"2008-05-11T12:02:20","slug":"7789","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=276","title":{"rendered":"File List View in File Dialogs"},"content":{"rendered":"<p>File List View in File Dialogs<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>File List View in File Dialogs\n\n\/\/ If an application asks user to select an icon, it's\n\/\/ more convenient for the user to see list of files as\n\/\/ large icons instead of small icons. Also, for selecting\n\/\/ an image file, user will be happier to choose an image\n\/\/ by seeing the thumbnails.\n\n\/\/ The standard file dialog initialy shows the files in\n\/\/ the LIST (small icon) style, and there is no documented\n\/\/ way to change this behavior. So, if user wants to see\n\/\/ the file list in another style, she\/he should change\n\/\/ it manually by selecting the desired view style form\n\/\/ the provided popup menu.\n\n\/\/ Here is a workaround for this limitation to select the\n\/\/ reasonable view style for a file dialog.\n\ntype\n  TFileViewStyle = (fvsIcons, fvsList, fvsDetails, fvsThumbnails, fvsTiles);\n\nfunction SetFileDialogViewStyle(Handle: THandle; ViewStyle: TFileViewStyle): Boolean;\nconst\n  CommandIDs: array[TFileViewStyle] of Word = ($7029, $702B, $702C, $702D, $702E);\nvar\n  NotifyWnd: THandle;\nbegin\n  Result    := False;\n  NotifyWnd := FindWindowEx(GetParent(Handle), 0, 'SHELLDLL_DefView', nil);\n  if NotifyWnd <> 0 then\n  begin\n    SendMessage(NotifyWnd, WM_COMMAND, CommandIDs[ViewStyle], 0);\n    Result := True;\n  end;\nend;\n\n\/\/ Each time the file dialog opens, the above function should\n\/\/ be called to set the desired view style. The OnShow event\n\/\/ of the file dialogs seems to be the right place for this\n\/\/ purpose, however at that time the list is not created yet\n\/\/ and the function fails.\n\n\/\/ When the file list is created, the dialog raises two events:\n\/\/ OnFolderChange and OnSelectionChange events. We can use one\n\/\/ of these events for our purpose. However, we have to consider\n\/\/ that the function should be called just once for each show.\n\n\/\/ Here is a sample usage of the introduced function:\n\nprocedure TForm1.Button1Click(Sender: TObject);\nbegin\n  OpenDialog1.Tag := 0;\n  OpenDialog1.Execute;\nend;\n\nprocedure TForm1.OpenDialog1FolderChange(Sender: TObject);\nbegin\n  if OpenDialog1.Tag = 0 then\n  begin\n    SetFileDialogViewStyle(OpenDialog1.Handle, fvsIcons)\n    OpenDialog1.Tag := 1;\n  end;\nend;\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>File List View in File Dialogs<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[437,448],"tags":[512,66,539,595],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/276"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=276"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/276\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=276"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}