Hello, I have been struggling with this for hours now.

Is there any way to completely remove the icon that is displayed in the upper left corner of a window in WPF, without setting the window style to ToolWindow?

I have tried loading user32 and setting various WinAPI-styles with no success.
It worked with setting the style to WS_EX_DLGMODALFRAME until I attached an icon to the assembly itself.

Thank you.

7 Years
Discussion Span
Last Post by k.d.m

The only thing I can think of:

[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x00080000;

private void Window_Loaded(object sender, RoutedEventArgs e)
    IntPtr handle = new WindowInteropHelper(this).Handle;
    SetWindowLong(handle, GWL_STYLE, GetWindowLong(handle, GWL_STYLE) & ~WS_SYSMENU);

This will however, remove the minimize, maximize and close buttons as well. I don't know of any other way around it...


Thank you for the suggestion, but I need the close button atleast.

It is weird that this is so hard to accomplish with such a modern framework when it was so easy with only C and WinAPI.

Edited by strmstn: n/a


you can change the icon by right clicking the project node in solution explorer and the icon that shows is displayed in application tab.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.