Catel.Windows.WindowExtensions.RemoveIcon C# (CSharp) Method

RemoveIcon() public static method

Removes the icon from the window.
public static RemoveIcon ( this window ) : void
window this The window.
return void
        public static void RemoveIcon(this SystemWindow window)
        {
            // Get the handle of the window
            var windowHandle = new WindowInteropHelper(window).Handle;

            // Send message to hide icon
            SendMessage(windowHandle, WM_SETICON, IntPtr.Zero, IntPtr.Zero);

            // Change the extended window style to not show a window icon
            int extendedStyle = GetWindowLong(windowHandle, GWL_EXSTYLE);

            // Update the window style
            SetWindowLong(windowHandle, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME);

            // Update the window's non-client area to reflect the changes
            SetWindowPos(windowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
        }