diff --git a/extern/nfd-modified/src/nfd_win.cpp b/extern/nfd-modified/src/nfd_win.cpp index 9c12c3485..c60f7a753 100644 --- a/extern/nfd-modified/src/nfd_win.cpp +++ b/extern/nfd-modified/src/nfd_win.cpp @@ -532,6 +532,9 @@ nfdresult_t NFD_OpenDialogMultiple( const std::vector& filterList, nfdselcallback_t selCallback ) { nfdresult_t nfdResult = NFD_ERROR; + NFDWinEvents* winEvents; + bool hasEvents=true; + DWORD eventID=0; HRESULT coResult = COMInit(); @@ -566,6 +569,16 @@ nfdresult_t NFD_OpenDialogMultiple( const std::vector& filterList, goto end; } + // Pass the callback + winEvents=new NFDWinEvents(selCallback); + if ( !SUCCEEDED(fileOpenDialog->Advise(winEvents,&eventID)) ) { + // error... ignore + hasEvents=false; + winEvents->Release(); + } else { + winEvents->Release(); + } + // Set a flag for multiple options DWORD dwFlags; result = fileOpenDialog->GetOptions(&dwFlags); @@ -613,8 +626,12 @@ nfdresult_t NFD_OpenDialogMultiple( const std::vector& filterList, } end: - if ( fileOpenDialog ) + if (fileOpenDialog) { + if (hasEvents) { + fileOpenDialog->Unadvise(eventID); + } fileOpenDialog->Release(); + } COMUninit(coResult);