Hack Forums
[C#] Changing Theme Colors on Windows (DwmSetColorizationParameters) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Changing Theme Colors on Windows (DwmSetColorizationParameters) (/showthread.php?tid=4369039)



Changing Theme Colors on Windows (DwmSetColorizationParameters) - AlbinoDrought - Jul 30, 2014

I have uploaded my source on Github: https://github.com/AlbinoDrought/DwmColorization

Some guy made a tool to instantly change the Windows colors, and I ported the base of it (unmanaged code references) to C# and built a helper around it.

Some usage examples are:

PHP Code

<?php 
using System
.Drawing;
using AlbinoDrought;
using System.Threading;

...

ColorShiftHelper csh = new ColorShiftHelper();
csh.setColor(Color.Red);
Thread.Sleep(500);

csh.blink(Color.Yellow);
Thread.Sleep(500);

csh.blendInto(Color.Green);
Thread.Sleep(500); 
See Examples/TestForm.cs for in-use code

Here is an animation of what the original does, mine is similar (but with no real interface): http://www.gfycat.com/EqualMeagerAnglerfish

See what cool things you can make with it. So far I've made the necessary change-to-every-color-very-fast program, a tool to flash the theme color when somebody joins the Skype call I'm in, and one to blend to the color at your mouse cursor just for fun.


* - Eternal Darkness - Jul 30, 2014

Code
private ColorShiftHelper csh = new ColorShiftHelper();
      private void Form1_Load(System.Object sender, System.EventArgs e) {
      csh.blendInto(Color.Pink);
      }
      private void Form1_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) {
      csh.resetColor();
      }

Should probably include FormClosing Event that resets color, just a suggestion. I didn't realize it had a reset method at first and thought I would need to code it in. Neat Discovery. :)


* - AlbinoDrought - Jul 30, 2014

(Jul 30, 2014 08:59 PM)Eternal Darkness Wrote:  
Code
private ColorShiftHelper csh = new ColorShiftHelper();
      private void Form1_Load(System.Object sender, System.EventArgs e) {
      csh.blendInto(Color.Pink);
      }
      private void Form1_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) {
      csh.resetColor();
      }

Should probably include FormClosing Event that resets color, just a suggestion. I didn't realize it had a reset method at first and thought I would need to code it in. Neat Discovery. :)

Thanks. In the included TestForm.cs I perform a click on the reset button (as of now it only resets the theme color).

Code
 
      private void TestForm_FormClosing(object sender, FormClosingEventArgs e)
      {
      btnReset.PerformClick();
      }

      private void btnReset_Click(object sender, EventArgs e)
      {
      csh.resetColor();
      }

I did it this way incase later I added more things that needed to be reset. I can see some reasons that people would not want to reset the color, though.