MessageBox.Show() or MsgBox() enters the application into a loop by itself,
because it is sth like form.ShowDialog() and unless the messageBox is closed
your main form or the parent form won't get repainted. However if you need
to repaint your main form while this form is being displayed, you should use
a custom dialog class, set its TopMost property to true and then Show() it.
This is one way, but have you tried Multithreading for this purpose so far?
I did it.. But sth in both cases is not so good....It is that your dialog
box appears just like a second form, and the user can shift from it to the
main form any time he likes without closing the dialog box.. One way to
solve it is to do sth like this:
Put the repaint functions in a Sub() and call the sub from a Timer_Tick
event handler while you are separately showing the dialogBox to the user:
'----------------------------------------------------------
' Add a button to your form:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MsgBox("HI", MsgBoxStyle.Critical)
End Sub
' Add the timer to your form, set its Interval to 500 and its Enabled to
true:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim th As New Threading.Thread(AddressOf ShowMyDialog)
th.Start()
End Sub
Dim i As Integer
' The ShowMyDialog works on a separate thread, so it doesn't lock up your
form from reapinting itself or anything else... :
Sub ShowMyDialog()
Me.Text = " I = " & i
Me.BackColor = Color.FromArgb(i, i + 10, i + 30)
If i > 224 Then i = 0
i += 5
End Sub
'--------------------------------------------------------------------------------------
' Hope this help
"Bruce" <Br***@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
I'm a bit new to VB coding. I have written an application that takes an
input file, processes it & creates some new output files for use in a
legacy
app. I am having issues with the main form getting repainted properly. I
have solved some of this by placing Application.DoEvents() in my loops. I
have some help menus with display a MessageBox.Show event, which also
freezes
my main window. It would seem a simple call to show a message box, would
inherently not "Lock" up the window from refreshing the form if another
window covers it. Any help would be greatly appreciated, thanks.