1

I have a WPF project that has an application icon assigned in the "Resources" section of the Application settings. This icon appears in the top-left of this application's windows, despite me not configuring this explicitly. When I use Spy++ to inspect the windows, the window class has a null pointer for the window icon. How is the icon ending up in the windows, and how can I turn it off for specific windows without affecting other aspects of the window's caption? My goal is to have a window that is visually the same as a standard message box, with a standard caption with text and a close button, but no icon and no minimize/maximize buttons. When I follow the instructions laid out in other articles for hiding the window icon, though, the icon still appears. (Specifically, the extended style WS_EX_DLGMODALFRAME and using WM_SETICON to assign a null pointer to ICON_SMALL and ICON_BIG.) If I disable the system menu entirely, then the icon disappears but so does the close button. Why does a standard messagebox have no icon, but my window does implicitly get an icon? How can I turn it off?

Excuse the redactions:

screenshot including OnSourceInitialized code, Spy++ window and the offending window with a couple of highlighted areas

Jonathan Gilbert
  • 3,526
  • 20
  • 28
  • You seem to be describing a toolwindow https://learn.microsoft.com/en-us/dotnet/api/system.windows.window.windowstyle?view=windowsdesktop-6.0 – Andy Nov 15 '22 at 17:53
  • But tool windows have oddly scrunched up geometry in the titlebar. Message boxes are not tool windows. – Jonathan Gilbert Nov 15 '22 at 19:55
  • @JonathanGilbert: Did you try [this](https://stackoverflow.com/questions/2341230/removing-icon-from-a-wpf-window)? – mm8 Nov 16 '22 at 15:11
  • I have indeed tried that approach. The icon still appears, pulled from the app's resources somehow by something secret in the depths of WPF or something. – Jonathan Gilbert Nov 17 '22 at 02:39

0 Answers0