NPPM_DOOPEN: wrong return value
-
The message NPPM_DOOPEN is declared as:
#define NPPM_DOOPEN (NPPMSG + 77) // BOOL NPPM_DOOPEN(0, const TCHAR *fullPathName2Open) // fullPathName2Open indicates the full file path name to be opened. // The return value is TRUE (1) if the operation is successful, otherwise FALSE (0).The return value is correct when
fullPathName2Openis a file (path)name.
If, however, thefullPathName2Openis a folder, Notepad++ does open all the files from this folder, but NPPM_DOOPEN returns 0 ! -
I can at least confirm I am seeing the same behavior as you.
As a side note: the “documentation” in that file has more than a few errors if you actually compare them to the code :)
-
OK, I’ve found how to deal with it. At least, it’s one of possible solutions:
int nFiles = (int) SendNppMsg(NPPM_GETNBOPENFILES, 0, 0); if ( !SendNppMsg(NPPM_DOOPEN, (WPARAM) 0, (LPARAM) params.c_str()) ) { nCmdResult = CMDRESULT_FAILED; DWORD dwAttr = ::GetFileAttributes(params.c_str()); if ( (dwAttr != INVALID_FILE_ATTRIBUTES) && ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) ) { // NPPM_DOOPEN unexpectedly returns 0 when a folder is specified // as its argument, though in fact it does open all the files // from that folder. int nFilesNow = (int) SendNppMsg(NPPM_GETNBOPENFILES, 0, 0); if ( nFilesNow != nFiles ) { nCmdResult = CMDRESULT_SUCCEEDED; } } }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login