I'm trying to develop a plugin and I need to detect when the user opens a file or change tab on notepad + +. Is there the possibility to create an event and detect this action and how ?
I develop in C + +
Your plugin should have a extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode) function. Notepad++ notification codes have NPPN_* defines, and Scintilla notifications have SCN_* defines. For file open there is NPPN_FILEOPENED, NPPN_FILEBEFOREOPEN, NPPN_FILEBEFORELOAD, and for tab change there is NPPN_BUFFERACTIVATED.
extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
Thanks for this answer but how I should use NPPN_BUFFERACTIVATED ? Via SendMessage ? What parameters should I put ? Where I need to put this in my source code? Can I have an exemple of source code with NPPN_BUFFERACTIVATED who call a function?
You should not call NPPN_BUFFERACTIVATED, it is Notepad++ which will call your beNotified function with notifyCode->nmhdr.code having a value of NPPN_BUFFERACTIVATED (thus you should have a switch case in your function), notifyCode->nmhdr.hwndFrom will have the HWND of Notepad++ window and notifyCode->nmhdr.idFrom will have the ID of the buffer which is activated. You can look at Notepad_plus_msgs.h to have a list of all NPPN_ messages and what they contain.
Thanks for your answer. I didn't see the extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode) method in NppPluginDemo
So, now all is alright!!
Thank you again
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.