Catching the SCN_UPDATEUI event in Plugin
-
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?
-
@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.
-
@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.