terminate plugin programmatically when Notepad++ is closed

  • Heinz

    Heinz - 2014-01-20


    I have a plugin that shows a window\form for some userinput.

    I have found that, when I exit Notepad++ while this window is displayed, there is still a notepad++.exe process running in taskmanager even though Notepad++ was closed.

    So I wonder how I could close all my plugin's components (window) when Notepad++ is shut down?

    I have tried to catch the NPPN_SHUTDOWN event in beNotified:
    I can catch NPPN_SHUTDOWN and close the window - but still a notepad++.exe process is running.

    And I have tried to close the window in DetachProcess() - but it seems that this procedure is not called.


  • dail8859

    dail8859 - 2014-01-21

    I'll first state I am no expert on Win32 applications.

    Are you registering your window with N++ by calling NPPM_MODELESSDIALOG?

    My DoxyIt plugin has 2 window's (an About window and a Settings window) and they are both correctly closed. So you can take a look at the source code and see if that helps any. The two windows I have are based off of the Window and StaticDialog class that came with the Plugin Demo code. Hope this helps and if you have any other questions or specific ones about my source code feel free to ask.

  • Heinz

    Heinz - 2014-01-21

    Thank you for your answer.
    No, I don't register the window by calling MODELESSDIALOG.
    What I do is that I use my compiler's "ShowWindow" command.
    (This window has some controls on it like buttons, textfields for userinput.)

    But I can get the handle of the window...so maybe it's worth to experiment with MODELESSDIALOG...?
    I will try.


  • Heinz

    Heinz - 2014-01-21

    I did some tests with calling MODELESSDIALOG - but without success.

    Where should I call "sendmessage #NPPM_MODELESSDIALOGREMOVE" ?
    In DetachProcess? Or in DetachThread? Or in beNotified using "case #NPPN_SHUTDOWN" ?

    Or is NPPM_MODELESSDIALOG maybe only for dockable windows?

  • dail8859

    dail8859 - 2014-01-21

    Since I'm not familiar with the language you are using, I'll specify that according to the documentation NPPM_MODELESSDIALOGREMOVE doesn't seem to exist (maybe it does for your language?).

    I don't remove the dialog specifically, it happens whenever my global variable goes out of scope and the destructor is called, so presumably when the DLL is unloaded...but I would assume calling it during NPPN_SHUTDOWN would be fine.

    Again this is assuming that this is even the problem. It may be some other issue how the window is created with different attributes.

    • Dave Brotherstone

      You should register the dialog on open, and remove it
      in StaticDialog.cpp in destroy()


      I assume from your message you're using C#. It sounds like you've still
      got a thread running, which is causing the process to still be running.
      One thing you could do, is to run your debug version of your plugin, close
      N++, then in visual studio attach to the still running Notepad++ process.
      Click the "pause" button, and look at the threads window, and see if you
      can find what is still running. It shouldn't be to do with a dialog still
      open, but there could be weird things happening with multiple message loops.

      Alternatively, is the code somewhere public? Then we can have a look and
      see if we can see the issue.


  • Heinz

    Heinz - 2014-01-22

    but there could be weird things happening with multiple message loops

    that's it!

    After Notepad++ was shut down there was still the message loop running for the window - and that caused the notepad++.exe to keep running.

    Now I quit the message loop when Notepad++ shuts down - and everything is OK :-)

    thank you for your help