它有点奇怪。好的,所以我正在使用 OGRE 游戏引擎,它有一个“SceneManager”类,可以让一些文件流在后台打开。如果我在使用 GetOpenFileName() 之前使用这些流,则这些流工作正常,但是如果我尝试在 GetOpenFileName() 之后使用这些流,则发现这些流已关闭。有人能解释一下为什么 GetOpenFileName() 会杀死我的后台流吗?
String Submerge::showFileDialog(char* filters, bool savedialog, char* title)
// need to tweak flags for open/save
{
OPENFILENAME ofn ;
char szFile[255] ;
HWND hwnd = NULL;
//getOgre()->getAutoCreatedWindow()->getCustomAttribute("WINDOW", &hwnd);
ZeroMemory( &ofn , sizeof(ofn) );
ofn.hwndOwner = hwnd;
ofn.lStructSize = sizeof ( ofn );
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof( szFile );
ofn.lpstrFilter = filters ? filters : "All files\0*.*\0";
ofn.nFilterIndex =1;
ofn.lpstrFileTitle = NULL ;
ofn.nMaxFileTitle = 0 ;
ofn.lpstrInitialDir=NULL ;
if(title!=NULL)
ofn.lpstrTitle=title;
//ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
MeshLoadTest(); // this is where i use background file streams
bool success = false;
if(savedialog)
success = GetSaveFileName( &ofn );
else
success = GetOpenFileName( &ofn );
MeshLoadTest(); // this is where i use background file streams
if(!success)
return "";
String str;
str.append(ofn.lpstrFile);
return str;
return "";
}