none
nonmodal messagebox

    Question

  • I want to show some information to the user in a nonmodal form. Basically exactly like a message box (doesn't even need buttons) except nonmodal (also doesn't beep). I could create a form from scratch, but I would think this is so basic and common that such a form or method already exists somewhere in vb.net 2008??
    Thursday, January 15, 2009 11:25 PM

Answers

  • Not that I've heard of. 

    Though if you do this on your own you might want to take a tip from MessageBox and notice that it has an overloaded constructor that takes an argument "owner" as a Win32.Window type.  This may be helpful for when the user takes focus away from the "message" form and reactivates the form that called the message -- the messageForm will lose focus it be sent behind the calling form.  I believe the "owner" argument might protect you from this behavior because the Form class has a property called Owner that allows it to stay visible above the parent/owner form when it is activated...  at least I'm fairly sure of this behavior.  I haven't tested it.
    • Marked as answer by Tekito Friday, January 16, 2009 2:34 PM
    Friday, January 16, 2009 1:45 AM

All replies

  • Not that I've heard of. 

    Though if you do this on your own you might want to take a tip from MessageBox and notice that it has an overloaded constructor that takes an argument "owner" as a Win32.Window type.  This may be helpful for when the user takes focus away from the "message" form and reactivates the form that called the message -- the messageForm will lose focus it be sent behind the calling form.  I believe the "owner" argument might protect you from this behavior because the Form class has a property called Owner that allows it to stay visible above the parent/owner form when it is activated...  at least I'm fairly sure of this behavior.  I haven't tested it.
    • Marked as answer by Tekito Friday, January 16, 2009 2:34 PM
    Friday, January 16, 2009 1:45 AM
  • I'm a little confused by your statement of purpose, Tekito.

    The idea behind displaying anything as a Modal is not to make it beep, but to halt all processing on the thread the modal display was called from until the modal is disposed.  The beep that occurs is actually a Windows Operating System Event Notification (I believe the Exclamation Event by default, which can be changed by setting the MessageBoxStyle).

    My best guess here is that what you're looking for is just to pop up a little "tag" window that displays some text, that the user can get rid of by clicking an X controlbox, that sits on top of everything else until it goes away?

    Without interfering with the operating system at large, you'd really need to define your main Form as an MDI Parent and then stick a secondary Form in it... otherwise anything you do to keep the "tag" on top will put it on top of literally everything else.

    If you're actually using a MessageBox or InputBox, I don't know of any way at all to display the box as a non-modal (meaning no matter what MessageBoxStyle you designate, it will always halt the thread until it's disposed).
    Friday, January 16, 2009 7:43 AM
  • I think DB's answer is what you're looking for - if not happy with the answer - but if some of what Painter is talking about fits your situation, you may be able to use a msgbox modally, but kill it by using a timer and killing it in tick event.  Just some thoughts...
    Thanks,
    Corey Furman
    Code Slabs
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    ______________________________________________________
    Going to Tech*Ed 2009? Email me at corey dot furman at gmail dot com.
    Friday, January 16, 2009 12:53 PM
  • You'll have to create your own form to show. It's not that hard, really, but it's uncommon for it to be a 'messagebox' style form.

    You also have to manage additional situations - since the form which generated this Non-modal message box can become active, what happens if the user generates the same event which created the non-modal message box in the first place? Does it generate two 'boxes? Replace the data? How do you keep track of the 'boxes shown? It can get very messy very quickly unless you plan for it.

    If you set the 'owner' of this new form it'll stay on top of that owner form; think 'floating toolbox', or, in your case, 'floating messagebox'.

    Stephen J Whiteley
    Friday, January 16, 2009 2:15 PM
  • Thanks for the many responses.

    PainterEnterprises - "The idea behind displaying anything as a Modal is not to make it beep, but to halt all processing on the thread the modal display was called from until the modal is disposed."

    I realize that.  I mentioned the 'no beep' as I was fishing for the possibility that the messagebox could be altered to a nonmodal state - in which case it would be desirable to take away the automatic 'beep' as well.

    But thanks for the tips, I will probably create my own form, but I never considered the 'owner' situation.  This is why I was hoping for a built-in vb form - I didn't want to have to do any thinking! :)
    Friday, January 16, 2009 2:29 PM
  • If you don't want to think, become an end user or management - either works :P


    Thanks,
    Corey Furman
    Corey Furman's Facebook profile
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    • Edited by Corey Furman Friday, January 16, 2009 2:32 PM I felt like it
    Friday, January 16, 2009 2:30 PM