Community
    • Login

    Catching the SCN_UPDATEUI event in Plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    3 Posts 2 Posters 709 Views 1 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.
    • Thomas KnoefelT Offline
      Thomas Knoefel
      last edited by Thomas Knoefel

      I’m trying to capture changes in Scintilla within a Notepad++ plugin. I have used the SCN_UPDATEUI notification to detect these changes within the WM_NOTIFY message, but it doesn’t seem to work. Regardless of the changes made to the document, the plugin never hits this event. I’m curious if this is even feasible from a plugin’s perspective. Here is my current approach:

      Initialization of _hScintilla:

      void initializeScintilla() {
          int which = -1;
          ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&which);
          if (which != -1) {
              _hScintilla = (which == 0) ? nppData._scintillaMainHandle : nppData._scintillaSecondHandle;
          }
      }
      

      Handler to catch event in _hScintilla:

      case WM_NOTIFY:
      {
          NMHDR* pnmh = (NMHDR*)lParam;
      
          if (pnmh->hwndFrom == _hScintilla) { 
              SCNotification* scn = (SCNotification*)lParam;
              if (scn->nmhdr.code == SCN_UPDATEUI) { 
                  if (scn->updated & SC_UPDATE_SELECTION) { 
                      MessageBox(_hSelf, L"Changed selection", L"Changed selection", MB_OK);
                  }
              }
          }
      }
      

      Has anyone encountered a similar issue or successfully implemented this kind of event handling?

      Michael VincentM 1 Reply Last reply Reply Quote 0
      • Michael VincentM Offline
        Michael Vincent @Thomas Knoefel
        last edited by

        @Thomas-Knoefel said in Catching the SCN_UPDATEUI event in Plugin:

        I have used the SCN_UPDATEUI notification to detect these changes within the WM_NOTIFY message, but it doesn’t seem to work.

        Why not just do it the “plugin recommended way” (as per the Notepad++ example plugin):

        extern "C" __declspec( dllexport ) void beNotified( SCNotification *notifyCode )
        {
            switch (notifyCode->nmhdr.code)
            {
                case SCN_UPDATEUI:
                {
        ... do your stuff ...
        
        ...
        

        Cheers.

        Thomas KnoefelT 1 Reply Last reply Reply Quote 4
        • Thomas KnoefelT Offline
          Thomas Knoefel @Michael Vincent
          last edited by Thomas Knoefel

          @Michael-Vincent said in Catching the SCN_UPDATEUI event in Plugin:

          Why not just do it the “plugin recommended way” (as per the Notepad++ example plugin):

          Thxs, Michael. Your suggestion was exactly what I needed. It was simpler than I initially thought, yet I spent hours figuring it out.

          1 Reply Last reply Reply Quote 4

          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