My project has a main form (frmMain, the startup object for the project) and
several other "child" forms that are painted within a large panel on
frmMain.
In each form's Form_Load event, a Weak Reference for that form is loaded
into a global Hash table, like this:
Dim wr As WeakReference = New WeakReference(Me, False)
If Not hashTable.Contains(cfrmMain) Then
hashTable.Add(cfrmMain, wr)
End If
I also have the following declares in frmMain, just after the designer code,
for each "child" form that gets painted inside the panel on frmMain:
Friend frmAdmin As New frmAdmin
Friend frmAppointment As New frmAppointment
Friend frmBilling As New frmBilling
Friend frmSystem As New frmSystem
Each child form writes to the status bar on frmMain in their Form_Load
event.
Problem is, the load events for the child forms are firing before
the load event for frmMain has put a reference into the hash table.
How can I get frmMain's Form_Load to fire completely before child Form_Load
events
fire? Or, how can I get an entry for frmMain into hashTable before child
Form_Load
events fire?
Above and beyond this specific problem, I would like to find an article that
explains in
great detail exactly what happens in sequence when a VB application is
launched.
Thanks,
Dean Slindee 12 4243
Hello Dean,
Thanks for your post. As I understand, the problem you are facing is that
your "child" forms' Load methods are called before that of the frmMain.
Please correct me if there is any misunderstand.
The Form.Load event occurs before a form is displayed for the first time.
So, generally speaking, the Load method of startup Form will be called
first. I am able to verify it by the following steps:
1. Create a WinForm application.
2. Add a new Form (Form2) to the project.
3. In the Load method of each form, add the following code to display a
message box.
MessageBox.Show("Form1_Load")
or
MessageBox.Show("Form2_Load")
4. Have the following declare in Form1 (the startup object):
Friend frmForm2 As New Form2
5. Execute the program and you will notice that Form2_Load() will not be
called until you explcitly call Form2.Show().
For further research, could you please tell me when you try to paint
"child" Forms to the frmMain? I recommend you paint them at the end of the
frmMain_Load method.
Hope this helps.
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Hello Dean,
Thanks for your post. As I understand, the problem you are facing is that
your "child" forms' Load methods are called before that of the frmMain.
Please correct me if there is any misunderstand.
The Form.Load event occurs before a form is displayed for the first time.
So, generally speaking, the Load method of startup Form will be called
first. I am able to verify it by the following steps:
1. Create a WinForm application.
2. Add a new Form (Form2) to the project.
3. In the Load method of each form, add the following code to display a
message box.
MessageBox.Show("Form1_Load")
or
MessageBox.Show("Form2_Load")
4. Have the following declare in Form1 (the startup object):
Friend frmForm2 As New Form2
5. Execute the program and you will notice that Form2_Load() will not be
called until you explcitly call Form2.Show().
For further research, could you please tell me when you try to paint
"child" Forms to the frmMain? I recommend you paint them at the end of the
frmMain_Load method.
Hope this helps.
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
"Dean Slindee" <sl*****@mindspring.com> schrieb
It's not required to post three times. Sometimes it might take many hours to
get an answer. I'd suggest to wait at least one day before reposting.
(Concerning me, I skipped your posts as soon as I read "WeakReference"
because I've never dealt with it. Now I'll try...) My project has a main form (frmMain, the startup object for the project) and several other "child" forms that are painted within a large panel on frmMain.
In each form's Form_Load event, a Weak Reference for that form is loaded into a global Hash table, like this:
Dim wr As WeakReference = New WeakReference(Me, False)
If Not hashTable.Contains(cfrmMain) Then
hashTable.Add(cfrmMain, wr)
End If
I also have the following declares in frmMain, just after the designer code, for each "child" form that gets painted inside the panel on frmMain:
Friend frmAdmin As New frmAdmin
Friend frmAppointment As New frmAppointment
Friend frmBilling As New frmBilling
Friend frmSystem As New frmSystem Each child form writes to the status bar on frmMain in their Form_Load event.
Problem is, the load events for the child forms are firing before
the load event for frmMain has put a reference into the hash table. How can I get frmMain's Form_Load to fire completely before child Form_Load events
fire? Or, how can I get an entry for frmMain into hashTable before child Form_Load
events fire?
You are mixing the order. The order is
1. create form
2. load form
3. show form
4. child paints anything (resp. change the display)
I'd code it appropriately:
dim f as new frmmain
f.show 'loading is done implicitly
' just before the form is shown
frmmain.refresh
frmmain.loadchildforms 'not in form_load
Loadchildforms creates the child instances, so don't declare them "As /New/
frmAdmin"
Another improvement approach is probably to make the child raise events and
catch them in frmMain. In the event handler, frmMain can update it's own
status bar.
Above and beyond this specific problem, I would like to find an article that explains in
great detail exactly what happens in sequence when a VB application is launched.
Sub main is started. It is running in the one and only thread of the
application. The application quits as soon as all threads terminated. If you
have one thread only, the app ends when your main thread ends. To keep sub
main running, there must be a loop that keeps the thread and the app alive.
In Windows.Forms applications, sub main contains a message loop that
processes all windows messages (key presses, mouse movements,...). If you
write sub main on your own, it can look like this:
sub main
application.run(new form1)
end sub
application.run contains the message loop and it returns as soon as the
passed form has been closed. In this sub main you are very flexible, you can
write anything you want.
If you specify a Form as the startup object in the project properties, VB
implicitly creates (invisible) code for you. It looks like this:
sub main
application.run(new form1)
end sub
Surprise, it's the same as above, but this code is fixed. In the first case,
you are free to fill Sub main as you want.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Dean Slindee" <sl*****@mindspring.com> schrieb
It's not required to post three times. Sometimes it might take many hours to
get an answer. I'd suggest to wait at least one day before reposting.
(Concerning me, I skipped your posts as soon as I read "WeakReference"
because I've never dealt with it. Now I'll try...) My project has a main form (frmMain, the startup object for the project) and several other "child" forms that are painted within a large panel on frmMain.
In each form's Form_Load event, a Weak Reference for that form is loaded into a global Hash table, like this:
Dim wr As WeakReference = New WeakReference(Me, False)
If Not hashTable.Contains(cfrmMain) Then
hashTable.Add(cfrmMain, wr)
End If
I also have the following declares in frmMain, just after the designer code, for each "child" form that gets painted inside the panel on frmMain:
Friend frmAdmin As New frmAdmin
Friend frmAppointment As New frmAppointment
Friend frmBilling As New frmBilling
Friend frmSystem As New frmSystem Each child form writes to the status bar on frmMain in their Form_Load event.
Problem is, the load events for the child forms are firing before
the load event for frmMain has put a reference into the hash table. How can I get frmMain's Form_Load to fire completely before child Form_Load events
fire? Or, how can I get an entry for frmMain into hashTable before child Form_Load
events fire?
You are mixing the order. The order is
1. create form
2. load form
3. show form
4. child paints anything (resp. change the display)
I'd code it appropriately:
dim f as new frmmain
f.show 'loading is done implicitly
' just before the form is shown
frmmain.refresh
frmmain.loadchildforms 'not in form_load
Loadchildforms creates the child instances, so don't declare them "As /New/
frmAdmin"
Another improvement approach is probably to make the child raise events and
catch them in frmMain. In the event handler, frmMain can update it's own
status bar.
Above and beyond this specific problem, I would like to find an article that explains in
great detail exactly what happens in sequence when a VB application is launched.
Sub main is started. It is running in the one and only thread of the
application. The application quits as soon as all threads terminated. If you
have one thread only, the app ends when your main thread ends. To keep sub
main running, there must be a loop that keeps the thread and the app alive.
In Windows.Forms applications, sub main contains a message loop that
processes all windows messages (key presses, mouse movements,...). If you
write sub main on your own, it can look like this:
sub main
application.run(new form1)
end sub
application.run contains the message loop and it returns as soon as the
passed form has been closed. In this sub main you are very flexible, you can
write anything you want.
If you specify a Form as the startup object in the project properties, VB
implicitly creates (invisible) code for you. It looks like this:
sub main
application.run(new form1)
end sub
Surprise, it's the same as above, but this code is fixed. In the first case,
you are free to fill Sub main as you want.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Armin,
Thank you so much for your insightful reply. I spent all day reworking the
communications between the main form and it's many children, based on your
suggestions. I am pleased to say that everything is working fine now. Many
thanks for erasing some of the fuzzy areas in my thinking.
Your second suggestion of using RaiseEvents to send status messages from the
child forms to the main form's status bar is also appealing. I have not got
it working yet, but here is what I have so far:
In frmMain:
Private WithEvents frm As New frmChild
Private Sub frm_StatusMessage(ByVal strMessage As String) Handles
frm.StatusMessage
MessageBox.Show(strMessage, "RaiseEvent", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
In frmChild:
Public Event StatusMessage(ByVal strStatus As String)
RaiseEvent StatusMessage("Houston, we have a problem")
Syntax is accepted, but the event is not trapped by frmMain. Any
suggestions?
Dean Slindee
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Dean Slindee" <sl*****@mindspring.com> schrieb
It's not required to post three times. Sometimes it might take many hours
to get an answer. I'd suggest to wait at least one day before reposting.
(Concerning me, I skipped your posts as soon as I read "WeakReference" because I've never dealt with it. Now I'll try...)
My project has a main form (frmMain, the startup object for the project) and several other "child" forms that are painted within a large panel on frmMain.
In each form's Form_Load event, a Weak Reference for that form is loaded into a global Hash table, like this:
Dim wr As WeakReference = New WeakReference(Me, False)
If Not hashTable.Contains(cfrmMain) Then
hashTable.Add(cfrmMain, wr)
End If
I also have the following declares in frmMain, just after the designer code, for each "child" form that gets painted inside the panel on frmMain:
Friend frmAdmin As New frmAdmin
Friend frmAppointment As New frmAppointment
Friend frmBilling As New frmBilling
Friend frmSystem As New frmSystem Each child form writes to the status bar on frmMain in their Form_Load event.
Problem is, the load events for the child forms are firing before
the load event for frmMain has put a reference into the hash table. How can I get frmMain's Form_Load to fire completely before child Form_Load events
fire? Or, how can I get an entry for frmMain into hashTable before child Form_Load
events fire? You are mixing the order. The order is 1. create form 2. load form 3. show form 4. child paints anything (resp. change the display)
I'd code it appropriately:
dim f as new frmmain f.show 'loading is done implicitly ' just before the form is shown frmmain.refresh frmmain.loadchildforms 'not in form_load
Loadchildforms creates the child instances, so don't declare them "As
/New/ frmAdmin" Another improvement approach is probably to make the child raise events
and catch them in frmMain. In the event handler, frmMain can update it's own status bar.
Above and beyond this specific problem, I would like to find an article that explains in
great detail exactly what happens in sequence when a VB application is launched. Sub main is started. It is running in the one and only thread of the application. The application quits as soon as all threads terminated. If
you have one thread only, the app ends when your main thread ends. To keep sub main running, there must be a loop that keeps the thread and the app
alive. In Windows.Forms applications, sub main contains a message loop that processes all windows messages (key presses, mouse movements,...). If you write sub main on your own, it can look like this:
sub main application.run(new form1) end sub
application.run contains the message loop and it returns as soon as the passed form has been closed. In this sub main you are very flexible, you
can write anything you want.
If you specify a Form as the startup object in the project properties, VB implicitly creates (invisible) code for you. It looks like this:
sub main application.run(new form1) end sub
Surprise, it's the same as above, but this code is fixed. In the first
case, you are free to fill Sub main as you want.
-- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Armin,
Thank you so much for your insightful reply. I spent all day reworking the
communications between the main form and it's many children, based on your
suggestions. I am pleased to say that everything is working fine now. Many
thanks for erasing some of the fuzzy areas in my thinking.
Your second suggestion of using RaiseEvents to send status messages from the
child forms to the main form's status bar is also appealing. I have not got
it working yet, but here is what I have so far:
In frmMain:
Private WithEvents frm As New frmChild
Private Sub frm_StatusMessage(ByVal strMessage As String) Handles
frm.StatusMessage
MessageBox.Show(strMessage, "RaiseEvent", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
In frmChild:
Public Event StatusMessage(ByVal strStatus As String)
RaiseEvent StatusMessage("Houston, we have a problem")
Syntax is accepted, but the event is not trapped by frmMain. Any
suggestions?
Dean Slindee
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Dean Slindee" <sl*****@mindspring.com> schrieb
It's not required to post three times. Sometimes it might take many hours
to get an answer. I'd suggest to wait at least one day before reposting.
(Concerning me, I skipped your posts as soon as I read "WeakReference" because I've never dealt with it. Now I'll try...)
My project has a main form (frmMain, the startup object for the project) and several other "child" forms that are painted within a large panel on frmMain.
In each form's Form_Load event, a Weak Reference for that form is loaded into a global Hash table, like this:
Dim wr As WeakReference = New WeakReference(Me, False)
If Not hashTable.Contains(cfrmMain) Then
hashTable.Add(cfrmMain, wr)
End If
I also have the following declares in frmMain, just after the designer code, for each "child" form that gets painted inside the panel on frmMain:
Friend frmAdmin As New frmAdmin
Friend frmAppointment As New frmAppointment
Friend frmBilling As New frmBilling
Friend frmSystem As New frmSystem Each child form writes to the status bar on frmMain in their Form_Load event.
Problem is, the load events for the child forms are firing before
the load event for frmMain has put a reference into the hash table. How can I get frmMain's Form_Load to fire completely before child Form_Load events
fire? Or, how can I get an entry for frmMain into hashTable before child Form_Load
events fire? You are mixing the order. The order is 1. create form 2. load form 3. show form 4. child paints anything (resp. change the display)
I'd code it appropriately:
dim f as new frmmain f.show 'loading is done implicitly ' just before the form is shown frmmain.refresh frmmain.loadchildforms 'not in form_load
Loadchildforms creates the child instances, so don't declare them "As
/New/ frmAdmin" Another improvement approach is probably to make the child raise events
and catch them in frmMain. In the event handler, frmMain can update it's own status bar.
Above and beyond this specific problem, I would like to find an article that explains in
great detail exactly what happens in sequence when a VB application is launched. Sub main is started. It is running in the one and only thread of the application. The application quits as soon as all threads terminated. If
you have one thread only, the app ends when your main thread ends. To keep sub main running, there must be a loop that keeps the thread and the app
alive. In Windows.Forms applications, sub main contains a message loop that processes all windows messages (key presses, mouse movements,...). If you write sub main on your own, it can look like this:
sub main application.run(new form1) end sub
application.run contains the message loop and it returns as soon as the passed form has been closed. In this sub main you are very flexible, you
can write anything you want.
If you specify a Form as the startup object in the project properties, VB implicitly creates (invisible) code for you. It looks like this:
sub main application.run(new form1) end sub
Surprise, it's the same as above, but this code is fixed. In the first
case, you are free to fill Sub main as you want.
-- Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Hi Dean,
I reviewed your code snippet and it seems correct for the event handling.
The following MSDN arcticle describes it in details:
Raising Events and Responding to Events http://msdn.microsoft.com/library/de...us/dndotnet/ht
ml/raiserespeven.asp
For further research, could you please tell me when you call RaiseEvent in
frmChild? Is it possible for you to post a simple reproducible project?
I look forward to hearing from you.
Have a nice day!
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Hi Dean,
I reviewed your code snippet and it seems correct for the event handling.
The following MSDN arcticle describes it in details:
Raising Events and Responding to Events http://msdn.microsoft.com/library/de...us/dndotnet/ht
ml/raiserespeven.asp
For further research, could you please tell me when you call RaiseEvent in
frmChild? Is it possible for you to post a simple reproducible project?
I look forward to hearing from you.
Have a nice day!
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
"Dean Slindee" <sl*****@mindspring.com> schrieb I have not got it working yet, but here is what I have so far: In frmMain: Private WithEvents frm As New frmChild
Private Sub frm_StatusMessage(ByVal strMessage As String) Handles frm.StatusMessage
MessageBox.Show(strMessage, "RaiseEvent", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
In frmChild:
Public Event StatusMessage(ByVal strStatus As String)
RaiseEvent StatusMessage("Houston, we have a problem")
Syntax is accepted, but the event is not trapped by frmMain. Any suggestions?
I guess you never show frm but another instance. Where is Raiseevent
located? Set a breakpoint at Raiseevent and look if it's reached.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Dean Slindee" <sl*****@mindspring.com> schrieb I have not got it working yet, but here is what I have so far: In frmMain: Private WithEvents frm As New frmChild
Private Sub frm_StatusMessage(ByVal strMessage As String) Handles frm.StatusMessage
MessageBox.Show(strMessage, "RaiseEvent", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
In frmChild:
Public Event StatusMessage(ByVal strStatus As String)
RaiseEvent StatusMessage("Houston, we have a problem")
Syntax is accepted, but the event is not trapped by frmMain. Any suggestions?
I guess you never show frm but another instance. Where is Raiseevent
located? Set a breakpoint at Raiseevent and look if it's reached.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Thanks for the link to the Microsoft web page. I built the example, which
eventually
led me to discover the solution to being able to get RaiseEvent working in
my project.
Thanks again.
Dean Slindee
"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:5h*************@cpmsftngxa06.phx.gbl... Hi Dean,
I reviewed your code snippet and it seems correct for the event handling. The following MSDN arcticle describes it in details:
Raising Events and Responding to Events http://msdn.microsoft.com/library/de...us/dndotnet/ht ml/raiserespeven.asp
For further research, could you please tell me when you call RaiseEvent in frmChild? Is it possible for you to post a simple reproducible project?
I look forward to hearing from you.
Have a nice day!
Regards,
HuangTM Microsoft Online Partner Support MCSE/MCSD
Get Secure! -- www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Thanks for the link to the Microsoft web page. I built the example, which
eventually
led me to discover the solution to being able to get RaiseEvent working in
my project.
Thanks again.
Dean Slindee
"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:5h*************@cpmsftngxa06.phx.gbl... Hi Dean,
I reviewed your code snippet and it seems correct for the event handling. The following MSDN arcticle describes it in details:
Raising Events and Responding to Events http://msdn.microsoft.com/library/de...us/dndotnet/ht ml/raiserespeven.asp
For further research, could you please tell me when you call RaiseEvent in frmChild? Is it possible for you to post a simple reproducible project?
I look forward to hearing from you.
Have a nice day!
Regards,
HuangTM Microsoft Online Partner Support MCSE/MCSD
Get Secure! -- www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: yagish |
last post by:
Hi Techies,
Am really new with the Oracle 9i Forms and am searching for a way to
perform Load Balancing in Oracle 9i Forms Application. Its not a J2EE
application, so cannot go the OC4J way.
I...
|
by: brianbender |
last post by:
I am trying to load and unload assemblies dynamically and call methods
and properties when loaded into an Appdomain
I can load assemblies all day in the current AppDomain without
references and...
|
by: Dean Slindee |
last post by:
My project has a main form (frmMain, the startup object for the project) and
several other "child" forms that are painted within a large panel on
frmMain.
In each form's Form_Load event, a Weak...
|
by: Dean Slindee |
last post by:
My project has a main form (frmMain, the startup object for the project) and
several other "child" forms that are painted within a large panel on
frmMain.
In each form's Form_Load event, a Weak...
|
by: Elmo Watson |
last post by:
Let's say I have a child form - frmEdit - on that form a RichText Box called
txtedit
So - in VB6 days - I used to be able to refer to that particular active
form's Rich Text box - like this:
...
|
by: Brett Romero |
last post by:
If my UI app uses three DLLs and two of those DLLs reference something
named utilities.dll, does the UI app load utilities.dll twice or does
the compiler recognize what is going on and load...
|
by: soahil |
last post by:
Hi and thanks to pragatiswain for reply.
i tell u about tables in the database.
TABLE NAMES are "SUB_HEAD","CATEGORY","COMPANY","BILL","BILL_DETAIL.
I've a master detail relationship b/w BILL...
|
by: jmartmem |
last post by:
Greetings,
I have an ASP page with two dynamic dependent list boxes written in JavaScript. My dependent lists work great, but my problem is that the values for "Program_Name" and "Project_Name"...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |