-3

I had searched a lot how to display a Msgbox that will not wait the user input (pressing ok or cancel). I found 3 solutiuons to this.

1- Display the MsgBox() in another thread or using BackgroundWorker()

2- Create a form that display the message, then closed the form by a timer and use it instead of Msgbox()

3- Using the API MessageBoxA()

Let say I have a loop from 1 to 100, and I want display a message for the i(counter)

When I test above 3 ways, I found that this is not the right way of doing it, I don't need a msgbox() to close by it self after showing the message, because that will display 100 dialog.

What I realy want is to display ONLY 1 MsgBox() and change the text accordingly.

I managed to do this using a a Form() as class and I did it using Application.DoEvents

I know it can be done using BackgroundWorker or Threading since alot of people advice against using Application.Doevents

Here is my code

Dim oWW As New WaitWindow With {.TopLevel = True,.TopMost = True,.StartPosition = FormStartPosition.CenterScreen}
oWW.Show(Me)
For i = 1 to 100
    Threading.Thread.Sleep(500) ' Just to slowdown execution
    oWW.SetMessage("Counter = " + i.ToString)
Next
oWW.Dispose()


Public Class WaitWindow
    Sub SetMessage(ByVal Message As string)
        lbl_message.Text = Message
        Application.DoEvents
    End Sub
End Class

WaitWindow is not more than a Form base class with a label (lbl_message)

That code works fine (display WaitWindowForm on center of currently displayed form only once, then I change the text)

I have 3 questions :

1- How to display the WaitWindowForm in the top right corner of my working form?

2- Is it possible to display the normal MsgBox() or MessageBox.Show() only once, then capture the text displayed and change it?

3- Which one is suitable for my issue (BackGroundWorker or Threading) and what the code in WaitWindow class I post will be if I decided to use Backgroundworker or Threading instead of Application.DoEvents (Changing the label text not showing new form with new text) ?

3 questions in one post.. humm.. who cares, I am not the one who will answer lol :)

Thanks in advance.

  • 3
    Rolled it back. I would delete the question instead. – LarsTech Dec 11 '14 at 18:44
  • As I am asking a not relative questions to deserve a -2 downvote? should I be serious (lol) gives downvote? its all related. not have the interrest of getting help from such sick minded people. – Samir Ibrahim Dec 11 '14 at 18:46
  • Let an admin delete it. I am done here – Samir Ibrahim Dec 11 '14 at 18:49
  • "How to display the WaitWindowForm in the top right corner of my working form?" Set TopLevel() to **False**, set an appropriate Location() relative to the client coords, then add it to the Controls() collection of the form/container and call Show(). – Idle_Mind Dec 11 '14 at 21:11

1 Answers1

0

I think the issue that you're really encountering is that you're trying to use a message box for something it's not suited for. If you want to have text that constantly changes just add a text box in the upper right corner of your application and adjust it every time a new message needs to be shown.

You can also look up dialogu windows (search ".showdialog() vb.net" in google) might help as well.

misterbee180
  • 325
  • 1
  • 13
  • http://www.codeproject.com/Articles/63507/A-Simple-Wait-Window Check this, that strange creature of showing message for user exist in VFP and that man did it, but not the way i wanted. I want it in vb.net to use it whenever Form I had in my application, not adding it everywhere. – Samir Ibrahim Dec 11 '14 at 19:52
  • _I want it in vb.net to use it whenever Form I had in my application_ as far as I see that's pretty much what the project from the link does. It's a form that you can call from whenever form or class you have in your application and set the text to anythig you want... – Josh Part Dec 12 '14 at 00:05
  • The above did not work (or I did not how to make it work) for filling datagridview sybcronizing with displaying a message. – Samir Ibrahim Dec 12 '14 at 14:52
  • Here is what I have did. All what I want is not using Application.DoEvents [MyWaitWindowProject](https://nbxpxw-ch3302.files.1drv.com/y2mu0m2Qe6PeIxbjCgvrWQ3kifUm-TWuSfeRvJKIBkA0YSjMpy3UsDFeh2lwE4ewzjY2YwuJ-VQAVl0izNNgppVZEBS9UsIj9Z4b9Vidkxi0Bec7JFeocTnVfgzWnOHCLZB/WaitWindow.rar?download&psid=1) – Samir Ibrahim Dec 12 '14 at 14:54