Toast window sometimes not stay front

Viewed 190

I'm trying to make my toast window to act exactly same as tray balloon tip. It must stay in front of every window and not steal focus. But when i press show desktop button in right bottom corner of Windows 7 and show this toast window 5 seconds later then it not show up in my screen. But when i select another window in taskbar it show up afterwards.

When i use top most for toast form it shows always properly but then it steals focus from directx games etc. and returning to desktop therefore i can't use top most.

This is what i'm doing:

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,
    SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE);

Full source code here:

https://github.com/ShareX/ShareX/blob/master/ShareX/Forms/NotificationForm.cs

I think Windows balloon tip is using top most and still manages to not steal focus when playing fullscreen directx games. Not sure how it works.

1 Answers
Related