473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Forms refresh

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.
Nov 21 '05 #1
2 1395
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.

Nov 21 '05 #2
Bruce,

When a Messagebox.Show is done, than your complete program stops until that
is closed, there are no doevents in that case.

A solution can be to set parts that take a long time (not the dialogboxex
and other UI parts) in seperated threads.

http://msdn.microsoft.com/library/de...isualbasic.asp

I hope this helps,

Cor
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MJ | last post by:
i have form1 and form2, form1 has a picturebox which i wish to make it accessible to other forms after form2 perform some drawing, it need to call form1.picbox.invalidate() to refresh the picbox,...
1
by: chris vettese | last post by:
I'm looking for advice on how to perform calculations on my forms. Iwill try to explain the situation as clearly as possible. I have a form that has multiple sub-forms. Some of these sub-forms...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
6
by: Jax | last post by:
I'm kind of used to the windows forms make a change then type down the good ol' this.refresh(). But in web forms i dont seem to have that choice no refresh, update or anything that sounds vaguely...
12
by: Peter Van Wilrijk | last post by:
Hi, In VB6 I have the following code ... Dim frmLink As Form Set frmLink = Forms.Add(stringformname) frmLink.Show 'wait until all data has been loaded Do Until frmLink.Loaded = 21 DoEvent
18
by: Jerry Boone | last post by:
I'm looking for a way to fire a public sub/function when a form is opened and closed - without using form level events. I have already done some extensive form work with instancing, looping...
4
by: joanWilder | last post by:
Hello. I am using MS Access 97 at work and trying to do the following... I have a main form which has several combo boxes, 2 buttons (search and refresh) and an unbound subform on it. This form...
0
by: keri | last post by:
Hi again, After puzzling all day I have (sort of) figured a round about way to solve my problems. I have a form callsmade with a subform allaccounts On clicking on a record in the subform I...
1
by: cookdw60 | last post by:
I am looking for a way to have an access form update for multiple users. I have a form where certain fields will be updated on individual computers, and there may be 3 or 4 users that have the...
2
by: IqbalEva | last post by:
I have a form and a subform. After updating one of the cboBox in the main form I would like the cboBox in the subform to filter out only the products from the supplier selected above. Currently the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.