473,602 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6544
"Altramagnu s" <al*********@ho tmail.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*******@free net.de> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"Altramagnu s" <al*********@ho tmail.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
"Altramagnu s" <al*********@ho tmail.com> schrieb
"Armin Zingler" <az*******@free net.de> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"Altramagnu s" <al*********@ho tmail.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click

f = New Form1
f.CreateHandle( )
Dim t As New Threading.Threa d(AddressOf a)
t.Start()
End Sub
Private Delegate Sub d()
Private Shared Sub a()
f.BeginInvoke(N ew 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*******@free net.de> wrote in message
news:u$******** ******@TK2MSFTN GP15.phx.gbl...
"Altramagnu s" <al*********@ho tmail.com> schrieb
"Armin Zingler" <az*******@free net.de> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"Altramagnu s" <al*********@ho tmail.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click

f = New Form1
f.CreateHandle( )
Dim t As New Threading.Threa d(AddressOf a)
t.Start()
End Sub
Private Delegate Sub d()
Private Shared Sub a()
f.BeginInvoke(N ew 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
18679
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? From looking at Reflector, it looks like no event is fired. I would have through the VisibleChanged event would fire, but Reflector shows that it only fires when the form is an MDI type.
3
6765
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 *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
5
2506
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 starts running immediately after it is shown. It loops indefinately. What I want to be able to do is have this form show up on the first cycle of the loop and then exit after the loop exits. How should I tackle this problem?
3
4030
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 show, auto open the first Item Detail . I add detail form.show() in list form.form_load event , but problem. some idea?? help me
2
5526
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 scope. When you call form.Show() you don't get this behaviour. Why is this? How can you make ShowWindow( ) behave the same way as Show(), in that the window doesnt
4
1333
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 works fine except that after the event is finished the form breaks because of an unhandled system.argument exception, and highlights the form class declaration. This only happens when I do the form.show command in the click event. When I comment it...
10
5767
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 Here frmProcess.Show vbModal Some More Code Here
0
1161
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. whats problem how do assign child form show from main form? Thanks in advance
1
1356
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
7993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.