Notepad++ new save dialog box
2015
07.21
Notepad++ new save dialog box
Category: Uncategorized / Tags: no tag / Add Comment
This has been bugging me for literally years; it’s the save dialog box for notepad++.
The default one is not very nice…
Now this is so much better!
How To:
TCHAR * FileDialog::doSaveDlg()
{
TCHAR dir[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, dir);
//_ofn.lpstrInitialDir = dir;
NppParameters * params = NppParameters::getInstance();
_ofn.lpstrInitialDir = params->getWorkingDir();
_ofn.Flags |= OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_ENABLESIZING;
//_ofn.Flags |= OFN_ENABLEHOOK; // Comment this line out.
_ofn.lpfnHook = OFNHookProc;
TCHAR *fn = NULL;
try {
fn = ::GetSaveFileName(&_ofn)?_fileName:NULL;
if (params->getNppGUI()._openSaveDir == dir_last)
{
::GetCurrentDirectory(MAX_PATH, dir);
params->setWorkingDir(dir);
}
} catch(std::exception e) {
::MessageBoxA(NULL, e.what(), “Exception”, MB_OK);
} catch(…) {
::MessageBox(NULL, TEXT(“GetSaveFileName crashes!!!”),
TEXT(“”), MB_OK);
}
::SetCurrentDirectory(dir);
return (fn);
}
Recompile and that’s it!
I found this solution once on the source forge np++ forums years ago, with no other
comments and very little views. Then the issue/solution came up again after the whole merge
to GitHub due to the bad practices of SF. Hopefully it will finally be recoded and put into the
release build soon. For now I’m keeping this so it’s easier to find/reference.