Hello ,I'm writing a GUI with C Win32 API and facing following issue. When I start the program and click the button for Opening the file dialog everything works fine. I can choose a file and all informations seem to fit properly into the ofn structure.
If I choose to click the button a second time without doing something else everything works fine again.
If i start my algorithm after choosing a file and wait untill it's finished i cannot choose another file. Everytime i try the program runs until the call to GetOpenFileName(&ofn) and freezes while executing this function.
The only issue i can imagine is within the HWND which is saved into ofn.hwndOwner, but i checked. Everytime the function is called the provided value for HWND is same. Moreover the GetOpenFileName function gets called by the window procedure callback function which supplies the value for HWND. Heres the code for the function which calls GetOpenFileName.
Any help would be appreciated.
LPSTR OpenFileDialog(HWND hwnd_t) {
OPENFILENAME ofn;
TCHAR szFile[MAX_PATH];
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.hwndOwner = hwnd_t;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("All files(*.*)\0*.*\0\0");
ofn.nFilterIndex = 1;
ofn.lpstrInitialDir = "D:\\casdev\\";
ofn.lpstrFileTitle = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
if (GetOpenFileName(&ofn))
{
return ofn.lpstrFile;
}
else return "";
}