pub fn try_theme(hwnd: HWND, preferred_theme: Option<Theme>) -> Theme {
    if *DARK_MODE_SUPPORTED {
        let is_dark_mode = match preferred_theme {
            Some(theme) => theme == Theme::Dark,
            None => should_use_dark_mode(),
        };

        let theme = if is_dark_mode {
            Theme::Dark
        } else {
            Theme::Light
        };
        let theme_name = match theme {
            Theme::Dark => DARK_THEME_NAME.as_ptr(),
            Theme::Light => LIGHT_THEME_NAME.as_ptr(),
        };

        let status = unsafe { SetWindowTheme(hwnd, theme_name, ptr::null()) };

        if status == S_OK && set_dark_mode_for_window(hwnd, is_dark_mode) {
            return theme;
        }
    }

    Theme::Light
}
/// Attempt to set a theme on a window, if necessary.
/// Returns the theme that was picked
Attempt to set a theme on a window, if necessary.
Returns the theme that was picked
Attempt to set a theme on a window if necessary . Returns the theme that was picked
pub fn try_theme(hwnd: HWND, preferred_theme: Option<Theme>) -> Theme {
    if *DARK_MODE_SUPPORTED {
        let is_dark_mode = match preferred_theme {
            Some(theme) => theme == Theme::Dark,
            None => should_use_dark_mode(),
        };
        let theme = if is_dark_mode {
            Theme::Dark
        } else {
            Theme::Light
        };
        let theme_name = match theme {
            Theme::Dark => DARK_THEME_NAME.as_ptr(),
            Theme::Light => LIGHT_THEME_NAME.as_ptr(),
        };
        let status = unsafe { SetWindowTheme(hwnd, theme_name, ptr::null()) };
        if status == S_OK && set_dark_mode_for_window(hwnd, is_dark_mode) {
            return theme;
        }
    }
    Theme::Light
}
pub fn try_theme ( hwnd : HWND , preferred_theme : Option < Theme > ) -> Theme { if * DARK_MODE_SUPPORTED { let is_dark_mode = match preferred_theme { Some ( theme ) => theme == Theme :: Dark , None => should_use_dark_mode ( ) , } ; let theme = if is_dark_mode { Theme :: Dark } else { Theme :: Light } ; let theme_name = match theme { Theme :: Dark => DARK_THEME_NAME . as_ptr ( ) , Theme :: Light => LIGHT_THEME_NAME . as_ptr ( ) , } ; let status = unsafe { SetWindowTheme ( hwnd , theme_name , ptr :: null ( ) ) } ; if status == S_OK && set_dark_mode_for_window ( hwnd , is_dark_mode ) { return theme ; } } Theme :: Light }
Attempt to set a theme on a window, if necessary.
Attempt to set a theme on a window if necessary .
hwnd
HWND
preferred_theme
Option<Theme>