From 44f1c4330f4d880c97ea263044964405523a0d1f Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 23 Dec 2013 23:11:06 +0200 Subject: [PATCH] Notification form top most --- ShareX/Forms/NotificationForm.Designer.cs | 1 + ShareX/Forms/NotificationForm.cs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ShareX/Forms/NotificationForm.Designer.cs b/ShareX/Forms/NotificationForm.Designer.cs index 99bbd268a..9e3d2ce72 100644 --- a/ShareX/Forms/NotificationForm.Designer.cs +++ b/ShareX/Forms/NotificationForm.Designer.cs @@ -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); diff --git a/ShareX/Forms/NotificationForm.cs b/ShareX/Forms/NotificationForm.cs index 1a4d93898..3d4abe995 100644 --- a/ShareX/Forms/NotificationForm.cs +++ b/ShareX/Forms/NotificationForm.cs @@ -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(); } } } \ No newline at end of file