I wanted to add a menu to NPP that contain some scripts
so i wrote a script and used some win32 APIs(getMenu, InsertMenu) to add menus
i successfully managed to add a menu with some menuitems
the next step was to associate commands with those menuItems
so i use win32 "SetWindowLong" to override WNDPROC of NPP
program crashes as long as i do anything (i think it doesn't interceprt messages at all)
maybe it was because python is different process and one can't override WNDPROC
of another process?!but the return value is not zero (means sucess of the function)?! i don't know
anyway can anyone help me with this?
maybe :add wrapper for menuitems in next release?
something like notepad.addMenu(name,command)?!
thank you in advance
Without seeing the code, it's hard to tell, but it's almost certainly due to the threading requirements for Python. Python runs in the same process, but on a separate thread to the GUI - replacing the WNDPROC through Python running on a separate thread, requiring Python to effectively run (i.e. own the GIL) for each message will be at best horrendously slow, at worst, produce crashes. I've not done any win32 API stuff with Python, so I don't know how it works, but I would imagine this would be very hard to support with Python Script in it's current form.
Adding menu items is tricky, N++ code assumes it knows where each menu is. Python Script does a similar trick to get the "scripts" menu to show the current scripts in the directory, however, that's under the plugin menu, so isn't really an issue for N++. If you start adding top-level menus, N++ could get confused.
It'd be nice if N++ properly supported it, and I'd suggest that we try and add the functionality into the N++ plugin API, rather than hack it from a plugin point of view. I'll bear it in mind for the next version…
that my explain why the function actually succeeded but the program crashes
"N++ code assumes it knows where each menu is."
"we try and add the functionality into the N++ plugin API, rather than hack it from a plugin point of view"
i not bothering you , can you explain more?