|
-
Jan 2nd, 2002, 07:13 PM
#1
Thread Starter
Frenzied Member
GetOpenFileName
Why is it when OFN_EXPLORER & OFN_ALLOWMULTISELECT are on and I do a multiple select all I get is the path back and not the files?
Code:
char szFileName[MAX_PATH];
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
szFileName[0] = 0;
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = "All Files (*.*)\0*.*\0 Text Files (*.txt)\0*.txt\0\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT;
ofn.lpstrDefExt = "*.txt"
if(!GetOpenFileName(&ofn))
{
MessageBox(NULL,"Unable to locate File","Error 32",MB_OK | MB_ICONSTOP);
return;
}
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jan 6th, 2002, 11:31 AM
#2
MSDN:
OFN_ALLOWMULTISELECT
Specifies that the File Name list box allows multiple selections. If you also set the OFN_EXPLORER flag, the dialog box uses the Explorer-style user interface; otherwise, it uses the old-style user interface.
If the user selects more than one file, the lpstrFile buffer returns the path to the current directory followed by the filenames of the selected files. The nFileOffset member is the offset, in bytes or characters, to the first filename, and the nFileExtension member is not used. For Explorer-style dialog boxes, the directory and filename strings are NULL separated, with an extra NULL character after the last filename. This format enables the Explorer-style dialogs to return long filenames that include spaces. For old-style dialog boxes, the directory and filename strings are separated by spaces and the function uses short filenames for filenames with spaces. You can use the FindFirstFile function to convert between long and short filenames.
Normal string functions won't parse this correctly.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 6th, 2002, 12:36 PM
#3
Monday Morning Lunatic
To parse that returned string:
Code:
#include <stdio.h>
int main(void) {
const char *str = "hello\0world\0other\0string\0";
const char *p = str;
while(1) {
if(*p && *(p + 1)) {
printf("%s\n", p);
}
while(*p) ++p;
++p;
if(*p == 0) break;
}
return 0;
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|