Messagebox shows underneath a TopMost form

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Hello,

I've seen a couple previous posts about this phenomenon, but none seem
to have been resolved. I am using Visual Basic .NET 2003 on Windows
2000 SP 3.

Would you mind creating a new project and running this simple test
program to see if it happens to you? Please let me know if you have
any ideas for a workaround (other than setting the TopMost form to
False then back to True every time I show a MessageBox.)

Create a new project and add the following code:

'------------------------
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized

Dim objForm As New Form
With objForm
.Text = "I'm the new form"
.TopMost = True
.StartPosition = FormStartPosition.CenterScreen
.Show()
End With
End Sub

Private Sub Form1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Click
MessageBox.Show("I get shown underneath " & _
"the new TopMost form and you can't see me.")
End Sub
'------------------------

Just start the app and click Form1. I made the message text wide
enough so the MessageBox extends past the default size of the new
form, but if it is smaller that makes things messier.
 
* (e-mail address removed) (Kevin) scripsit:
I've seen a couple previous posts about this phenomenon, but none seem
to have been resolved. I am using Visual Basic .NET 2003 on Windows
2000 SP 3.

This behavior is "by design". Quick and Dirty solution (I didn't check
the side effects):

\\\
MsgBox("I get shown underneath " & _
"the new TopMost form and you can't see me.", MsgBoxStyle.SystemModal)
///
 
Back
Top