New test.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / NotifyIcon.cs
index decd1fb1756bd93e2abbb375c9acd58726dbe045..ceac86723eddd41bc80921dd26e1e1de2730a050 100644 (file)
@@ -49,7 +49,7 @@ namespace System.Windows.Forms {
                #endregion      // Local Variables
 
                #region NotifyIconWindow Class
-               internal class NotifyIconWindow : Control {
+               internal class NotifyIconWindow : Form {
                        NotifyIcon      owner;
                        Rectangle       rect;
 
@@ -60,7 +60,6 @@ namespace System.Windows.Forms {
 
                                CreateControl();
 
-                               Paint += new PaintEventHandler(HandlePaint);
                                SizeChanged += new EventHandler(HandleSizeChanged);
 
                                // Events that need to be sent to our parent
@@ -82,7 +81,7 @@ namespace System.Windows.Forms {
                                        cp.Style = (int)WindowStyles.WS_POPUP;
                                        cp.Style |= (int)WindowStyles.WS_CLIPSIBLINGS;
 
-                                       cp.ExStyle = (int)(WindowStyles.WS_EX_TOOLWINDOW);
+                                       cp.ExStyle = (int)(WindowExStyles.WS_EX_TOOLWINDOW);
 
                                        return cp;
                                }
@@ -94,11 +93,18 @@ namespace System.Windows.Forms {
                                                PaintEventArgs  paint_event;
 
                                                paint_event = XplatUI.PaintEventStart(Handle, false);
-                                               OnPaint(paint_event);
+                                               OnPaintInternal (paint_event);
                                                XplatUI.PaintEventEnd(Handle, false);
                                                break;
                                        }
 
+                                               //
+                                               //  NotifyIcon does CONTEXTMENU on mouse up, not down
+                                               //  so we swallow the message here, and handle it on our own
+                                               // 
+                                       case Msg.WM_CONTEXTMENU:
+                                               return;
+
                                        case Msg.WM_USER: {
                                                switch ((Msg)m.LParam.ToInt32()) {
                                                        case Msg.WM_LBUTTONDOWN: {
@@ -171,7 +177,7 @@ namespace System.Windows.Forms {
                                }
                        }
 
-                       private void HandlePaint(object sender, PaintEventArgs e) {
+                       internal override void OnPaintInternal (PaintEventArgs e) {
                                if (owner.icon != null) {
                                        e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(SystemColors.Window), rect);
                                        e.Graphics.DrawImage(owner.icon_bitmap, rect);
@@ -179,6 +185,11 @@ namespace System.Windows.Forms {
                                }
                        }
 
+                       internal void InternalRecreateHandle () {
+                               base.RecreateHandle ();
+                       }
+
+
                        private void HandleSizeChanged(object sender, EventArgs e) {
                                CalculateIconRect();
                        }