endungen hinzufügen beim "öffnen"- dialog
-
Tach
OPENFILENAME ofn; char szFileName[MAX_PATH]; ZeroMemory(&ofn, sizeof(ofn)); szFileName[0] = 0; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.lpstrDefExt = "txt";Wie kann ich hier, zusätzlcih zu *.txt noch andere (z.b. *.bmp, *.doc) o.ä. hinzufügen??
muss ich nur "ofn.lpstrFilter" ändern??
-
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0Bild-Dateien (*.jpg;*.bmp;*.gif;*.png)\0*.jpg;*.bmp;*.gif;*.png\0Alle Dateien (*.*)\0*.*\0\0";Ergibt:
Text Files (.txt)
Bild-Dateien (.jpg;.bmp;.gif;.png)
Alle Dateien (.*)
-
Das wars??
wofür ist denn dann das zuständig: ofn.lpstrDefExt = "txt"
??
-
Danke, funktioneirt
aber die Fragen anch dem (ofn.lpstrDefExt = "txt") besteht weiterhin
-
Das ist die "Standard" Endung.
Wählt der User . als Filter aus und gibt dann keine Datei-Endung an, wird lpstrDefExt benutzt, sofern es gesetzt ist.
-
aha, wenn er aber dann als name test.xyz eingibt, wird dann daraus test.xyz.txt??
oder wird das nur eingesetzt, wenn der User "test" eingibt??
-
MSDN schrieb:
lpstrDefExt:
Pointer to a buffer that contains the default extension. GetOpenFileName and GetSaveFileName append this extension to the file name if the user fails to type an extension. This string can be any length, but only the first three characters are appended. The string should not contain a period (.). If this member is NULL and the user fails to type an extension, no extension is appended.
-
Alles schmarrn

The api states:
-----------------
lpstrDefExt
Pointer to a buffer that contains the default extension. GetOpenFileName and GetSaveFileName append this extension to the file name if the user fails to type an extension. This string can be any length, but only the first three characters are appended. The string should not contain a period (.). If this member is NULL and the user fails to type an extension, no extension is appended.
-----------------What actually happens:
If lpstrDefExt is NULL, no extension is appended, but if it is non-null, then it uses the first extension in the filter. In the following example, wang is appended rather than bar.
ofn.lpstrFilter = "Text files (.txt)\0.wang;.foo\0All Files\0.*\0";
ofn.lpstrDefExt = "bar";Stimmt wirklich!