Community
    • Login

    NPPM_DOOPEN: wrong return value

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    3 Posts 2 Posters 2.1k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Vitaliy DovganV Offline
      Vitaliy Dovgan
      last edited by

      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 fullPathName2Open is a file (path)name.
      If, however, the fullPathName2Open is a folder, Notepad++ does open all the files from this folder, but NPPM_DOOPEN returns 0 !

      1 Reply Last reply Reply Quote 1
      • dailD Offline
        dail
        last edited by

        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 :)

        1 Reply Last reply Reply Quote 0
        • Vitaliy DovganV Offline
          Vitaliy Dovgan
          last edited by Vitaliy Dovgan

          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;
                  }
              }
          }
          
          1 Reply Last reply Reply Quote 1

          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors