Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark mode, call to NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR gives incorrect color at init plug-in #10741

Closed
BdR76 opened this issue Nov 1, 2021 · 2 comments
Labels
dark mode Dark mode related issues, fixes plugin

Comments

@BdR76
Copy link
Contributor

BdR76 commented Nov 1, 2021

Description of the Issue

When set to dark mode, the call to NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR gives incorrect color at init plug-in. I'm trying to find a way to detect if Notepad++ is or is not running in dark mode, in order to set the correct color scheme for my plug-in.

Notepad++ initialises the plug-in using the call to the Dll Export setInfo. When I use the api call NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR at this moment the plug-in is initializing, then it always returns 16777215 (white) even when it's set to dark mode, so afaik that is incorrect. When I run the same api call later, after Notepad++ has started and is up and running, then it returns 4144959 (dark grey) which is correct.

Here's my code (it's C# btw)

        var test123 = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR, 0, 0);
        if (test123 <= 4210752) // #404040 dark grey roughly
        {
            // dark mode
        }
        else
        {
            // not dark mode
        };

Am I using this api incorrectly? Or is it not returning the correct value at start-up?
Is there a way around this, or should I use a different api call to detect dark-mode?

Steps to Reproduce the Issue

  1. set Notepad++ to dark mode and close
  2. plug-in uses setInfo implementation
  3. setInfo calls some plug-in initialization function
  4. the initialization function calls NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR
  5. get the return value

Expected Behavior

For dark mode the return value should be 0x3F3F3F (4144959 = dark grey)

Actual Behavior

Return value is 0xFFFFFF (16777215 = white)

Debug Information

Notepad++ v8.1.9 (32-bit)
Build time : Oct 21 2021 - 23:32:04
Path : C:\Program Files (x86)\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Home (64-bit)
OS Version : 2009
OS Build : 19042.1288
Current ANSI codepage : 1252
Plugins : ComparePlugin.dll CSVLint.dll mimeTools.dll NppConverter.dll NppExport.dll NppXmlTreeviewPlugin.dll RandomValuesNppPlugin.dll XMLTools.dll

@dail8859
Copy link
Contributor

dail8859 commented Dec 5, 2021

One recommendation is to wait for the NPPN_READY notification and see if it gives you the correct value.

@dail8859
Copy link
Contributor

Closing issue. I'm assuming Notepad++ is not fully initialized yet during setInfo(), so NPPN_READY should suffice. Please let us know if it is not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dark mode Dark mode related issues, fixes plugin
Projects
None yet
Development

No branches or pull requests

3 participants