Community
    • Login

    A question about dark mode, plugins, and an owner-draw ComboBox

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    3 Posts 2 Posters 354 Views 1 Watching
    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.
    • CoisesC Offline
      Coises
      last edited by Coises

      I’m working on a plugin and I have a couple questions about dark mode. I’m hoping someone who reads this will know the answers. I have looked at the code, but I don’t really follow everything it’s doing.

      My Settings dialog uses a ComboBox with style:

      CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_TABSTOP

      I’m sending an NPPM_DARKMODESUBCLASSANDTHEME message with wParam = NppDarkMode::dmfInit at the end of my WM_INITDIALOG process in the hopes of not antagonizing users who have dark mode enabled.

      The ComboBox is fine in light mode but it is messed up in dark mode.

      • Am I correct in thinking that the dark mode subclass process does not support owner-draw combo boxes?

      • Is there a way to exempt just that one control from the processing and try to figure out myself how to set the right colors, or do I need to drop the NPPM_DARKMODESUBCLASSANDTHEME message and either stay in light mode or handle all of the dark mode processing in my code? (Staying in light mode is an option; it’s not like users have the Settings dialog open all the time. The main dialog, fortunately, doesn’t seem to have any controls the dark mode handler doesn’t like. Yet. But I may need to go to owner-draw buttons at some point, and perhaps they will have the same problem.)

      rdipardoR 1 Reply Last reply Reply Quote 0
      • rdipardoR Offline
        rdipardo @Coises
        last edited by rdipardo

        @Coises said in A question about dark mode, plugins, and an owner-draw ComboBox:

        The ComboBox is fine in light mode but it is messed up in dark mode.

        Try passing the control’s handle to the ::SetWindowTheme function provided by the uxtheme header, using L"DarkMode_CFD" as the pszSubAppName; to restore light mode, call it with the same arguments, but change pszSubAppName to a null pointer.

        Credit goes to @klaus101 for identifying the (undocumented) dark theme’s name in this post.

        P.S. The drop-down list background color may still need to be owner-drawn with an appropriate color. The only functional example I can provide is in Free Pascal, so YMMV.

        CoisesC 1 Reply Last reply Reply Quote 1
        • CoisesC Offline
          Coises @rdipardo
          last edited by

          @rdipardo said in A question about dark mode, plugins, and an owner-draw ComboBox:

          Try passing the control’s handle to the ::SetWindowTheme function provided by the uxtheme header, using L"DarkMode_CFD" as the pszSubAppName; to restore light mode, call it with the same arguments, but change pszSubAppName to a null pointer.

          Thanks, Robert. At first attempt, this doesn’t appear to solve the problem.

          The colors are right with just NPPM_DARKMODESUBCLASSANDTHEME; the problem is that the static control shows unknown text instead of the selected drop-down entry, and attempting to select from the drop-down produces bizarre highlighting and tracking instead of what is expected (and still doesn’t set the static control). Adding the SetWindowTheme call doesn’t change that. Removing NPPM_DARKMODESUBCLASSANDTHEME, of course, makes everything else light, and for the control in question, SetWindowTheme only seems to change the drop-down chevron. Interestingly, NPPM_DARKMODESUBCLASSANDTHEME does get all the colors right, including in the owner-drawn drop-down; it just breaks the functionality in the process.

          The problem goes away entirely if I remove the CBS_OWNERDRAWFIXED style (but then, of course, it doesn’t display as intended, showing the color associated with each indicator that can be selected). That’s why I feel like the problem is most likely to do with the sub-classing. I can’t find any clear documentation on how all that works. I don’t even know why the controls are being sub-classed, and not just themed. Maybe there is a way to exempt that control from sub-classing, and do whatever it is that the sub-classing does in my own code?

          A pointer to actual documentation on this design, how it works and how it is meant to be used would be wonderful, but I’m guessing no such thing exists. :-(

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors