CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2010
    Posts
    47

    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 ...
    Last edited by wavering; September 22nd, 2014 at 06:10 AM.
    MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?

  2. #2
    Join Date
    May 2002
    Location
    Boston
    Posts
    67

    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

  3. #3
    Join Date
    Aug 2010
    Posts
    47

    Re: Ensure that MessageBox is ALWAYS on Top

    Quote Originally Posted by curt_c View Post
    ... 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
    MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured