• Login
Community
  • Login

C# GUI access

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
9 Posts 6 Posters 1.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G
    General Coder
    last edited by Aug 7, 2024, 3:46 PM

    Hi
    I don’t know about you guys but I love to create new GUIs using windows forms and C#. I made my plugin GUI for NP++ using forms.
    But what about the rest of the official GUI NP++ has, can it be accessed through C#? So you could fill the function list or use project window via C#.

    is it possible?

    thx!

    E 1 Reply Last reply Aug 7, 2024, 4:19 PM Reply Quote 0
    • E
      Ekopalypse @General Coder
      last edited by Aug 7, 2024, 4:19 PM

      @General-Coder

      In general yes, all ui elements can be accessed via the SendMessage api, but most of the time I would say this is not a good idea if you want to be in sync with Npps view of these ui elements, as no official apis are available, meaning that any changes you make will, probably, not reach Npp which will surely lead to instability sooner or later.

      1 Reply Last reply Reply Quote 4
      • G
        General Coder
        last edited by General Coder Aug 8, 2024, 3:00 PM Aug 8, 2024, 2:58 PM

        ok so its not possible to edit the UI via C# classes but have to use SendMessage. maybe I just use the project view that way

        1 Reply Last reply Reply Quote 1
        • M
          Mark Olson
          last edited by Mark Olson Aug 8, 2024, 4:56 PM Aug 8, 2024, 4:50 PM

          In my experience, if Notepad++ doesn’t explicitly allow plugins to edit a GUI element via an NPPM_* notification, it is probably a bad idea to edit that GUI element.

          For example, it’s possible for plugins to add their menu to the Notepad++ main menu rather than being a submenu of the Plugins menu (using native Win32 APIs), but if you do that, the names of the main menu items will get messed up when you change your native language preference. On the other hand, Notepad++ gives a formal way to edit the status bar using NPPM_SETSTATUSBAR, so this can be edited safely without side effects.

          You might think “Why reinvent the wheel? The project panel looks like the kind of GUI I want to use, so I’ll just hack that!” But Notepad++ is going to expect that the project panel has a very specific structure, and you should not be surprised to get crashes or weird behavior if your modifications don’t conform to the expected structure. Get ready to spend a lot of time staring at the most arcane parts of the Notepad++ codebase.

          Speaking as an active C# plugin maintainer, I believe that native C# code is faster, easier to debug, and less likely to cause unexpected errors in Notepad++, compared to code that attempts to hack the Notepad++ GUI with the Win32 API.

          1 Reply Last reply Reply Quote 4
          • M
            myGitAlex
            last edited by Aug 9, 2024, 2:54 PM

            Hey,

            I experimented with and adapted some plugins in C# back then and still use some of them today. e.g. ‘CSharpRegexTools4Npp’ (can be found on github).
            maybe it will help you.

            G 1 Reply Last reply Aug 11, 2024, 8:58 AM Reply Quote 1
            • G
              General Coder @myGitAlex
              last edited by Aug 11, 2024, 8:58 AM

              @myGitAlex regex? sorry i dont follow

              R 1 Reply Last reply Aug 11, 2024, 5:18 PM Reply Quote 0
              • R
                rdipardo @General Coder
                last edited by rdipardo Aug 11, 2024, 5:21 PM Aug 11, 2024, 5:18 PM

                @myGitAlex regex? sorry i dont follow

                @myGitAlex is probably talking about this: https://github.com/codingseb/CSharpRegexTools4Npp

                Brand new users can’t post hyperlinks in the forum; it’s a privilege they have to earn.

                G 1 Reply Last reply Aug 11, 2024, 6:28 PM Reply Quote 1
                • G
                  General Coder @rdipardo
                  last edited by General Coder Aug 11, 2024, 6:29 PM Aug 11, 2024, 6:28 PM

                  @rdipardo I mean I dont understand what regex has to do with this topic but maybe i just don’t understand regex and N++ that well

                  P 1 Reply Last reply Aug 11, 2024, 6:37 PM Reply Quote 0
                  • P
                    PeterJones @General Coder
                    last edited by PeterJones Aug 11, 2024, 6:37 PM Aug 11, 2024, 6:37 PM

                    @General-Coder ,

                    My guess is that @myGitAlex thought that showing you another example of a GUI written in C# would be helpful – maybe assuming you were asking “how do I write any GUI for my plugin using C#”, not realizing you were asking for a very specific question about accessing specific parts of the native Notepad++ GUI from your plugin, even though they don’t have plugin API calls.

                    1 Reply Last reply Reply Quote 4
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors