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.

Recommended Answers

All 5 Replies

If you have an icon editor, why not create a completely transparant icon?

I would prefer not to, as that would leave an empty space.

The only thing I can think of:

[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.