Community
    • Login

    C# GUI access

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    9 Posts 6 Posters 787 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.
    • General CoderG
      General Coder
      last edited by

      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!

      EkopalypseE 1 Reply Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @General Coder
        last edited by

        @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
        • General CoderG
          General Coder
          last edited by General Coder

          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
          • Mark OlsonM
            Mark Olson
            last edited by Mark Olson

            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

              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.

              General CoderG 1 Reply Last reply Reply Quote 1
              • General CoderG
                General Coder @myGitAlex
                last edited by

                @myGitAlex regex? sorry i dont follow

                rdipardoR 1 Reply Last reply Reply Quote 0
                • rdipardoR
                  rdipardo @General Coder
                  last edited by rdipardo

                  @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.

                  General CoderG 1 Reply Last reply Reply Quote 1
                  • General CoderG
                    General Coder @rdipardo
                    last edited by General Coder

                    @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

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @General Coder
                      last edited by PeterJones

                      @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
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors