GetOpenFileName, OPENFILENAME und OFN_ALLOWMULTISELECT
-
-
tust du:
nMaxFile
Type: DWORDThe size, in characters, of the buffer pointed to by lpstrFile. The buffer must be large enough to store the path and file name string or strings, including the terminating NULL character. The GetOpenFileName and GetSaveFileName functions return FALSE if the buffer is too small to contain the file information. The buffer should be at least 256 characters long.
1. ist der buffer für den PFAD. hat nichts mit den dateien an sich zu tun
2. at least => mindestens
-
unskilled schrieb:
hat nichts mit den dateien an sich zu tun
In meinen Augen schon, die werden doch in den gleichen Puffer geschrieben?
(Edit: Quote gefixt)
-
Wenn DU den Puffer auf 256 beschränkst, dann ist das so...
-
Ich hab das schon versucht, Pfad + 17 Dateien (je 12 Zeichen) + die ganzen '\0'
hier ist der Code:void OpenFileBox(HWND hWnd){ OPENFILENAME ofn; char szFileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hWnd; ofn.lpstrFilter = "Alle Dateien (*.*)\0*.*\0" "Bilder (*.jpg, *.png)\0*.jpg;*.png\0"; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT; ofn.lpstrDefExt = "*"; if(!GetOpenFileName(&ofn)) MessageBox(hWnd, "Zu viele Dateien", "Dateien", MB_OK); char item[MAX_PATH] = "\0"; int item_i = 0; for(int i = 0; i < sizeof(szFileName); ++i, ++item_i){ if(szFileName[i] != '\0'){ item[item_i] = szFileName[i]; } else if(strlen(item)){ ListBoxAddItem(item); memset(item, '\0', sizeof(item)); item_i = -1; } } }
-
tjo, dann ersetz MAX_PATH doch mal durch was größeres
-
Ist die Doku sooo schwer zu verstehen?
The buffer should be at least 256 characters long.
Nötigefalls kannst Du ja auch mal googeln was "at least" bedeutet...
http://www.dict.cc/englisch-deutsch/at+least.html
-
Hab ich schon
szFileName[1000]
ofn.nMaxFile = 1000;und troztem, die Funktion
GetOpenFileName(&ofn)
gibt false.
-
Doch jetzt klappt das. Sorry. Hab wohl vorher den speicher auf 1000 erhöht und ca. 100 Dateien eingelessen habs jetzt auf 10000 gemacht und es klappt
-