From 4b6492764db1ab910ff2b7d422d30f55611131b9 Mon Sep 17 00:00:00 2001 From: dmitry Date: Mon, 5 Jul 2010 13:50:08 +0000 Subject: [PATCH] win32: updated Win7 opensave dialog library dir selection. fix #16797 git-svn-id: trunk@26471 - --- lcl/interfaces/win32/win32wsdialogs.pp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lcl/interfaces/win32/win32wsdialogs.pp b/lcl/interfaces/win32/win32wsdialogs.pp index eee6999741..9268b04afa 100644 --- a/lcl/interfaces/win32/win32wsdialogs.pp +++ b/lcl/interfaces/win32/win32wsdialogs.pp @@ -186,6 +186,24 @@ var begin FolderName := UTF16ToUTF8(DialogRec^.UnicodeFolderName); FileNames := UTF16ToUTF8(DialogRec^.UnicodeFileNames); + if FolderName='' then + begin + // On Windows 7, the SendMessageW(GetParent(Wnd), CDM_GETFOLDERPATH, 0, LPARAM(nil)) + // at UpdateStorage might fail (see #16797) + // However, the valid directory is returned in OpenFile^.lpstrFile + // + // What was the reason not to use OpenFile^.lpstrFile, since it's list + // of the selected files, without need of writting any callbacks! + FolderName:=UTF16ToUTF8(PWidechar(OpenFile^.lpstrFile)); + // Check for DirectoryExistsUTF8(FolderName) is required, because Win 7 + // sometimes returns a single file name in OpenFile^.lpstrFile, while + // OFN_ALLOWMULTISELECT is set + // to reproduce. + // 1. Allow mulitple files in OpenDialog options. Run the project. + // 2. OpenDialog.Execute -> Library -> Documens. Select a single file! + if (OpenFile^.Flags and OFN_ALLOWMULTISELECT=0) or not DirectoryExistsUTF8(FolderName) then + FolderName:=ExtractFileDir(FolderName); + end; end else begin