Is there a way to use the CustomFileDialog from a plugin?
-
If a plugin wants/need to allow the user to pick a file it seems the functionality exists in npp with https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp but is that available to a plugin? There is a command https://npp-user-manual.org/docs/plugin-communication/#nppm-doopen to open a file but what if a plugin wants or needs the user to first select a file? Is there no other way than implementing functionality similar to CustomFileDialog in the plugin itself?
-
I do not believe that you can have access from the plugin to the custom file dialog already compiled into Notepad++.exe – at least, it doesn’t seem to be exposed by any of the API commands, and I don’t know of a way for a DLL to access a function from the parent EXE.
That said, rather than fully implementing your own version, you might just be able to copy the source code for the CustomFileDialog, and compile it as part of your plugin’s DLL. I know, it has downsides (if they changed the source code, you would have to change your source code, rather than just calling their function), but it might be easier than completely re-implementing.
Or you could just use a win32api-standard file-selection dialog, like GetOpenFileName or GetSaveFileName rather than NPP’s customized version.
Caveat: I am not a plugin-authoring expert, though I have dealt heavily with the NPP messaging API, and know a tiny bit about generic win32 coding.