Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Dark Mode issues (Read 2854 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Dark Mode issues

Hi all,

I am using the latest SDK 2024-12-03 version and tried to create an custom ICON via Picture Control.
It does load and display the icon with correct size dimensions ( 16x16 ) in the preferences dialog window in LIGHT mode,
but when I switch to DARK mode, the icon size is doubled ( 32x32 upscale ) and pixelated.

resource.rc:
Code: [Select]
ICON            "",IDC_CUSTOM_ICON_IMG,144,217,16,16

P.S Adding the SS_REALSIZEIMAGE flag does nothing...

-TT

Re: Icon Size Issue in Dark Mode

Reply #1
Can you please share specific icon that you're getting this behavior with? I can't seem to reproduce it.
Offending code is in SDK / libPPUI / DarkMode.cpp / CStaticHook

What exact Windows version are you running?
Microsoft Windows: We can't script here, this is bat country.

Re: Icon Size Issue in Dark Mode

Reply #2
Hi @Peter,

I am on Windows 10 x64 and actually it is with all .ICO's:


I tried to set the picture control explicitly to fixed 16x16, the same with the icon, but it has no effect.
In Spy++ the picture control has 16x16 but the icon is rendered over the frame.
Actually the icon is not doubled but it's upscaled to an even larger size, i.e 50x50.
I have 150% window scaling ( 144 DPI ) and tried to change back to 100% ( 96 DPI ) but it is the same issue.
In light mode there are no issues.

I have debugged a little bit and the issue is somewhere in:
Code: [Select]
m_dark.AddDialogWithControls(*this); // Problematic
m_dark.AddControls(*this); // Problematic
m_dark.AddDialog(*this); // OK

In the spoiler is the code I'm using with my helpers.
InitDarkMode() method is the workaround to ignore to apply that icon with dark mode.
Still not an ideal solution because the control has white background and somehow I can't
paint over it...

Spoiler (click to show/hide)


In the attachment is the firefox.ico that is in 32x32, also tried with 16x16 ico's and they have the same issue...

-TT

Re: Icon Size Issue in Dark Mode

Reply #3
Hi @Peter,

I found another issue with the dark mode controls when using the list view control with custom column sorting functionality:
Code: [Select]
CONTROL         "", IDC_ANALYSIS_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,10,10,580,265

The same as with the custom icon:
Code: [Select]
m_dark.AddDialogWithControls(*this); // Problematic
m_dark.AddControls(*this); // Problematic
m_dark.AddDialog(*this); // OK

When clicking the SysHeader32 column header, it does not sort the list.

Btw, I am using fb2k::CCoreDarkModeHooks m_dark; to save space like mentioned in the SDK.

Some code snippets:
Spoiler (click to show/hide)

The column header sorting works fine when using m_dark.AddDialog(*this);
But when using m_dark.AddDialogWithControls(*this); or m_dark.AddControls(*this); the sorting does not work anymore.

-TT

Re: Icon Size Issue in Dark Mode

Reply #4
Problem noted.

Please keep in mind that there's no apparent dark mode support in MS listview that I know of, so I replace your listview instance with an instance of my own reimplementation of it, based on my CListControl code (same class as the one driving standard playlist views etc).

You might be better off getting rid of MS listview and using CListControl directly instead.
Microsoft Windows: We can't script here, this is bat country.

Re: Icon Size Issue in Dark Mode

Reply #5
@Peter,

thanks, I'll take a look at your CListControl (found it).

There is another issue with the dark mode and related to this:
https://hydrogenaud.io/index.php/topic,126273.0.html

When using m_dark.AddDialogWithControls(*this); or m_dark.AddDialog(*this); you can not apply colors
to static text controls because it seems the dark mode hooks are preventing WM_CTLCOLORSTATIC to trigger.

Code: [Select]
// m_dark.AddDialogWithControls(*this); // Problematic
// m_dark.AddDialog(*this); // Problematic
m_dark.AddControls(*this); // OK

Spoiler (click to show/hide)

---

Here is a workaround is to handle the custom drawing yourself using the WM_DRAWITEM message:
Spoiler (click to show/hide)

---

P.S Maybe we should rename the thread from "Icon Size Issue in Dark Mode" to "Dark Mode Issues" to make life easier for other devs to discover.
I didn't want to create a new thread for each of these to have it all in one place...

-TT

Re: Icon Size Issue in Dark Mode

Reply #6
Ok, I just found out that a new foobar2000 and SDK version was released few days ago, 2025-03-07.
I have updated both, removed my workarounds and the icon and list view have been fixed, thanks Peter.

Only the latest dark mode issue with the colored text controls still remains.

-TT

Re: Icon Size Issue in Dark Mode

Reply #7
Please note that, in case it's not obvious enough:
Using libPPUI DarkMode.h methods directly = your dark mode support code is included with SDK / libPPUI, which adds to your component size but can be debugged and hotfixed on your side.
Using CCoreDarkModeHooks = you're calling the same methods but in libPPUI that's your foobar2000 install is using, so your component remains relatively small, updates to foobar2000 update dark mode support code, but you can't debug or hotfix it.

foobar2000 2.24.3 fixes the icon size issue (and so does the new SDK). Next version will fix LVS_SORTITEMS/LVS_SORTITEMSEX.

I'm investigating static colors, indeed I'm overriding all of WM_CTLCOLOR* in dialogs, I'll see if this can be fixed.
Microsoft Windows: We can't script here, this is bat country.

 

Re: Icon Size Issue in Dark Mode

Reply #8
That said, if anyone knows how to properly darken MS ListView without glitches or shimming uxtheme.dll methods, info about this would be most welcome. As you've noticed my solution for this is extremely complex and still only partial.
No, overriding OpenNcThemeData() like some do is not an acceptable solution.
Microsoft Windows: We can't script here, this is bat country.