0

I want to get the accent color the user has selected for their PC and use it for my application, much like how Microsoft makes the start button, menus, window colors, etc. match it. How can I do this?

I'm talking about this color, by the way:

enter image description here

Klink45
  • 439
  • 1
  • 6
  • 21
  • When asking questions like this, it's helpful to mention what type of application you're creating. The answer is very likely different depending on which framework you're using. C# is a language, not a framework. – Cody Gray - on strike Aug 31 '16 at 19:31
  • Hmm yeah, the C# language always uses the .NET Framework. That isn't specific enough, either. You need to indicate if it's WinForms, WPF, UWP, etc. – Cody Gray - on strike Aug 31 '16 at 19:36
  • If I am using the Windows Form Application in Visual Studio 2015, would that be WinForms? – Klink45 Aug 31 '16 at 19:40
  • Yes, Windows Forms == WinForms. We have a tag for that, so please use it on future questions. The question I closed this as a duplicate of assumes WPF. The logic is identical, and the code in the top half of BoltClock's answer is the same. However, the bottom part, that shows a demonstration of interacting with the window is more complicated than it needs to be. WinForms actually makes this simpler, because you can obtain a native window handle (HWND) directly. – Cody Gray - on strike Sep 01 '16 at 10:18

1 Answers1

0

Try this, worked for me on a Windows 10 VM:

var color = (Color)this.Resources["SystemAccentColor"];

Here´s the source.

F.Stan
  • 553
  • 1
  • 10
  • 23
flakeyjake
  • 13
  • 1
  • 5
  • "'Form1' does not contain a definition for 'Resources' and no extension method 'Resources' accepting a first argument of type 'Form1' could be found (are you missing a using directive or an assembly reference?)" – Klink45 Aug 31 '16 at 19:36
  • 1
    It only works in UWP apps. Klink is writing a WinForms app (though he didn't mention it to start with, so you couldn't have known). That's why it doesn't work. – Cody Gray - on strike Sep 01 '16 at 10:18