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

How to tell what other forms are opened.

I have an application with a menu system which creates a new thread when a
menu item is selected - some of these other threads may open a form for user
interaction.

Before the menu system is closed, I want to check that no other forms are
open - on any thread. Is there a way of checking for this easily? At
the moment, I'm not keeping track of new threads that I create ie I create
the new thread using code similar to as follows:

private sub RunMenu
dim obj as new myclass
dim t as new threading.thread(addressof obj.subroutinename)
t.start
end sub

How can I do this?

Thanks in advance
Simon

Nov 21 '05 #1
5 1425
A very simple example:

Dim frm as Form1

If Not (frm Is Nothing) Then
MessageBox.Show("Form Exists")
Else
frm = new Form1
frm.ShowDialog()
End If

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
Thanx for that.. Perhaps I should have explained better.

The menu system I have works on an XML file that contains the menu items,
along with dll names, class names and entry points - I create the object
through reflection and then start up a new thread to call it. I don't
keep track of the threads after I've started them off.

What I really want to do is know whether any forms started by these threads
are currently still running before I close the menu system down - i.e I
don't want the menu system closed whilst the application is running.

Maybe I should be searching for threads rather than forms?

Regards
Simon
"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
A very simple example:

Dim frm as Form1

If Not (frm Is Nothing) Then
MessageBox.Show("Form Exists")
Else
frm = new Form1
frm.ShowDialog()
End If

Crouchie1998
BA (HONS) MCP MCSE

Nov 21 '05 #3
Hi Simon,

Herez a thought -

When your threads create a form you could add it to a collection and on
closing the form remove it from the collection. So your collection would have
a list of open forms and you could iterate the collection to see if it has
any forms before closing the app.

VB.NET does not have an inbuilt Forms collection, but you could create a
class that behaves like a collection. Check out this link for some sample
code for the same.

http://www.dotnet247.com/247referenc...21/107856.aspx

HTH
Nov 21 '05 #4
Sarika

Thanks for the thought, whilst this would be a little re-engineering of my
application to get working, I think I might be able to do the same with the
threads that I am creating - If I add each thread to a collection as I start
it up, then I can iterate through the collection at a later point and check
to see that all the threads have exited?

Regards
Simon
"Sarika" <Sa****@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com...
Hi Simon,

Herez a thought -

When your threads create a form you could add it to a collection and on
closing the form remove it from the collection. So your collection would
have
a list of open forms and you could iterate the collection to see if it has
any forms before closing the app.

VB.NET does not have an inbuilt Forms collection, but you could create a
class that behaves like a collection. Check out this link for some sample
code for the same.

http://www.dotnet247.com/247referenc...21/107856.aspx

HTH

Nov 21 '05 #5
Yes I think that should work too.
Nov 21 '05 #6

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

Similar topics

6
by: newbie_csharp | last post by:
Hi, I have a class structure like this: rootform : System.Windows.Forms.Form midiform : rootform child1 : rootform child11 : child1 child2 : rootform chld21 : child2
18
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to...
2
by: Bruno Rodrigues | last post by:
Hey, it's me again. Is there a way to, when closing a form, close also all forms opened inside this one? I'm not talking about MDI. Let's say I create and open three forms in Form1. When I close...
8
by: Edwinah63 | last post by:
Hi Everyone, in vb6 i was able to execute the following code and it would close the children is the reverse order they were opened eg the last child opened was the first child to close. in...
7
by: Jeff | last post by:
I plan to write a Windows Forms MDI application for a medical office. Users must be able to select a patient and view related information on multiple forms; with1-4 forms opened at the same time...
18
by: shilpa.saraogi | last post by:
Heya all, How do I tell, prgrammatically, if a file is opened for read/write by some other process? In unix .. of course. My program needs to open files and work on it, and I want it to make...
1
by: robertmeyer1 | last post by:
Hey, I am having a problem with opening some forms. I have several forms. The forms are based off the same table, tblClient. Each form has a sbf inserted into it. These sbf’s are each based...
4
by: Peter | last post by:
Access 2007 optionally opens forms as tabs. There is an Access Option that controls this - Access Options Current Database Document Window Options Tabbed Documents. But how, from VBA, can I...
3
JodiPhillips
by: JodiPhillips | last post by:
Hello All, I'm trying to limit the number of attempts a user has to log into an MS Access 2003 database, but am having very little success. My current code for log in is as follows (and thanks...
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: 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
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
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,...
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...

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.