Open Bk8 opened 5 years ago
I made I small patch to be able to use it, I don't really know win 32 api but the variables sent to the function where unused
ofFileDialogResult ofSystemSaveDialog(string defaultName, string fileExt){
ofFileDialogResult results;
//----------------------------------------------------------------------------------------
//------------------------------------------------------------------------------ OSX
//----------------------------------------------------------------------------------------
@autoreleasepool {
NSSavePanel * saveDialog = [NSSavePanel savePanel];
NSOpenGLContext *context = [NSOpenGLContext currentContext];
[saveDialog setMessage:[NSString stringWithUTF8String:messageName.c_str()]];
[saveDialog setNameFieldStringValue:[NSString stringWithUTF8String:defaultName.c_str()]];
NSInteger buttonClicked = [saveDialog runModal];
restoreAppWindowFocus();
[context makeCurrentContext];
if(buttonClicked == NSFileHandlingPanelOKButton){
results.filePath = string([[[saveDialog URL] path] UTF8String]);
}
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//------------------------------------------------------------------------------ windoze
//----------------------------------------------------------------------------------------
wchar_t fileName[MAX_PATH] = L"";
for(int i =0; i <defaultName.size();i++)
fileName[i] = defaultName[i];
wchar_t ext[10] = L"";
for (int i = 0; i <fileExt.size(); i++)
ext[i] = fileExt[i];
OPENFILENAMEW ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
HWND hwnd = WindowFromDC(wglGetCurrentDC());
ofn.hwndOwner = hwnd;
ofn.hInstance = GetModuleHandle(0);
ofn.nMaxFileTitle = 31;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = ext;
ofn.lpstrDefExt = ext; // we could do .rxml here?
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
ofn.lpstrTitle = L"Select Output File";
if (GetSaveFileNameW(&ofn)){
results.filePath = convertWideToNarrow(fileName);
}
Seems to have never been fixed, just ran into this issue myself. Tried to cook up a dirty fix for my own project but I can't get past an allocation crash. If someone more familiar with the windows API than me could take a crack at a more stable/permanent fix to this it'd be very appreciated 🙏
The default name and messageName parameters on the ofSystemSaveDialog and ofSystemLoadDialog functions are not working, this is a really old bug (look links below). I don't know why is not solved, help please. I'm using Windows 10 and of_v0.10.1.
https://forum.openframeworks.cc/t/ofsystemsavedialog-defaultname-messagename-have-no-influence/15264