Hi all,

I have a small app in .net 2008, running (in systray), in many computers in my company, that has to alert the user a few times during the day's work, and sometimes ask for their input.

The problem is, when, i open a form (show or showdialog), it doesn't popup, this because the user is working in other office app's, and the forms stays behind, and most of the times the users don't even pay attention.

Is there a way to put a form in popup, jumping in front of any app that may be open or maybe create a window info, like the one outlook does when alerting of an incoming mail?

Thanks for any help

Dani AI

Generated

Nice— got it working with ’s hint, and ’s NotifyIcon suggestion is a good alternative. Below are a few practical, less-disruptive ways to surface alerts reliably and some caveats to avoid focus-stealing or OS surprises.

A robust pattern for small “toast” windows is to show a topmost form that does not take focus. Override the form’s ShowWithoutActivation and CreateParams so the window is displayed above other apps but won’t steal keyboard focus; show it with Show() (not ShowDialog()), then let the user click or dismiss. Example (VB.NET):

Protected Overrides ReadOnly Property CreateParams() As CreateParams
  Get
    Dim cp As CreateParams = MyBase.CreateParams
    Const WS_EX_NOACTIVATE As Integer = &H08000000
    Const WS_EX_TOPMOST As Integer = &H00000008
    Const WS_EX_TOOLWINDOW As Integer = &H80
    cp.ExStyle = cp.ExStyle Or WS_EX_NOACTIVATE Or WS_EX_TOPMOST Or WS_EX_TOOLWINDOW
    Return cp
  End Get
End Property

Protected Overrides ReadOnly Property ShowWithoutActivation() As Boolean
  Get
    Return True
  End Get
End Property

That pattern is the common workaround to keep a notification visible without interrupting the user. (stackoverflow.com)

Other options and cautions:

  • A NotifyIcon with ShowBalloonTip is the least intrusive and integrates with the OS notification area, but display time and behavior are OS-controlled (modern Windows may route notifications to Action Center). (learn.microsoft.com)
  • Calling SetForegroundWindow to force focus is unreliable because Windows restricts which processes may set the foreground window; you’ll often get only a taskbar flash instead. Prefer the non-activating toast or let the taskbar highlight the app. (learn.microsoft.com)

For modern deployments, consider Windows toast notifications (Windows Notification Platform) for interactive toasts (buttons, actions), but they require the appropriate manifest/registration and platform support. Keep notifications respectful—offer snooze/dismiss and avoid interrupting critical work. (learn.microsoft.com)

In short: for immediate visibility without breaking the user’s workflow, use a ShowWithoutActivation/WS_EX_NOACTIVATE toast or a NotifyIcon balloon; reserve focus-stealing calls for truly urgent alerts and be aware of OS limitations.

Recommended Answers

All 4 Replies

Set TopMost property of your pop up form

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  '
  Me.TopMost = True

End Sub

After the user has somehow "reacted" to your pop up, you may set TopMost = False to allow user send your form to background.

Set TopMost property of your pop up form

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  '
  Me.TopMost = True

End Sub

After the user has somehow "reacted" to your pop up, you may set TopMost = False to allow user send your form to background.

Thanxs for your help.

that worked just fine

Hi! Nice to hear that you got answer to your problem, could you please mark the thread as solved. Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.