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.
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