I have had this problem, after I call DoFileDialog() a second time, and I hover over a file, my whole program terminates with no warning or error message.
After searching this board and google I find out that this is a common problem, however, those people always fix their problems by fixing a buffer overflow problem. I'm smart enough to avoid that from the beggining. So please help! Why isn't this working more than once??Code:int DoFileDialog(HWND hwnd, BOOL bSave) { char *pszTempPath = new char[MAX_PATH]; OPENFILENAME ofn; ZeroMemory(pszTempPath, MAX_PATH); ZeroMemory(szPath, MAX_PATH); ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; ofn.lpstrFilter = "Bitmap Files\0*.bmp\0All Files\0*.*\0\0"; ofn.lpstrFile = pszTempPath; ofn.nMaxFile = MAX_PATH; ofn.lpstrDefExt = "*.bmp"; ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; ofn.FlagsEx = OFN_EX_NOPLACESBAR; BOOL bRet; if(bSave) bRet = GetSaveFileName(&ofn); else bRet = GetOpenFileName(&ofn); if(bRet) return FALSE; strcpy(szPath, pszTempPath); delete [] pszTempPath; return TRUE; }



LinkBack URL
About LinkBacks




