Ver Fonte

Merge pull request #598 from JLouis-B/filePicker_fixes

Win32Core::openFilePicker fixes
Ivan Safrin há 11 anos atrás
pai
commit
4eb4f1a96c
1 ficheiros alterados com 22 adições e 3 exclusões
  1. 22 3
      Core/Contents/Source/PolyWinCore.cpp

+ 22 - 3
Core/Contents/Source/PolyWinCore.cpp

@@ -1150,16 +1150,35 @@ std::vector<String> Win32Core::openFilePicker(std::vector<CoreFileExtension> ext
 	ofn.lpstrInitialDir=NULL;
 	ofn.lpstrInitialDir=NULL;
 
 
 	if(allowMultiple) {
 	if(allowMultiple) {
-		ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_EXPLORER;
-	} else {
 		ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_EXPLORER;
 		ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_EXPLORER;
+	} else {
+		ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_EXPLORER;
 	}
 	}
 
 
 	std::vector<String> retVec;
 	std::vector<String> retVec;
 
 
 	if(GetOpenFileName(&ofn)) {
 	if(GetOpenFileName(&ofn)) {
 		if(allowMultiple) {
 		if(allowMultiple) {
-
+			String path = fBuffer;
+
+			std::string buf;
+			for (int i = ofn.nFileOffset; i < sizeof( fBuffer ); i++)
+			{
+				if (fBuffer[i] != NULL)
+					buf.push_back(fBuffer[i]);
+				else if (fBuffer[i-1] != NULL)
+				{
+					retVec.push_back(path + "/" + buf);
+					buf = "";
+				}
+				else // 2 NULL characters = no more files
+					break;
+			}
+			if (retVec.size() == 1)
+			{
+				retVec.clear();
+				retVec.push_back(path); // If only 1 file selected, path is the full path of the file
+			}
 		} else {
 		} else {
 			retVec.push_back(String(fBuffer));
 			retVec.push_back(String(fBuffer));
 		}
 		}