Topmost notification form otherwise sometimes not show up when in desktop

This commit is contained in:
Jaex 2013-12-24 22:52:12 +02:00
parent 4b719fee96
commit be93e8dd08
2 changed files with 9 additions and 2 deletions

View file

@ -17,6 +17,12 @@ protected override void Dispose(bool disposing)
{
components.Dispose();
}
if (ToastImage != null)
{
ToastImage.Dispose();
}
base.Dispose(disposing);
}

View file

@ -95,13 +95,15 @@ public static void Show(string imagePath, string url)
Image img = ImageHelpers.LoadImage(imagePath);
NotificationForm form = new NotificationForm(5000, new Size(400, 300), img, url);
NativeMethods.ShowWindow(form.Handle, (int)WindowShowStyle.ShowNoActivate);
NativeMethods.SetWindowPos(form.Handle, (IntPtr)SpecialWindowHandles.HWND_TOP, 0, 0, 0, 0,
NativeMethods.SetWindowPos(form.Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, 0, 0, 0, 0,
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);
}
}
private void NotificationForm_MouseClick(object sender, MouseEventArgs e)
{
tDuration.Stop();
if (e.Button == MouseButtons.Left)
{
if (!string.IsNullOrEmpty(URL))
@ -110,7 +112,6 @@ private void NotificationForm_MouseClick(object sender, MouseEventArgs e)
}
}
tDuration.Stop();
Close();
}
}