473,386 Members | 1,706 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,386 software developers and data experts.

How to invoke a form to show?

I have a form first created my the main thread.
I have another thread monitoring the IO.
Upon receiving certain message, I want to show/unhide the form.

When the form is first created ( handle is not created until it is first
shown ).
How do my IO thread invoke the form to show? ( in order to invoke the form,
the form handle must be created )

Thanks.
Nov 17 '05 #1
4 6527
"Altramagnus" <al*********@hotmail.com> schrieb
I have a form first created my the main thread.
I have another thread monitoring the IO.
Upon receiving certain message, I want to show/unhide the form.

When the form is first created ( handle is not created until it is
first shown ).
How do my IO thread invoke the form to show? ( in order to invoke the
form, the form handle must be created )

Thanks.


2 suggestions: You could call CreateHandle in the main thread after the form
has been created. Or, use an empty dummy form created in the main thread
used by (Begin)Invoke in the 2nd thread. The target procedure in the main
thread then shows the actual form.

Armin

Nov 17 '05 #2
Thanks

The first method would not work because,
even you explictly call CreateHandle, the handle would still not be created
until the form is first visible.
In other words, if the form is not visible, createHandle does nothing.

The second method works if i have a existing form that is already shown.
It will still be a problem if I have no existing form.

Thanks.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Altramagnus" <al*********@hotmail.com> schrieb
I have a form first created my the main thread.
I have another thread monitoring the IO.
Upon receiving certain message, I want to show/unhide the form.

When the form is first created ( handle is not created until it is
first shown ).
How do my IO thread invoke the form to show? ( in order to invoke the
form, the form handle must be created )

Thanks.


2 suggestions: You could call CreateHandle in the main thread after the
form has been created. Or, use an empty dummy form created in the main
thread used by (Begin)Invoke in the 2nd thread. The target procedure in
the main thread then shows the actual form.

Armin

Nov 17 '05 #3
"Altramagnus" <al*********@hotmail.com> schrieb
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Altramagnus" <al*********@hotmail.com> schrieb
I have a form first created my the main thread.
I have another thread monitoring the IO.
Upon receiving certain message, I want to show/unhide the form.

When the form is first created ( handle is not created until it
is first shown ).
How do my IO thread invoke the form to show? ( in order to invoke
the form, the form handle must be created )
2 suggestions: You could call CreateHandle in the main thread after
the form has been created. Or, use an empty dummy form created in
the main thread used by (Begin)Invoke in the 2nd thread. The target
procedure in the main thread then shows the actual form.


The first method would not work because,
even you explictly call CreateHandle, the handle would still not be
created until the form is first visible.
In other words, if the form is not visible, createHandle does
nothing.


Sure? I tried it and it worked. In a new project, add a button and this code
(sorry, VB.NET, but you'll see the point):

Shared f As Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

f = New Form1
f.CreateHandle()
Dim t As New Threading.Thread(AddressOf a)
t.Start()
End Sub
Private Delegate Sub d()
Private Shared Sub a()
f.BeginInvoke(New d(AddressOf b))
End Sub
Private Shared Sub b()

End Sub

Exception without createhandle, no exception with createhandle.

The second method works if i have a existing form that is already
shown. It will still be a problem if I have no existing form.


Yes, that's why you could add one, but you don't have to show it.
Armin

Nov 17 '05 #4
OK thanks.

I think CreateHandle works.
Sorry it was my mistake.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:u$**************@TK2MSFTNGP15.phx.gbl...
"Altramagnus" <al*********@hotmail.com> schrieb
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Altramagnus" <al*********@hotmail.com> schrieb
I have a form first created my the main thread.
I have another thread monitoring the IO.
Upon receiving certain message, I want to show/unhide the form.

When the form is first created ( handle is not created until it
is first shown ).
How do my IO thread invoke the form to show? ( in order to invoke
the form, the form handle must be created )

2 suggestions: You could call CreateHandle in the main thread after
the form has been created. Or, use an empty dummy form created in
the main thread used by (Begin)Invoke in the 2nd thread. The target
procedure in the main thread then shows the actual form.


The first method would not work because,
even you explictly call CreateHandle, the handle would still not be
created until the form is first visible.
In other words, if the form is not visible, createHandle does
nothing.


Sure? I tried it and it worked. In a new project, add a button and this
code
(sorry, VB.NET, but you'll see the point):

Shared f As Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

f = New Form1
f.CreateHandle()
Dim t As New Threading.Thread(AddressOf a)
t.Start()
End Sub
Private Delegate Sub d()
Private Shared Sub a()
f.BeginInvoke(New d(AddressOf b))
End Sub
Private Shared Sub b()

End Sub

Exception without createhandle, no exception with createhandle.

The second method works if i have a existing form that is already
shown. It will still be a problem if I have no existing form.


Yes, that's why you could add one, but you don't have to show it.
Armin

Nov 17 '05 #5

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

Similar topics

1
by: Peter Rilling | last post by:
What events are fired when the Form.Show() and Form.Hide() methods are called. I know Load fires the first time, but what about showing and hiding the form at any point during its life cycle? ...
3
by: Ivan Weiss | last post by:
I have been using form.show to display my forms yet I see a lot of people using form.Showdialog. What are the differences and when is one better than the other or are they the same...? -Ivan...
5
by: Peter | last post by:
I want to have a form named 'frmUpdating' that pops up on a clients screen while a loop is cycling and disapears when the loop ends. The 'frmUpdating' form has a real cool animation on it and it...
3
by: yzi | last post by:
I have a list form and a detail form . Before, I open the List form, use form.showDialog(),then I click List Item and open the Detail Form by form.show(). now , user need when the list form...
8
by: PAPutzback | last post by:
How do I keep the form up.
2
by: vooose | last post by:
Form form = new Form(); when you call ShowWindow(form, SW_SHOWNOACTIVATE); the form disappears the next time the garbage collector is called, assuming the form variable has gone out of...
4
by: Marc the Demi-Programmer | last post by:
I have a rather simple form that takes a user name and password, validates it, and loads another form. All this is done in the click event for the one and only button on the form. Everything...
10
by: Matt Nunnally | last post by:
Its been a while since I worked with VB6, so hang with me if this is stupid. How do I get past the Form.show method if I call it in a function? Here is the scenario. Sub Whatever() Some Code...
0
by: mvenkatesan | last post by:
Hi I want child form show assign to thread from main form I was assigned thread in main forn button click abort the thread on child form dispose. but child form dont display it is sparkle. ...
1
by: helpmewithasp | last post by:
I am getting error as assembly or reference missing for form.Show() method. What refernce shall I add for this??
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
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 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.