finally implement file name hint on NFD (Windows)

for "auto-fill file name when saving"
This commit is contained in:
tildearrow 2024-09-28 00:30:16 -05:00
parent 0f5adae785
commit ab006d5d78
2 changed files with 39 additions and 10 deletions

View file

@ -466,6 +466,15 @@ nfdresult_t NFD_OpenDialog( const std::vector<std::string>& filterList,
goto end;
}
// Set the file name
if (defaultFileName!=NULL) {
std::wstring defFileName=utf8To16(defaultFileName);
result = fileOpenDialog->SetFileName(defFileName.c_str());
if ( !SUCCEEDED(result) ) {
// ignore
}
}
// Pass the callback
winEvents=new NFDWinEvents(selCallback);
if ( !SUCCEEDED(fileOpenDialog->Advise(winEvents,&eventID)) ) {
@ -577,6 +586,15 @@ nfdresult_t NFD_OpenDialogMultiple( const std::vector<std::string>& filterList,
goto end;
}
// Set the file name
if (defaultFileName!=NULL) {
std::wstring defFileName=utf8To16(defaultFileName);
result = fileOpenDialog->SetFileName(defFileName.c_str());
if ( !SUCCEEDED(result) ) {
// ignore
}
}
// Pass the callback
winEvents=new NFDWinEvents(selCallback);
if ( !SUCCEEDED(fileOpenDialog->Advise(winEvents,&eventID)) ) {
@ -686,6 +704,15 @@ nfdresult_t NFD_SaveDialog( const std::vector<std::string>& filterList,
goto end;
}
// Set the file name
if (defaultFileName!=NULL) {
std::wstring defFileName=utf8To16(defaultFileName);
result = fileSaveDialog->SetFileName(defFileName.c_str());
if ( !SUCCEEDED(result) ) {
// ignore
}
}
// Set a flag for no history
DWORD dwFlags;
result = fileSaveDialog->GetOptions(&dwFlags);