Created
March 22, 2024 21:02
-
-
Save linadk/7f9891f45af62aa3f3165aefa7989905 to your computer and use it in GitHub Desktop.
Sets the corner rounding preferences in windows 11. Works with Tao's window handle hwnd() method.
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
#[cfg(target_os = "windows")] | |
use windows::Win32::Graphics::Dwm::{ | |
DwmSetWindowAttribute, | |
DWM_WINDOW_CORNER_PREFERENCE, | |
DWMWA_WINDOW_CORNER_PREFERENCE, | |
DWMWCP_ROUND, DWMWCP_ROUNDSMALL, DWMWCP_DEFAULT, DWMWCP_DONOTROUND, | |
}; | |
use windows::Win32::Foundation::HWND; | |
use core::mem; | |
#[repr(i32)] | |
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)] | |
pub enum CornerPreference{ | |
#[default] | |
Default = DWMWCP_DEFAULT.0, | |
DoNotRound = DWMWCP_DONOTROUND.0, | |
Round = DWMWCP_ROUND.0, | |
RoundSmall = DWMWCP_ROUNDSMALL.0, | |
} | |
pub fn set_corner_preference(hwnd:HWND ,prefs:CornerPreference){ | |
unsafe{ | |
let _ = DwmSetWindowAttribute( | |
HWND(hwnd.0), | |
DWMWA_WINDOW_CORNER_PREFERENCE, | |
&(prefs as i32) as *const _ as _, | |
mem::size_of::<DWM_WINDOW_CORNER_PREFERENCE>() as _, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment