Ensure that MessageBox is ALWAYS on Top
Firstly, I am using Visual Studio 2013
I have been looking for a way to ensure that the Message Box is ALWAYS on top and finally came up with this after the usual going round in circles
Code:
Private Sub frmTopmost_Load( sender As Object, e As EventArgs) Handles MyBase.Load
Me.TopMost = True
End Sub
frmTopmost.Show
frmTopmost.Hide
MessageBox.Show(frmTopmost, "I am always on top!")
This works well (frmTopmost is just a minmal dummy form) but offends my sense of style - is there a tidier way?
Edit:
I also would like to extend this to cover "Yes, No and Cancel" message boxes but cannot seem to be able to do that ...
Re: Ensure that MessageBox is ALWAYS on Top
Hi,
Use can use the old VB6 style Msgbox. try
MsgBox("Always on Top!", MsgBoxStyle.SystemModal, "On Top")
SystemModal keeps it on top.
Curt
Re: Ensure that MessageBox is ALWAYS on Top
Quote:
Originally Posted by
curt_c
... MsgBox("Always on Top!", MsgBoxStyle.SystemModal, "On Top")
Brilliant! There are lots of requestes for this on the web and lots of people saying "it can't be done"
Many thanks -- tested and it works