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

how to check if a form is already open

TM
Is there any way to check if a form is already pen and if so set the focus
to it instead of opening another instance of that form ?

Thanks
--
Tony


Nov 20 '05 #1
7 11270
Cor
Hi Tonny,
Is there any way to check if a form is already pen and if so set the focus
to it instead of opening another instance of that form ?


Hi Tonny, sorry that I have to write this, but this is the answer.

"Use good program logic"

Cor
Nov 20 '05 #2
* "TM" <no********@nothing.com> scripsit:
Is there any way to check if a form is already pen and if so set the focus
to it instead of opening another instance of that form ?


Have a Google Search for "Singleton Design Pattern".

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #3
On Tue, 24 Feb 2004 23:59:17 -0500, "TM" <no********@nothing.com>
wrote:
Is there any way to check if a form is already pen and if so set the focus
to it instead of opening another instance of that form ?

Thanks


It's not very easy. You could use Win API functions to enumerate all
windows and look for the window in question. (eg, EnumThreadWindows)

I had hoped that the static .NET function
System.Windows.Forms.Form.ActiveForm() would help me determine if ANY
forms were open besides the "main" form.

Unfortunately, I found it had a few quirks that limited its usefulness
for me:

(1) ActiveForm returns "Nothing" if the application does not
have focus.
(2) .. Returns "Nothing" if a non-application form is being
displayed (eg, a MsgBox() is open)

I think that you'll have to either resort to a windows enumeration or
building the functionality by adding code to implement the "singleton"
design pattern.

// CHRIS

Nov 20 '05 #4
TM
Sorry but that is not an answer. I am new to .Net and have no idea how to
do this in vb.net.

I have a button to add a new record into the database which opens a form
with the fields and such.

I want to prevent someone from opening that form more than once
--
Tony

"Cor" <no*@non.com> wrote in message
news:up****************@TK2MSFTNGP10.phx.gbl...
Hi Tonny,
Is there any way to check if a form is already pen and if so set the focus to it instead of opening another instance of that form ?


Hi Tonny, sorry that I have to write this, but this is the answer.

"Use good program logic"

Cor

Nov 20 '05 #5
Cor
Hi Tony,

Use good program logic was the answer.

What is not good on it. There are so many logical methods for that.
One sample.

If you want to prevent that the form is opened twice you set that button to
invisible and set it to visible if the form is closed.

Very easy and simple programming logic.

Cor

Nov 20 '05 #6
On Wed, 25 Feb 2004 14:27:48 -0500, "TM" <no********@nothing.com>
wrote:
Sorry but that is not an answer. I am new to .Net and have no idea how to
do this in vb.net.

I have a button to add a new record into the database which opens a form
with the fields and such.

I want to prevent someone from opening that form more than once
--
Tony


In that case, just define the form normally and call it like this:

Dim myForm As New FormName
myForm.ShowDialog()

Then the user interface will be essentially disabled until the user is
done with the form... a basic "modal" form..

// CHRIS

Nov 20 '05 #7

Cor wrote:
*Hi Tonny,
Is there any way to check if a form is already pen and if so set

the focus
to it instead of opening another instance of that form ?


Hi Tonny, sorry that I have to write this, but this is the answer.

"Use good program logic"

Cor *

Only registered to reply to this post. I was looking for similiar
answers/solutions.Felt compelled to reply to it even though it's such
an old post.

This kind of post doesn't help one bit. It's like a teacher you had
back in school you asked for help on a spelling of a word. Thier reply
is look it up in the dictionary.

i've got a helpful reply

'Go seek the holy grail' thats were you will find your answer

Suffice to say this post was no f****** help at all and just someones
lazy 'I'm better than you' poor attitude.

Dakine

--
dakine181
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message423947.html

Mar 4 '06 #8

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

Similar topics

7
by: Shaldaman | last post by:
Hi Is there a property in MS Access for the following: 1) For a Command Button on a form, is there a property that can be used to determine if it has been clicked? eg: Me!button7.Clicked - I...
3
by: Shelby | last post by:
Hi, how can I check that if the form is already open? Whenever I click on a button, it will open the form. I would like to check if the form is open.
4
by: jes | last post by:
hi, i have an open & delete btn. onclick of open as visio drawing opens in visio & onclick of delete the drawing gets deleted from the filesystem. The problem is i am unable to perform these...
3
by: Eagle | last post by:
Hi, I've got an input form (frmInput) that can be accessed in two ways. A combobox on this form either gets filled in by a selection on an already opened form (frmBasic), or one can input a...
9
by: KelsMckin | last post by:
Hello, I was wondering if there was a way to check there was already a form open before opening a new one, sorry that doesnt seem clear, here is an example: The following button opens a new form...
6
by: JayDawg | last post by:
Is there a way to tell access to open or make visible one of two other forms/subforms depending upon whether the yes no check box is true or false. I have a data entry form that collects data on...
2
by: Kimmo Laine | last post by:
Hi! Is there a way to check if file is already open/used by another process? I know that i can do something like this to check it try { StreamWriter sw = new StreamWriter(filename);...
19
by: =?Utf-8?B?R3JlZw==?= | last post by:
How can I tell via code if a Form is already open. Each time my forms load I have some initialization code that runs, but if the form is already open and hidden I don't want that initialization...
2
by: KA NMC | last post by:
Current application is built in VB.net 2005 what it does is open other small applications within the form. I'm not using mdi I probably should. Here is my problem The application load - main...
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
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...
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
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
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.