├── .gitattributes
├── .gitignore
├── README.md
├── SetTheme.sln
├── SetThemeLib
├── HwndSearch.cs
├── HwndSearchTypes.cs
├── Kernel32.cs
├── PsApi.cs
├── SetThemeLib.csproj
├── Theme.cs
├── ThemesRepository.cs
├── User32.cs
├── UxTheme.cs
└── WindowTheming.cs
├── SetThemeUI
├── EditWindow.Designer.cs
├── EditWindow.cs
├── EditWindow.resx
├── HwndSearchControl.Designer.cs
├── HwndSearchControl.cs
├── HwndSearchControl.resx
├── LogControl.Designer.cs
├── LogControl.cs
├── LogControl.resx
├── MainWindow.Designer.cs
├── MainWindow.cs
├── MainWindow.resx
├── ProcessModel.cs
├── Program.cs
├── Properties
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── SelectProcessWindow.Designer.cs
├── SelectProcessWindow.cs
├── SelectProcessWindow.resx
├── SetThemeUI.csproj
├── ThemePickControl.Designer.cs
├── ThemePickControl.cs
└── ThemePickControl.resx
└── sctprev.gif
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SetTheme [](https://ci.appveyor.com/project/dz333n/winsettheme/branch/master)
2 |
3 | This program searches for windows and uses ``SetWindowTheme`` function.
4 |
--------------------------------------------------------------------------------
/SetTheme.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29920.165
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SetThemeLib", "SetThemeLib\SetThemeLib.csproj", "{F4717E4A-B9F9-48AA-960F-DB0BC69D598B}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SetThemeUI", "SetThemeUI\SetThemeUI.csproj", "{7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {F4717E4A-B9F9-48AA-960F-DB0BC69D598B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {F4717E4A-B9F9-48AA-960F-DB0BC69D598B}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {F4717E4A-B9F9-48AA-960F-DB0BC69D598B}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {F4717E4A-B9F9-48AA-960F-DB0BC69D598B}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {DD4279DD-CD93-45A3-B2CC-0B602569F2A0}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/SetThemeLib/HwndSearch.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 |
8 | namespace SetThemeLib
9 | {
10 | public class HwndSearch
11 | {
12 | ///
13 | /// Searches HWNDs and invokes Action
14 | ///
15 | public static void ForEach(HwndSearchTypes type, object[] valuesRaw, Action action, Action onFail = null)
16 | {
17 | if (type == HwndSearchTypes.Specific)
18 | {
19 | foreach (var value in valuesRaw.Cast())
20 | action(value);
21 |
22 | return;
23 | }
24 |
25 | User32.EnumWindows((mainHwnd, b) =>
26 | {
27 | if (type == HwndSearchTypes.All)
28 | action(mainHwnd);
29 | else if (type == HwndSearchTypes.ForProcess)
30 | {
31 | uint proc;
32 | User32.GetWindowThreadProcessId(mainHwnd, out proc);
33 |
34 | IntPtr procHandle = Kernel32.OpenProcess(Kernel32.ProcessAccessFlags.QueryInformation | Kernel32.ProcessAccessFlags.VirtualMemoryRead, false, (int)proc);
35 |
36 | if (procHandle == IntPtr.Zero)
37 | {
38 | var error = Marshal.GetLastWin32Error();
39 |
40 | if (error == 5) // Referencing to original SetClassicTheme we should ignore this error
41 | return true;
42 |
43 | onFail?.Invoke(mainHwnd, new Exception("Win32 error when OpenProcess: " + Marshal.GetLastWin32Error()));
44 | return true;
45 | }
46 |
47 |
48 | StringBuilder moduleName = new StringBuilder(1024);
49 | var moduleResult = PsApi.GetModuleFileNameEx(procHandle, IntPtr.Zero, moduleName, moduleName.Capacity);
50 |
51 | if (moduleResult == 0)
52 | {
53 | onFail?.Invoke(mainHwnd, new Exception("Failed to get module file name: " + moduleResult));
54 | Kernel32.CloseHandle(procHandle);
55 | return true;
56 | }
57 |
58 | Kernel32.CloseHandle(procHandle);
59 |
60 | var moduleFile = new FileInfo(moduleName.ToString());
61 |
62 | if (!valuesRaw.Select(x => x.ToString().ToLower()).Contains(moduleFile.Name.ToLower()))
63 | {
64 | return true;
65 | }
66 |
67 | action(mainHwnd);
68 | }
69 | else throw new NotImplementedException("Unknown search type: " + type);
70 |
71 | User32.EnumChildWindows(mainHwnd, (childHwnd, b2) =>
72 | {
73 | action(childHwnd);
74 | return true;
75 | }, IntPtr.Zero);
76 |
77 | return true;
78 | }, IntPtr.Zero);
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/SetThemeLib/HwndSearchTypes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SetThemeLib
7 | {
8 | public enum HwndSearchTypes
9 | {
10 | All,
11 | ForProcess,
12 | Specific
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/SetThemeLib/Kernel32.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Runtime.ConstrainedExecution;
6 | using System.Runtime.InteropServices;
7 | using System.Security;
8 | using System.Text;
9 |
10 | namespace SetThemeLib
11 | {
12 | public class Kernel32
13 | {
14 | [DllImport("kernel32.dll", SetLastError = true)]
15 | [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
16 | [SuppressUnmanagedCodeSecurity]
17 | [return: MarshalAs(UnmanagedType.Bool)]
18 | public static extern bool CloseHandle(IntPtr hObject);
19 |
20 | [DllImport("kernel32.dll", SetLastError = true)]
21 | public static extern IntPtr OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId);
22 |
23 | public static IntPtr OpenProcess(Process proc, ProcessAccessFlags flags)
24 | {
25 | return OpenProcess(flags, false, proc.Id);
26 | }
27 |
28 | [Flags]
29 | public enum ProcessAccessFlags : uint
30 | {
31 | All = 0x001F0FFF,
32 | Terminate = 0x00000001,
33 | CreateThread = 0x00000002,
34 | VirtualMemoryOperation = 0x00000008,
35 | VirtualMemoryRead = 0x00000010,
36 | VirtualMemoryWrite = 0x00000020,
37 | DuplicateHandle = 0x00000040,
38 | CreateProcess = 0x000000080,
39 | SetQuota = 0x00000100,
40 | SetInformation = 0x00000200,
41 | QueryInformation = 0x00000400,
42 | QueryLimitedInformation = 0x00001000,
43 | Synchronize = 0x00100000
44 | }
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/SetThemeLib/PsApi.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace SetThemeLib
8 | {
9 | public class PsApi
10 | {
11 | [DllImport("psapi.dll")]
12 | public static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, [Out] StringBuilder lpBaseName, [In] [MarshalAs(UnmanagedType.U4)] int nSize);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/SetThemeLib/SetThemeLib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net40
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SetThemeLib/Theme.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SetThemeLib
7 | {
8 | public class Theme
9 | {
10 | public string Value { get; private set; }
11 | public string Description { get; private set; }
12 | public Action ExtraAction { get; private set; }
13 |
14 | public Theme(string value, string description, Action extraAction = null)
15 | {
16 | Value = value;
17 | Description = description;
18 | ExtraAction = extraAction;
19 | }
20 |
21 | public override string ToString()
22 | => $"ThemeAppName: {(Value != null ? Value : "null")}";
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/SetThemeLib/ThemesRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SetThemeLib
7 | {
8 | public class ThemesRepository
9 | {
10 | public static Theme[] Themes = {
11 | new Theme(null, "Supposed to be a default theming"),
12 | new Theme(" ", "Classic theming"),
13 | new Theme("Explorer", "Gives list-view control the appearance of a Windows Explorer list"),
14 | new Theme("DarkMode_Explorer", "Seems to be dark variation of Explorer theme"),
15 | new Theme("Explorer", "Explorer + apply Win32 dark theme", WindowTheming.AllowDarkMode),
16 | new Theme("DarkMode_Explorer", "DarkMode_Explorer + apply Win32 dark theme", WindowTheming.AllowDarkMode),
17 | new Theme("Start", ""),
18 | new Theme("TaskBar", ""),
19 | new Theme("TrayNotify", ""),
20 | new Theme("TrayNotifyHoriz", ""),
21 | new Theme("TrayNotifyVert", ""),
22 | new Theme("TaskBand", ""),
23 | };
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/SetThemeLib/User32.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace SetThemeLib
8 | {
9 | public class User32
10 | {
11 | public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
12 |
13 | [DllImport("user32.dll")]
14 | [return: MarshalAs(UnmanagedType.Bool)]
15 | public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
16 |
17 | [DllImport("user32.dll")]
18 | [return: MarshalAs(UnmanagedType.Bool)]
19 | public static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
20 |
21 | [DllImport("user32.dll", SetLastError = true)]
22 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
23 |
24 | // When you don't want the ProcessId, use this overload and pass IntPtr.Zero for the second parameter
25 | [DllImport("user32.dll")]
26 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/SetThemeLib/UxTheme.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace SetThemeLib
8 | {
9 | public class UxTheme
10 | {
11 | [DllImport("uxtheme.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
12 | public static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
13 |
14 | [DllImport("uxtheme.dll", SetLastError = true, EntryPoint = "#133")]
15 | public static extern bool AllowDarkModeForWindow(IntPtr a_HWND, bool a_Allow);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/SetThemeLib/WindowTheming.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace SetThemeLib
8 | {
9 | public class WindowTheming
10 | {
11 | ///
12 | /// Sets theming for specified HWND
13 | ///
14 | public static int Set(IntPtr hwnd, Theme theme)
15 | {
16 | theme.ExtraAction?.Invoke(hwnd);
17 | var result = UxTheme.SetWindowTheme(hwnd, theme.Value, null);
18 |
19 | return result;
20 | }
21 |
22 | ///
23 | /// Applies dark theming for win32 application
24 | ///
25 | public static void AllowDarkMode(IntPtr hwnd)
26 | {
27 | UxTheme.AllowDarkModeForWindow(hwnd, true);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SetThemeUI/EditWindow.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SetThemeUI
2 | {
3 | partial class EditWindow
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.btnCancel = new System.Windows.Forms.Button();
32 | this.btnOK = new System.Windows.Forms.Button();
33 | this.label = new System.Windows.Forms.Label();
34 | this.textBox1 = new System.Windows.Forms.TextBox();
35 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
36 | this.tableLayoutPanel1.SuspendLayout();
37 | this.SuspendLayout();
38 | //
39 | // btnCancel
40 | //
41 | this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
42 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
43 | this.btnCancel.Location = new System.Drawing.Point(291, 155);
44 | this.btnCancel.Name = "btnCancel";
45 | this.btnCancel.Size = new System.Drawing.Size(75, 23);
46 | this.btnCancel.TabIndex = 0;
47 | this.btnCancel.Text = "Cancel";
48 | this.btnCancel.UseVisualStyleBackColor = true;
49 | //
50 | // btnOK
51 | //
52 | this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
53 | this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
54 | this.btnOK.Location = new System.Drawing.Point(210, 155);
55 | this.btnOK.Name = "btnOK";
56 | this.btnOK.Size = new System.Drawing.Size(75, 23);
57 | this.btnOK.TabIndex = 1;
58 | this.btnOK.Text = "OK";
59 | this.btnOK.UseVisualStyleBackColor = true;
60 | //
61 | // label
62 | //
63 | this.label.AutoSize = true;
64 | this.label.Location = new System.Drawing.Point(3, 0);
65 | this.label.Name = "label";
66 | this.label.Size = new System.Drawing.Size(35, 13);
67 | this.label.TabIndex = 2;
68 | this.label.Text = "label1";
69 | //
70 | // textBox1
71 | //
72 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
73 | | System.Windows.Forms.AnchorStyles.Left)
74 | | System.Windows.Forms.AnchorStyles.Right)));
75 | this.textBox1.Location = new System.Drawing.Point(3, 16);
76 | this.textBox1.MinimumSize = new System.Drawing.Size(348, 116);
77 | this.textBox1.Multiline = true;
78 | this.textBox1.Name = "textBox1";
79 | this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
80 | this.textBox1.Size = new System.Drawing.Size(348, 118);
81 | this.textBox1.TabIndex = 3;
82 | //
83 | // tableLayoutPanel1
84 | //
85 | this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
86 | | System.Windows.Forms.AnchorStyles.Left)
87 | | System.Windows.Forms.AnchorStyles.Right)));
88 | this.tableLayoutPanel1.AutoSize = true;
89 | this.tableLayoutPanel1.ColumnCount = 1;
90 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
91 | this.tableLayoutPanel1.Controls.Add(this.label, 0, 0);
92 | this.tableLayoutPanel1.Controls.Add(this.textBox1, 0, 1);
93 | this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12);
94 | this.tableLayoutPanel1.Name = "tableLayoutPanel1";
95 | this.tableLayoutPanel1.RowCount = 2;
96 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
97 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
98 | this.tableLayoutPanel1.Size = new System.Drawing.Size(354, 137);
99 | this.tableLayoutPanel1.TabIndex = 4;
100 | //
101 | // EditWindow
102 | //
103 | this.AcceptButton = this.btnOK;
104 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
105 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
106 | this.AutoSize = true;
107 | this.CancelButton = this.btnCancel;
108 | this.ClientSize = new System.Drawing.Size(378, 190);
109 | this.Controls.Add(this.tableLayoutPanel1);
110 | this.Controls.Add(this.btnOK);
111 | this.Controls.Add(this.btnCancel);
112 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
113 | this.MaximizeBox = false;
114 | this.MinimizeBox = false;
115 | this.Name = "EditWindow";
116 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
117 | this.Text = "Edit";
118 | this.Load += new System.EventHandler(this.EditWindow_Load);
119 | this.tableLayoutPanel1.ResumeLayout(false);
120 | this.tableLayoutPanel1.PerformLayout();
121 | this.ResumeLayout(false);
122 | this.PerformLayout();
123 |
124 | }
125 |
126 | #endregion
127 |
128 | private System.Windows.Forms.Button btnCancel;
129 | private System.Windows.Forms.Button btnOK;
130 | private System.Windows.Forms.Label label;
131 | private System.Windows.Forms.TextBox textBox1;
132 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
133 | }
134 | }
135 |
136 |
--------------------------------------------------------------------------------
/SetThemeUI/EditWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 |
10 | namespace SetThemeUI
11 | {
12 | public partial class EditWindow : Form
13 | {
14 | public EditWindow()
15 | {
16 | InitializeComponent();
17 | }
18 |
19 | public EditWindow(string title, string label, string text = "") : this()
20 | {
21 | this.label.Text = label;
22 | this.Text = title;
23 | this.textBox1.Text = text;
24 | }
25 |
26 | public string Result => textBox1.Text;
27 |
28 | private void EditWindow_Load(object sender, EventArgs e)
29 | {
30 | var pos = this.textBox1.TextLength;
31 | this.textBox1.Select(pos >= 1 ? pos - 1 : 0, 0);
32 | this.textBox1.ScrollToCaret();
33 | this.textBox1.Focus();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/SetThemeUI/EditWindow.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SetThemeUI/HwndSearchControl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SetThemeUI
2 | {
3 | partial class HwndSearchControl
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.rbAllHwnds = new System.Windows.Forms.RadioButton();
32 | this.groupBox1 = new System.Windows.Forms.GroupBox();
33 | this.BtnSelectWindows = new System.Windows.Forms.Button();
34 | this.BtnSelectProcesses = new System.Windows.Forms.Button();
35 | this.btnEditProps = new System.Windows.Forms.Button();
36 | this.rbSpecificHWNDs = new System.Windows.Forms.RadioButton();
37 | this.rbProcess = new System.Windows.Forms.RadioButton();
38 | this.groupBox1.SuspendLayout();
39 | this.SuspendLayout();
40 | //
41 | // rbAllHwnds
42 | //
43 | this.rbAllHwnds.AutoSize = true;
44 | this.rbAllHwnds.Checked = true;
45 | this.rbAllHwnds.Location = new System.Drawing.Point(6, 19);
46 | this.rbAllHwnds.Name = "rbAllHwnds";
47 | this.rbAllHwnds.Size = new System.Drawing.Size(146, 17);
48 | this.rbAllHwnds.TabIndex = 0;
49 | this.rbAllHwnds.TabStop = true;
50 | this.rbAllHwnds.Text = "Find all available HWNDs";
51 | this.rbAllHwnds.UseVisualStyleBackColor = true;
52 | this.rbAllHwnds.CheckedChanged += new System.EventHandler(this.CheckChanged);
53 | //
54 | // groupBox1
55 | //
56 | this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
57 | | System.Windows.Forms.AnchorStyles.Left)
58 | | System.Windows.Forms.AnchorStyles.Right)));
59 | this.groupBox1.Controls.Add(this.BtnSelectWindows);
60 | this.groupBox1.Controls.Add(this.BtnSelectProcesses);
61 | this.groupBox1.Controls.Add(this.btnEditProps);
62 | this.groupBox1.Controls.Add(this.rbSpecificHWNDs);
63 | this.groupBox1.Controls.Add(this.rbProcess);
64 | this.groupBox1.Controls.Add(this.rbAllHwnds);
65 | this.groupBox1.Location = new System.Drawing.Point(3, 3);
66 | this.groupBox1.Name = "groupBox1";
67 | this.groupBox1.Size = new System.Drawing.Size(276, 171);
68 | this.groupBox1.TabIndex = 1;
69 | this.groupBox1.TabStop = false;
70 | this.groupBox1.Text = "HWND Search";
71 | //
72 | // BtnSelectWindows
73 | //
74 | this.BtnSelectWindows.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.5F);
75 | this.BtnSelectWindows.Location = new System.Drawing.Point(118, 62);
76 | this.BtnSelectWindows.Name = "BtnSelectWindows";
77 | this.BtnSelectWindows.Size = new System.Drawing.Size(24, 23);
78 | this.BtnSelectWindows.TabIndex = 5;
79 | this.BtnSelectWindows.Text = "...";
80 | this.BtnSelectWindows.UseVisualStyleBackColor = true;
81 | this.BtnSelectWindows.Click += new System.EventHandler(this.BtnSelectWindows_Click);
82 | //
83 | // BtnSelectProcesses
84 | //
85 | this.BtnSelectProcesses.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.5F);
86 | this.BtnSelectProcesses.Location = new System.Drawing.Point(200, 39);
87 | this.BtnSelectProcesses.Name = "BtnSelectProcesses";
88 | this.BtnSelectProcesses.Size = new System.Drawing.Size(24, 23);
89 | this.BtnSelectProcesses.TabIndex = 4;
90 | this.BtnSelectProcesses.Text = "...";
91 | this.BtnSelectProcesses.UseVisualStyleBackColor = true;
92 | this.BtnSelectProcesses.Click += new System.EventHandler(this.BtnSelectProcesses_Click);
93 | //
94 | // btnEditProps
95 | //
96 | this.btnEditProps.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
97 | | System.Windows.Forms.AnchorStyles.Right)));
98 | this.btnEditProps.Location = new System.Drawing.Point(6, 142);
99 | this.btnEditProps.Name = "btnEditProps";
100 | this.btnEditProps.Size = new System.Drawing.Size(264, 23);
101 | this.btnEditProps.TabIndex = 3;
102 | this.btnEditProps.Text = "Edit values";
103 | this.btnEditProps.UseVisualStyleBackColor = true;
104 | this.btnEditProps.Click += new System.EventHandler(this.btnEditProps_Click);
105 | //
106 | // rbSpecificHWNDs
107 | //
108 | this.rbSpecificHWNDs.AutoSize = true;
109 | this.rbSpecificHWNDs.Location = new System.Drawing.Point(6, 65);
110 | this.rbSpecificHWNDs.Name = "rbSpecificHWNDs";
111 | this.rbSpecificHWNDs.Size = new System.Drawing.Size(106, 17);
112 | this.rbSpecificHWNDs.TabIndex = 2;
113 | this.rbSpecificHWNDs.Text = "Specific HWNDs";
114 | this.rbSpecificHWNDs.UseVisualStyleBackColor = true;
115 | this.rbSpecificHWNDs.CheckedChanged += new System.EventHandler(this.CheckChanged);
116 | //
117 | // rbProcess
118 | //
119 | this.rbProcess.AutoSize = true;
120 | this.rbProcess.Location = new System.Drawing.Point(6, 42);
121 | this.rbProcess.Name = "rbProcess";
122 | this.rbProcess.Size = new System.Drawing.Size(188, 17);
123 | this.rbProcess.TabIndex = 1;
124 | this.rbProcess.Text = "Find HWNDs for specified process";
125 | this.rbProcess.UseVisualStyleBackColor = true;
126 | this.rbProcess.CheckedChanged += new System.EventHandler(this.CheckChanged);
127 | //
128 | // HwndSearchControl
129 | //
130 | this.Controls.Add(this.groupBox1);
131 | this.Name = "HwndSearchControl";
132 | this.Size = new System.Drawing.Size(282, 177);
133 | this.groupBox1.ResumeLayout(false);
134 | this.groupBox1.PerformLayout();
135 | this.ResumeLayout(false);
136 |
137 | }
138 |
139 | #endregion
140 |
141 | private System.Windows.Forms.RadioButton rbAllHwnds;
142 | private System.Windows.Forms.GroupBox groupBox1;
143 | private System.Windows.Forms.RadioButton rbSpecificHWNDs;
144 | private System.Windows.Forms.RadioButton rbProcess;
145 | private System.Windows.Forms.Button btnEditProps;
146 | private System.Windows.Forms.Button BtnSelectWindows;
147 | private System.Windows.Forms.Button BtnSelectProcesses;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/SetThemeUI/HwndSearchControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using SetThemeLib;
10 |
11 | namespace SetThemeUI
12 | {
13 | public partial class HwndSearchControl : UserControl
14 | {
15 | public HwndSearchTypes SearchType
16 | {
17 | get
18 | {
19 | if (rbAllHwnds.Checked)
20 | return HwndSearchTypes.All;
21 | else if (rbProcess.Checked)
22 | return HwndSearchTypes.ForProcess;
23 | else if (rbSpecificHWNDs.Checked)
24 | return HwndSearchTypes.Specific;
25 | else
26 | throw new NotImplementedException("Unknown HWNDs search type");
27 | }
28 | }
29 |
30 | public List