Notification form top most

This commit is contained in:
Jaex 2013-12-23 23:11:06 +02:00
parent c9dff4a04a
commit 44f1c4330f
2 changed files with 9 additions and 8 deletions

View file

@ -47,6 +47,7 @@ private void InitializeComponent()
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "ToastForm";
this.TopMost = true;
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.NotificationForm_MouseClick);
this.ResumeLayout(false);

View file

@ -57,7 +57,9 @@ public NotificationForm(int duration, Size size, string text, Image image, strin
URL = url;
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - Width - windowOffset, Screen.PrimaryScreen.WorkingArea.Bottom - Height - windowOffset);
NativeMethods.AnimateWindow(Handle, 1000, AnimateWindowFlags.AW_BLEND);
NativeMethods.SetWindowPos(Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, 0, 0, 0, 0,
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
NativeMethods.AnimateWindow(Handle, 500, AnimateWindowFlags.AW_SLIDE | AnimateWindowFlags.AW_VER_NEGATIVE);
tDuration.Interval = duration;
tDuration.Start();
}
@ -75,9 +77,9 @@ protected override void OnPaint(PaintEventArgs e)
g.DrawImage(ToastImage, 1, 1, ToastImage.Width, ToastImage.Height);
using (SolidBrush brush = new SolidBrush(Color.FromArgb(200, 255, 255, 255)))
using (SolidBrush brush = new SolidBrush(Color.FromArgb(150, 255, 255, 255)))
{
g.FillRectangle(brush, new Rectangle(0, 0, e.ClipRectangle.Width, 40));
g.FillRectangle(brush, new Rectangle(0, 0, e.ClipRectangle.Width, 45));
}
using (Font font = new Font("Arial", 10))
@ -114,11 +116,9 @@ private void NotificationForm_MouseClick(object sender, MouseEventArgs e)
Helpers.LoadBrowserAsync(URL);
}
}
else if (e.Button == MouseButtons.Right)
{
tDuration.Stop();
Close();
}
tDuration.Stop();
Close();
}
}
}