Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing system colors for a single application (Windows, .NET)

I know I should generally avoid messing up with such system settings, but my application do already use nonstandard colors and I have no influence on that. I would like to be able to add standard .NET controls in some places, but their colors do not match. I would like to have a hack that would replace system colors for this one application. One more important thing to note is that it is a .NET application.

My (incomplete) ideas so far were:

  • To create a proxy User32.dll library with replaced GetSysColor, but it would be very tedious (731 functions to be redirected, 1 to be replaced) and I do not know how to force my application to use that particular copy.
  • To intercept somehow invocations to GetSysColors (unfortunatelly it is somewhere in the CLR I think).
  • To modify somehow .NET class SystemColors (in memory? is it possible?).

Do you have any idea, what is the best (and complete) way to achieve this?

like image 979
Michal Czardybon Avatar asked Jul 07 '09 12:07

Michal Czardybon


People also ask

How do I change the color of my Windows apps?

Select Personalization > Colors. In the list for Choose your mode, select Custom. In the list for Choose your default Windows mode, select Dark. In the list for Choose your default app mode, select Light or Dark.

How do I change the color of a form in C#?

To change the background color, select the form in Visual Studio and locate the BackColor property in the Properties panel. There are a number of ways to specify a color. Color by name - Simply type in a color name into the BackColor value field (for example Red, Yellow, Cyan etc).

How do I change the background color in Winforms?

Set the background in the Windows Forms DesignerOpen the project in Visual Studio and select the Panel control. In the Properties window, click the arrow button next to the BackColor property to display a window with three tabs. Select the Custom tab to display a palette of colors.

What is accent color in Windows 10?

The windows accent color refers to the coloring of secondary or tertiary UI elements in your operating system. Windows applies the accent color to borders, buttons, notification icons, and (optionally) your Start menu, taskbar, or window title bars.


2 Answers

I would like to be able to add standard .NET controls in some places, but their colors do not match. I would like to have a hack that would replace system colors for this one application.

That's like driving a nail with a sledgehammer.

Rather than mucking up colors within the system itself, what you can do is inherit a new control from each of the stock controls you want to use. So instead of a plain TextBox you inherit from the stock TextBox control to create your own ThemedTextBox. You setup this new control to use your app's color scheme by default, and because it is still a TextBox as far as the inheritance structure is concerned you can use it anywhere you'd use a normal textbox, including in the winforms designer.

like image 186
Joel Coehoorn Avatar answered Sep 23 '22 14:09

Joel Coehoorn


In my early days I developed a program that registered a global message hook to owner draw window borders - I could theme all windows. This should be possible for a single application, too. However, this is not a simple task.

Otherwise I don't think that this will be possible. How about using themable third party controls such as Krypton Toolkit?

like image 23
Thorsten Dittmar Avatar answered Sep 19 '22 14:09

Thorsten Dittmar