open file dialog
open file dialog
Hey all,
I did a open file dialog and i want the save the file that the user clicked on.
I'm trying to use getfilename but it dosen't work.can you show me plz how to use it?
I did a open file dialog and i want the save the file that the user clicked on.
I'm trying to use getfilename but it dosen't work.can you show me plz how to use it?
Yeah because opendlg is a pointer pointing to nothing, so of course you will get a access violation, when you are trying to derefrence it, and the program can't access that spot in memory (0 == NULL).
.
I haven't used the UserInterface Classes yet, but i believe you have to do something like this:
.
I haven't used the UserInterface Classes yet, but i believe you have to do something like this:
Code: Select all
IGUIFileOpenDialog* opendlg = env->addFileOpenDialog(L"Please choose a file.");
const wchar_t* FileName = opendlg->getFilename();
Could the problem be that the user hasn't been able to select a file in the split second between opening the window and it checking what is being selected?
This isn't VB where the program will wait for the dialog box to be dealt with.
You would have to do the getFileName() during your event handler.
This isn't VB where the program will wait for the dialog box to be dealt with.
You would have to do the getFileName() during your event handler.
Code: Select all
if (event.EventType == EET_GUI_EVENT){
if (event.GUIEvent.EventType ==EGET_FILE_SELECTED){
const wchar_t* FileName = opendlg->getFilename();
}
}
Crud, how do I do this again?
-
- Posts: 118
- Joined: Thu Sep 18, 2003 10:05 pm
- Location: switzerland
hm could it be that you use a char outputstream instead of a wchar??Cleves wrote:...but i'm still getting numbers then the name of the file
I'm not sure if that matters with C++?
I wouldd try to convert the wchar string to a normal character string and then output it...
Code: Select all
std::string to_string(const wchar_t* msg){
std::locale loc1 ( "english" );
char str2 [255];
std::use_facet<std::ctype<wchar_t> > ( loc1 ).narrow( msg, msg + wcslen(msg), 'X', &str2[0] );
str2[wcslen(msg)] = '\0';
std::string result(str2);
return result;
}
cheers
gorgon