Community
    • Login

    Hi and I'm working on a WPF fork of NppCSharpPluginPack

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    11 Posts 4 Posters 629 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.
    • Mark OlsonM
      Mark Olson @Jonathan Johansen
      last edited by Mark Olson

      @Jonathan-Johansen

      Hi, I’m the maintainer of NppCSharpPluginPack. Glad to hear you’re interested in creating a new variant with WPF, and I hope you’re able to make something you’re happy with.

      I don’t know anything about WPF, but I do know that forms (especially docking forms) in a Notepad++ plugin have to do a bunch of annoying fiddly things to ensure that they work correctly. I recommend reading carefully through NppFormHelper.cs and FormBase.cs, because they contain a few methods that you need to create WPF versions of to ensure your forms work correctly.

      More specifically, I’m guessing that your keyboard input problem is due to not registering your form with NPPM_MODELESSDIALOG.

      Jonathan JohansenJ 1 Reply Last reply Reply Quote 2
      • Jonathan JohansenJ
        Jonathan Johansen @Mark Olson
        last edited by

        @Mark-Olson Thanks! I have been migrating your code in-place, and I do get the ElementHost’s handle and pass it to Npp.notepad.AddModelessDialog(handle);. I will read through thoroughly - I’m also thinking to check something diagnostic like Spy++?

        Jonathan JohansenJ 1 Reply Last reply Reply Quote 0
        • Jonathan JohansenJ
          Jonathan Johansen @Jonathan Johansen
          last edited by Jonathan Johansen

          Oh, it’s interesting - When I don’t call Npp.notepad.AddModelessDialog(host.Handle);, I can type into the TextBox, but I can’t copy/paste with Ctrl+C/Ctrl+V. When I do call Npp.notepad.AddModelessDialog(host.Handle);, I can’t type in, but I can copy/paste with Ctrl+C/Ctrl+V. Curious.

          Mark OlsonM 1 Reply Last reply Reply Quote 0
          • Jonathan JohansenJ
            Jonathan Johansen
            last edited by

            The fork is here: https://github.com/framlingham/NppCSharpPluginPack#

            1 Reply Last reply Reply Quote 0
            • Mark OlsonM
              Mark Olson @Jonathan Johansen
              last edited by

              @Jonathan-Johansen said in Hi and I'm working on a WPF fork of NppCSharpPluginPack:

              Oh, it’s interesting - When I don’t call Npp.notepad.AddModelessDialog(host.Handle);, I can type into the TextBox, but I can’t copy/paste with Ctrl+C/Ctrl+V. When I do call Npp.notepad.AddModelessDialog(host.Handle);, I can’t type in, but I can copy/paste with Ctrl+C/Ctrl+V. Curious.

              OK, that’s really weird. I’ve never had any problem like that before. @rdipardo is kind of a wizard when it comes to the low-level operation of forms; I’m mentioning him in the hopes that he will be able to give you some advice.

              rdipardoR 1 Reply Last reply Reply Quote 1
              • pbarneyP
                pbarney @Jonathan Johansen
                last edited by

                @Jonathan-Johansen What is the benefit of using WPF instead of what we already have?

                Jonathan JohansenJ 1 Reply Last reply Reply Quote 1
                • rdipardoR
                  rdipardo @Mark Olson
                  last edited by

                  @Mark-Olson said in Hi and I'm working on a WPF fork of NppCSharpPluginPack:

                  @rdipardo is kind of a wizard when it comes to the low-level operation of forms

                  I’m also unfamiliar with WPF, but I can suggest to @Jonathan-Johansen that hosting the docking form on a WindowsFormsHost might be a better approach. That would at least provide access to a Win32-style window procedure, useful for debugging how (of if) the WM_CHAR message is being handled.

                  Alternatively, try to expose the window handle of the existing WPF UserControl and pass that to the NPPM_MODELESSDIALOG wrapper instead of the ElementHost (as was tried already ). Or maybe there’s a way for WPF controls to broadcast messages to their child components…🤔?

                  Jonathan JohansenJ 1 Reply Last reply Reply Quote 1
                  • Jonathan JohansenJ
                    Jonathan Johansen @pbarney
                    last edited by

                    @pbarney The benefit of using WPF is that (in my opinion):

                    • I like WPF and have 6 years experience in it, but no experience with WinForms.
                    • It provides strong layout options (e.g. Grid)
                    • It provides flexible data binding
                    • It provides Styles.

                    Some links from others.

                    1 Reply Last reply Reply Quote 0
                    • Jonathan JohansenJ
                      Jonathan Johansen @rdipardo
                      last edited by

                      @rdipardo Thanks for the suggestions! WPF doesn’t have handles for controls like WinForms, and WindowsFormsHost would do the opposite of ElementHost. Thankfully, ElementHost lets you override the WndProc method (which I do here), so I’ll poke around in there for a bit.

                      Jonathan JohansenJ 1 Reply Last reply Reply Quote 0
                      • Jonathan JohansenJ
                        Jonathan Johansen @Jonathan Johansen
                        last edited by

                        Update: when I inspect the WndProc messages that come through $"{m.Msg} {m.WParam} {m.LParam}", I note these (mostly tangential, but I’d like to document them):

                        • Pressing ‘normal’ keys (e.g. a-z, arrows, 0-9, punctuation) does not send a message to the ElementHostEx, but instead (after I turned the volume up on my laptop), it somehow triggers a bell sound.
                        • Mouse click comes through with 528 513 36634781 and 33 723656 33619969
                        • Switching to another program sends 8 0 0, and switching back to NPP sends 1024 0 0
                        • Pasting into the TextBox works, but does not trigger any messages. Similarly for copying, deleting and backspacing.
                        • Opening the WPF About window sent 8 1116900 0

                        I’d like to convert the msg id to a string, I’m not familiar with their values. But there still aren’t that many messages, so perhaps I haven’t set up the dock panel correctly. I’ll try the same thing in the existing Forms version and see what comes up for comparison.

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