Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8873547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:29:31+00:00 2026-06-14T18:29:31+00:00

What I want is a small notification message that is shown in the lower

  • 0

What I want is a small notification message that is shown in the lower right corner when there are any messages to be shown. If there are none the notification message will not be shown. The notification message should not steal focus or block the main application.

What I have is an application that runs a Task as a kind of messageservice. This application contains multiple dialogs that opens as modal dialogs.

When a message arrives to the application it is added to a observable list. This fires an eventhandler in the form showing the notification message and it is redrawn to show the first item in the list.
When a message is read/closed it is removed from the list which fires the event again and the form is updated with the information from the first item in the list.
If the list is empty the form is hidden.

My problem is that if i get a message and the notification message form is shown, and before I close it a modal dialog is opened in the main application, my form with the notification message is still on top of everything, even the modal dialog, but it’s not clickable.

I’ve searched and read several forums for an answer but haven’t been able to come up with an answer.

A small testapplication that simulates this behaviour can be found at Github.
https://github.com/Oneleg/NotificationMessage

Some fast info:

The NotificationMessage form has:

  • FormBorderStyle = None
  • Topmost = False
  • Is shown with Show()
  • Overloads ShowWithoutActivation()
  • Overloads CreateParams with WS_EX_NOACTIVATE WS_EX_TOOLWINDOW WS_EX_TOPMOST

Any ideas on how I could solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:29:33+00:00Added an answer on June 14, 2026 at 6:29 pm

    Looks like I’ll be able to answer my own question.

    The answer is to create the NotificationMessage as an application withs it’s own messagepump.

    Application.Run(New NotificationMessage(_messageList))
    

    After some modifications my Main now looks like this:

    Imports System.Threading
    Imports System.Threading.Tasks
    
    Public Class frmMain
    
        Private _notificationMessage As NotificationMessage
        Private _task As Task
        Private _messageList As ObservableGenericList(Of String) = New ObservableGenericList(Of String)
        Private ReadOnly _cancelMessages As CancellationTokenSource = New CancellationTokenSource()
    
        Private Sub btnModal_Click(sender As System.Object, e As System.EventArgs) Handles btnModal.Click
            frmModal.ShowDialog()
        End Sub
    
        Private Sub frmMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            AddHandler _messageList.Changed, AddressOf MessageListChanged
        End Sub
    
        Private Sub NotificationMessageLoop(mess As String)
            _notificationMessage = New NotificationMessage(_messageList)
            _messageList.Add(mess)
            Application.Run(_notificationMessage)
        End Sub
    
        Private Sub btnMessage_Click(sender As System.Object, e As System.EventArgs) Handles btnMessage.Click
    
            Dim newMessage = String.Format("Message no {0}", _messageList.Count + 1)
    
            If _task Is Nothing Then
                _task = Task.Factory.StartNew(Sub() NotificationMessageLoop(newMessage), _cancelMessages.Token)
            Else
                _messageList.Add(newMessage)
            End If
        End Sub
    
        Private Sub MessageListChanged()
            If Not _messageList.Any Then
                _cancelMessages.Cancel()
            End If
        End Sub
    End Class
    

    And the NotificationMessage looks like this:

    Imports System.Runtime.InteropServices
    
    Public Class NotificationMessage
        Public Sub New(messages As ObservableGenericList(Of String))
    
            InitializeComponent()
            _messages = messages
            AddHandler _messages.Changed, AddressOf ListChanged
    
        End Sub
    
        Private ReadOnly _messages As ObservableGenericList(Of String)
        Private Delegate Sub ListChangedDelegate()
    
        Private Sub ListChanged()
            If InvokeRequired Then
                BeginInvoke(New ListChangedDelegate(AddressOf ListChanged))
                Return
            End If
    
            If _messages.Any Then
                Dim message As String = _messages.First
                txtMessage.Text = message
                lblCounter.Text = String.Format("({0} messages)", _messages.Count)
                Show()
            Else
                Hide()
            End If
        End Sub
    
        Private Sub MessageLoad(sender As System.Object, e As EventArgs) Handles MyBase.Load
            Left = Screen.PrimaryScreen.WorkingArea.Width - Width
            Top = Screen.PrimaryScreen.WorkingArea.Height - Height
        End Sub
    
        Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
            _messages.RemoveFirst()
        End Sub
    
    #Region "Overrides"
    
        Private Const WS_EX_NOACTIVATE = &H8000000 ' Do not steal focus
        Private Const WS_EX_TOOLWINDOW = &H80 ' Makes form hidden from Alt + Tab window
        Private Const WS_EX_TOPMOST = &H8 ' Makes window topmost
    
        ''' <summary> Indicates whether the window will be activated when it is shown. </summary>
        ''' <remarks> http://msdn.microsoft.com/en-us/library/system.windows.forms.form.showwithoutactivation.aspx </remarks>
        Protected Overrides ReadOnly Property ShowWithoutActivation() As Boolean
            Get
                Return True
            End Get
        End Property
    
        ''' <summary> Override for creation parameters that are set when control handle is created. </summary>
        Protected Overrides ReadOnly Property CreateParams() As CreateParams
            Get
                Dim params As CreateParams = MyBase.CreateParams
                params.ExStyle = params.ExStyle Or WS_EX_NOACTIVATE Or WS_EX_TOOLWINDOW Or WS_EX_TOPMOST
                Return params
            End Get
        End Property
    
    #End Region
    
    End Class
    

    I now have a notification message that is only visible when there are any messages to show, doesn’t steal focus when a new message arrives, is always on top and is clickable even after a modal form is opened in the main application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a small text box with a scroll bar that will
I want to display a small view that does not cover the whole screen
Not &reg; that shows a registered symbol next to text, I want the small
I want to know if there is a siverlight client notification best practice, right
I want to write a small Android app with a GUI that should display
I want to build a button that represents a person, On the right i
I have a small email application that lets a user build a message from
What encryption scheme returns a short string? I want a small result less than
Possible Duplicates: How would I implement stackoverflow’s hovering dialogs? i want a small box
I want to port an small open source AES encryption class to Android, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.