-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from RussKie/theming
Add UxTheme.GetCurrentThemeName
- Loading branch information
Showing
5 changed files
with
115 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Jeremy W. Kuhne. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using FluentAssertions; | ||
using WInterop.Windows; | ||
using Xunit; | ||
|
||
namespace WindowsTests | ||
{ | ||
public class ThemesTests | ||
{ | ||
[Fact] | ||
public unsafe void GetCurrentThemeName() | ||
{ | ||
string themeName = Themes.GetCurrentThemeName(); | ||
|
||
// Name would be something like: C:\WINDOWS\resources\themes\Aero\Aero.msstyles | ||
|
||
themeName.Length.Should().BeGreaterThan(0); | ||
themeName.Should().EndWith(".msstyles"); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/WInterop.Desktop/Windows/Native/WindowsImports.Kernel32.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Jeremy W. Kuhne. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Runtime.InteropServices; | ||
|
||
namespace WInterop.Windows.Native | ||
{ | ||
public static partial class WindowsImports | ||
{ | ||
// https://msdn.microsoft.com/library/windows/desktop/ms679277.aspx | ||
[DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)] | ||
public static extern bool Beep( | ||
uint dwFreq, | ||
uint dwDurations); | ||
|
||
// https://docs.microsoft.com/windows/win32/api/winbase/nf-winbase-muldiv | ||
[SuppressGCTransition] | ||
[DllImport(Libraries.Kernel32, ExactSpelling = true)] | ||
public static extern int MulDiv( | ||
int nNumber, | ||
int nNumerator, | ||
int nDenominator); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/WInterop.Desktop/Windows/Native/WindowsImports.UxTheme.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Jeremy W. Kuhne. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using WInterop.Errors; | ||
using WInterop.Support; | ||
|
||
namespace WInterop.Windows.Native | ||
{ | ||
public static partial class WindowsImports | ||
{ | ||
// https://docs.microsoft.com/windows/win32/api/uxtheme/nf-uxtheme-closethemedata | ||
[DllImport(Libraries.UxTheme, ExactSpelling = true)] | ||
public static extern HResult CloseThemeData( | ||
HTHEME hTheme); | ||
|
||
// https://docs.microsoft.com/windows/win32/api/uxtheme/nf-uxtheme-getcurrentthemename | ||
[DllImport(Libraries.UxTheme, ExactSpelling = true)] | ||
public static unsafe extern HResult GetCurrentThemeName( | ||
char* pszThemeFileName, | ||
int cchMaxNameChars, | ||
char* pszColorBuff, | ||
int cchMaxColorChars, | ||
char* pszSizeBuff, | ||
int cchMaxSizeChars); | ||
|
||
// https://docs.microsoft.com/windows/win32/api/uxtheme/nf-uxtheme-isappthemed | ||
[SuppressGCTransition] | ||
[DllImport(Libraries.UxTheme, ExactSpelling = true)] | ||
public static extern IntBoolean IsAppThemed(); | ||
|
||
// https://docs.microsoft.com/windows/win32/api/uxtheme/nf-uxtheme-iscompositionactive | ||
[SuppressGCTransition] | ||
[DllImport(Libraries.UxTheme, ExactSpelling = true)] | ||
public static extern IntBoolean IsCompositionActive(); | ||
|
||
// https://docs.microsoft.com/windows/win32/api/uxtheme/nf-uxtheme-isthemeactive | ||
[SuppressGCTransition] | ||
[DllImport(Libraries.UxTheme, ExactSpelling = true)] | ||
public static extern IntBoolean IsThemeActive(); | ||
|
||
// https://docs.microsoft.com/windows/win32/api/uxtheme/nf-uxtheme-isthemepartdefined | ||
[DllImport(Libraries.UxTheme, ExactSpelling = true)] | ||
public static extern IntBoolean IsThemePartDefined( | ||
HTHEME hTheme, | ||
int iPartId, | ||
int iStateId); | ||
|
||
// https://docs.microsoft.com/windows/win32/api/uxtheme/nf-uxtheme-openthemedataex | ||
[DllImport(Libraries.UxTheme, ExactSpelling = true, CharSet = CharSet.Unicode)] | ||
public static unsafe extern HTHEME OpenThemeDataEx( | ||
HWND hwnd, | ||
char* pszClassList, | ||
uint dwFlags); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters