2007-01-15 Jonathan Pobst <jpobst@novell.com>
authorJonathan Pobst <monkey@jpobst.com>
Mon, 15 Jan 2007 22:05:08 +0000 (22:05 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Mon, 15 Jan 2007 22:05:08 +0000 (22:05 -0000)
* Form.cs: Implement Form.ShowIcon.

* XplatUIWin32.cs: Allow the SetIcon win32 call to set the icon to
null, which when combined with the DlgModalFrame window style removes
the icon from the title bar.

svn path=/trunk/mcs/; revision=71094

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs

index 221a96224790e245e599f0aaddfc1b181afff601..c4b55e8df49bac8e520adcbcc4b8d613467161bb 100644 (file)
@@ -1,3 +1,11 @@
+2007-01-15  Jonathan Pobst  <jpobst@novell.com>
+
+       * Form.cs: Implement Form.ShowIcon.
+       
+       * XplatUIWin32.cs: Allow the SetIcon win32 call to set the icon to
+       null, which when combined with the DlgModalFrame window style removes
+       the icon from the title bar.
+
 2007-01-15  Jonathan Pobst  <jpobst@novell.com>
 
        * Control.cs: Call OnMouseClick after OnClick. (2.0)
index a8d516f49760c2250ff332b43f35571a795ad265..446a62024acf1d5fab914ce9da26026b26c807a8 100644 (file)
@@ -89,6 +89,7 @@ namespace System.Windows.Forms {
 
 #if NET_2_0
                private MenuStrip               main_menu_strip;
+               private bool                    show_icon;
 #endif
                #endregion      // Local Variables
 
@@ -205,6 +206,10 @@ namespace System.Windows.Forms {
                        owned_forms = new Form.ControlCollection(this);
                        transparency_key = Color.Empty;
 
+#if NET_2_0
+                       show_icon = true;
+#endif
+
                        // FIXME: this should disappear just as soon as the handle creation is done in the right place (here is too soon()
                        UpdateBounds();
 
@@ -856,6 +861,24 @@ namespace System.Windows.Forms {
                        }
                }
 
+#if NET_2_0
+               [DefaultValue (true)]
+               public bool ShowIcon {
+                       get { return this.show_icon; }
+                       set {
+                               if (this.show_icon != value ) {
+                                       this.show_icon = value;
+                                       UpdateStyles ();
+                                       
+                                       XplatUI.SetIcon (this.Handle, value == true ? this.Icon : null);
+                                       
+                                       Message msg = new Message ();
+                                       XplatUI.InvalidateNC (this.Handle);
+                               }
+                       }
+               }                       
+#endif
+       
                [DefaultValue(true)]
                [MWFCategory("Window Style")]
                public bool ShowInTaskbar {
@@ -1142,6 +1165,12 @@ namespace System.Windows.Forms {
                                        cp.Style |= (int)WindowStyles.WS_SYSMENU;
                                }
 
+#if NET_2_0
+                               if (!this.show_icon) {
+                                       cp.ExStyle |= (int)WindowExStyles.WS_EX_DLGMODALFRAME;
+                               }
+#endif
+
                                if (HelpButton && !MaximizeBox && !MinimizeBox) {
                                        cp.ExStyle |= (int)WindowExStyles.WS_EX_CONTEXTHELP;
                                }
index a0ba99422dec3d5a561288977715be079f7bd398..8b915780013168f8c9e78a6c230f1cba48d114fd 100644 (file)
@@ -2178,7 +2178,7 @@ namespace System.Windows.Forms {
                }
 
                internal override void SetIcon(IntPtr hwnd, Icon icon) {
-                       Win32SendMessage(hwnd, Msg.WM_SETICON, (IntPtr)1, icon.Handle); // 1 = large icon (0 would be small)
+                       Win32SendMessage(hwnd, Msg.WM_SETICON, (IntPtr)1, icon == null ? IntPtr.Zero : icon.Handle);    // 1 = large icon (0 would be small)
                }
 
                internal override void ClipboardClose(IntPtr handle) {