Page 1 of 1

Need help with messaging/notifications with Scintilla/Notepa

Posted: Wed Mar 27, 2013 6:29 pm
by Heinz123
Hello,

I plan to developed a simple plugin for Notepad++ and I wonder how I could add an icon to Notepadd++ to start the plugin.

I know that I need to use the „beNotified“ procedure for this and catch a certain notification there before I can add my icon.

To the "beNotified" procedure Notepad++ will send all its notifications so here you can catch a certain message and react to it – in my case I need to catch the #NPPN_TBMODIFICATION message
(https://sourceforge.net/apps/mediawiki/ ... ifications)

Now my problem is that I dont know how to write the „beNotified“ procedure in Purebasic.

I have found many snippets for other languages, for example:
In Python „beNotified“ looks like this:

Code: Select all

extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
{
	switch(notifyCode->nmhdr.code)
	{
		case NPPN_TBMODIFICATION:
			{ ....add icon here
In C:

Code: Select all

void beNotified(SciNotification *notif)
if (notifyCode->nmhdr.code == NPPN_TBMODIFICATION)   
{.... add icon here
}
I understand that I need to work with the SCNotification structure that is already defined in Purebasic

So here is what I have tried to so far (I leave all my commented attempts so you can see what I have tried so far...)

Code: Select all

;ProcedureCDLL.l beNotified(Hwnd.l , Msg.l , wParam.l , lParam.l )
;ProcedureCDLL.l beNotified(msg.l)                                
;ProcedureCDLL.l beNotified(*notify.SCNotification)   
ProcedureCDLL.l beNotified(*SCNotification)

Protected LocalSCNotification.SCNotification
  
CopyMemory(@*SCNotification, @LocalSCNotification, SizeOf(SCNotification))  ;needed? Cannt I work with the passed structure...?

;  *lpnmhdr.NMHDR         = lParam
;  *notify.SCNotification = lParam
 ;  debuglog ("*lpnmhdr\code  =" +  *lpnmhdr\code)
;  debuglog ("*notify\message=" +  *notify\message)
   
;Select Msg
;Select *xnotify\message
 Select LocalSCNotification\message
        
        Case #WM_NOTIFY
          
;              *lpnmhdr.NMHDR         = lParam
;              *notify.SCNotification = lParam
;              debuglog ("*lpnmhdr\code  =" +  *lpnmhdr\code)
;              debuglog ("*notify\message=" +  *notify\message)
            
;       Select *lpnmhdr\code
;       Select *xnotify\nmhdr\code
        Select LocalSCNotification\nmhdr\code 
                
              ; if (notifyCode.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION)  
            Case #NPPN_TBMODIFICATION
	....
But nothing works.... NPPN_TBMODIFICATION is never caught...


Heinz

Re: Need help with messaging/notifications with Scintilla/No

Posted: Wed Mar 27, 2013 7:34 pm
by idle
We need to see the relevant bits of the c header but from what you pasted the procedure should take this form

Code: Select all

ProcedureCDll beNotified(*notify.SCNotification)   
   
   If *notify

      Select *notify\message
           
         Case #WM_NOTIFY
             
            Select *notify\nmhdr\code  
                            
               Case #NPPN_TBMODIFICATION
            EndSelect 
      EndSelect 
      
      ProcedureReturn #True
      
   EndIf 
   
EndProcedure

Re: Need help with messaging/notifications with Scintilla/No

Posted: Thu Mar 28, 2013 11:28 am
by Heinz123
thank you - this has helped me a lot