Community
    • Login

    Catching the SCN_UPDATEUI event in Plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    3 Posts 2 Posters 290 Views
    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
      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
        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
          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors