When left-clicking an application sitting minimized in the systray and displaying a messagebox, the dialog is out of focus the first time it's displayed, while it does have the focus the second time around.
Google seems to say that the solution is to configure the dialog with the MB_TOPMOST parameter, but the .Net MessageBox object doesn't seem to suppport this parameter.
So I tried the following with the non-.Net MsgBox, but it doesn't solve the problem:
Public Class Form1
Private Sub LeftClick(sender As Object, e As EventArgs) Handles NotifyIcon1.Click
'Work-around to prevent Windows from triggering Click then right-click
Dim MyButton As System.Windows.Forms.MouseEventArgs = e
If MyButton.Button = MouseButtons.Left Then
'MessageBox apparently unable to handle MB_TOPMOST
'MessageBox.Show(Str, "Output", ???? )
'Doesn't work
Const MB_TOPMOST As Integer = &H40000
MsgBox("Hello there", MsgBoxStyle.OkOnly Or MB_TOPMOST, "Out of focus")
End If
End Sub
End Class
Has someone found a work-around?
Thank you.
For that you can use the TopMost Property of MsgBox (Number 262144)
Edit: Another way to accomplish this is creating a temporary form