In an MDI application, when the MDI child form is maximised the icon for the form is used as the context menu icon, displayed on the left of the parent form's MenuStrip. When I set the icon of a form used in an MDI application to something larger than 16x16 (I'm using 32x32) the icon is drawn unscaled, and the menu is resized to suit. Note that if the ICO file also contains a 16x16 version of the icon it works fine.
The following creates a basic application that shows the behaviour:
- create a new solution and WinForms project
- change Form1's IsMdiContainer to
true
- add a
MenuStrip
to Form1 - create a new form, call it
MdiChildForm
- set
MdiChildForm
's icon to a 32x32 ICO file, here's one I prepared earlier in
Form1
add a menu item, double-click it to create theClick
event handler and add the following:var child = new MdiChildForm(); child.MdiParent = this; child.Show(); child.WindowState = FormWindowState.Maximized;
build and run, click the menu item
Note that when you click the menu item again the icon changes to the default one, this is described in this question and isn't the issue here.
I'm pretty sure this would be described as 'by design' but it is annoying nonetheless. Is there a way to force the context menu icon to scale down, sort of resizing the source icon? I'll probably do that as well, but I'm after some kind of in-code catch-all.