Created
May 19, 2022 11:53
-
-
Save colhountech/7ea471e61f21410792e2ae4651548536 to your computer and use it in GitHub Desktop.
AcrylicUI Gist - Round Corners
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
#region Round Corners | |
private void RoundCorners(bool _isWindows11) | |
{ | |
if (_isWindows11) | |
{ | |
var attribute = DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE; | |
var preference = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND; | |
DwmSetWindowAttribute(this.Handle, attribute, ref preference, sizeof(uint)); | |
} | |
this.windowPanel1.RoundCorners = _isWindows11; | |
} | |
public enum DWMWINDOWATTRIBUTE | |
{ | |
DWMWA_WINDOW_CORNER_PREFERENCE = 33 | |
} | |
// The DWM_WINDOW_CORNER_PREFERENCE enum for DwmSetWindowAttribute's third parameter, which tells the function | |
// what value of the enum to set. | |
public enum DWM_WINDOW_CORNER_PREFERENCE | |
{ | |
DWMWCP_DEFAULT = 0, | |
DWMWCP_DONOTROUND = 1, | |
DWMWCP_ROUND = 2, | |
DWMWCP_ROUNDSMALL = 3 | |
} | |
// Import dwmapi.dll and define DwmSetWindowAttribute in C# corresponding to the native function. | |
[DllImport("dwmapi.dll", CharSet = CharSet.Unicode, SetLastError = true)] | |
private static extern long DwmSetWindowAttribute(IntPtr hwnd, | |
DWMWINDOWATTRIBUTE attribute, | |
ref DWM_WINDOW_CORNER_PREFERENCE pvAttribute, | |
uint cbAttribute); | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment