Home » Developing U++ » U++ Developers corner » Dynamic skin changes...
Re: Dynamic skin changes... [message #61204 is a reply to message #61201] |
Wed, 04 December 2024 12:48   |
Tom1
Messages: 1305 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi,
For those looking for rapid theme switching on Windows, I composed a tray utility to does just that. You may wish to put it in auto start, so it will be always available...
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#ifndef WIN32
#error Sorry, but this program is only available for Windows at this time.
#endif
struct App : TrayIcon {
typedef App CLASSNAME;
bool IsSystemThemeDark(){
return !GetWinRegInt("AppsUseLightTheme", "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", HKEY_CURRENT_USER);
}
void SetDarkTheme(){
SetWinRegInt(0, "SystemUsesLightTheme", "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", HKEY_CURRENT_USER);
SetWinRegInt(0, "AppsUseLightTheme", "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", HKEY_CURRENT_USER);
SetWinRegInt(0, "AccentColorMenu", "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent", HKEY_CURRENT_USER);
Sleep(500);
SetWinRegInt(0xff1d3f58, "AccentColorMenu", "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent", HKEY_CURRENT_USER);
}
void SetLightTheme(){
SetWinRegInt(1, "SystemUsesLightTheme", "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", HKEY_CURRENT_USER);
SetWinRegInt(1, "AppsUseLightTheme", "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", HKEY_CURRENT_USER);
SetWinRegInt(0, "AccentColorMenu", "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent", HKEY_CURRENT_USER);
Sleep(500);
SetWinRegInt(0xff1d3f58, "AccentColorMenu", "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent", HKEY_CURRENT_USER);
}
virtual void LeftUp() {
if(IsSystemThemeDark()) SetLightTheme();
else SetDarkTheme();
}
virtual void Menu(Bar& bar) {
bool dark = IsSystemThemeDark();
bar.Add("Light", [=](){ SetLightTheme(); }).Check(!dark);
bar.Add("Dark", [=](){ SetDarkTheme(); }).Check(dark);
bar.Separator();
bar.Add("Exit", [=](){ Break(); });
}
App() {
Icon(Image::Hand());
}
};
GUI_APP_MAIN
{
Ctrl::SetDarkThemeEnabled(true);
#if (UPP_VERSION>=0x20241100)
Ctrl::SkinChangeSensitive(true);
#endif
App().Run();
}
Feel free to include this in U++ or use wherever you need it.
Best regards,
Tom
EDIT: You may also wish to give it a nice tray icon instead of "Image::Hand()"
[Updated on: Wed, 04 December 2024 12:50] Report message to a moderator
|
|
|
 |
|
Dynamic skin changes...
By: mirek on Wed, 13 November 2024 23:53
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Thu, 14 November 2024 16:32
|
 |
|
Re: Dynamic skin changes...
By: mirek on Fri, 15 November 2024 09:06
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Sun, 17 November 2024 12:36
|
 |
|
Re: Dynamic skin changes...
By: mirek on Mon, 18 November 2024 14:28
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Mon, 18 November 2024 21:04
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Tue, 19 November 2024 07:44
|
 |
|
Re: Dynamic skin changes...
By: mirek on Tue, 19 November 2024 10:14
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Tue, 19 November 2024 14:22
|
 |
|
Re: Dynamic skin changes...
By: mirek on Wed, 20 November 2024 10:29
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Wed, 20 November 2024 12:23
|
 |
|
Re: Dynamic skin changes...
By: mirek on Wed, 20 November 2024 12:40
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Wed, 20 November 2024 12:57
|
 |
|
Re: Dynamic skin changes...
By: mirek on Wed, 20 November 2024 15:37
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Wed, 20 November 2024 16:16
|
 |
|
Re: Dynamic skin changes...
By: mirek on Thu, 21 November 2024 20:30
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Fri, 22 November 2024 08:40
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Fri, 22 November 2024 16:11
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Sat, 23 November 2024 18:10
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Mon, 25 November 2024 15:43
|
 |
|
Re: Dynamic skin changes...
By: mirek on Wed, 27 November 2024 11:28
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Wed, 27 November 2024 12:14
|
 |
|
Re: Dynamic skin changes...
By: mirek on Wed, 27 November 2024 12:43
|
 |
|
Re: Dynamic skin changes...
By: mirek on Wed, 27 November 2024 12:45
|
 |
|
Re: Dynamic skin changes...
By: mirek on Wed, 27 November 2024 13:06
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Wed, 27 November 2024 14:37
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Thu, 28 November 2024 10:31
|
 |
|
Re: Dynamic skin changes...
By: mirek on Thu, 28 November 2024 19:31
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Thu, 28 November 2024 20:48
|
 |
|
Re: Dynamic skin changes...
By: Didier on Thu, 28 November 2024 22:46
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Fri, 29 November 2024 09:00
|
 |
|
Re: Dynamic skin changes...
By: Didier on Thu, 28 November 2024 22:56
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Fri, 29 November 2024 09:03
|
 |
|
Re: Dynamic skin changes...
By: mirek on Fri, 29 November 2024 11:57
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Sat, 30 November 2024 13:26
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Sat, 30 November 2024 13:56
|
 |
|
Re: Dynamic skin changes...
By: mirek on Tue, 03 December 2024 20:22
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Wed, 04 December 2024 07:48
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Wed, 04 December 2024 12:48
|
 |
|
Re: Dynamic skin changes...
By: Lance on Thu, 02 January 2025 04:30
|
 |
|
Re: Dynamic skin changes...
By: mirek on Thu, 02 January 2025 04:40
|
 |
|
Re: Dynamic skin changes...
By: Lance on Thu, 02 January 2025 15:12
|
 |
|
Re: Dynamic skin changes...
By: mirek on Thu, 02 January 2025 18:10
|
 |
|
Re: Dynamic skin changes...
By: Lance on Thu, 02 January 2025 18:58
|
 |
|
Re: Dynamic skin changes...
By: mirek on Thu, 02 January 2025 20:37
|
 |
|
Re: Dynamic skin changes...
By: Lance on Fri, 03 January 2025 14:58
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Tue, 19 November 2024 08:42
|
 |
|
Re: Dynamic skin changes...
By: mirek on Tue, 19 November 2024 10:15
|
 |
|
Re: Dynamic skin changes...
By: Tom1 on Tue, 19 November 2024 10:23
|
Goto Forum:
Current Time: Wed Aug 13 21:24:31 CEST 2025
Total time taken to generate the page: 0.13548 seconds
|