473,473 Members | 1,959 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to restrict the multiple opening of the Same window...

If I click a menu to open a form which already open...the vb.net opens a new
window while existing open window is there...i want to restric the opening of
a new instance of an already opened form...
and also ...
if i open a form from a child form of an MDI form, the recently opened form
also should be the child of that MDI form...
--
Peter...
Nov 21 '05 #1
2 2898
"Prabhudhas Peter" <Pr*************@discussions.microsoft.com> schrieb:
If I click a menu to open a form which already open...the vb.net opens a
new
window while existing open window is there...i want to restric the opening
of
a new instance of an already opened form...
and also ...
\\\
Private m_Child As Form2

Private Sub Button1_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button1.Click
If m_Child Is Nothing Then
m_Child = New Form2()
m_Child .MdiParent = Me
AddHandler m_Child.Load, AddressOf Me.MdiChild_Load
AddHandler m_Child.Closed, AddressOf Me.MdiChild_Closed
End If
m_Child.Show() ' ...
End Sub

Private Sub MdiChild_Load( _
ByVal sender As Object, _
ByVal e As EventArgs _
)
MsgBox( _
"MDI child with handle " & _
DirectCast(sender, Form).Handle.ToString() & _
" loaded!" _
)
End Sub

Private Sub MdiChild_Closed( _
ByVal sender As Object, _
ByVal e As EventArgs _
)
MsgBox( _
"MDI child with handle " & _
DirectCast(sender, Form).Handle.ToString() & _
" closed!" _
)
m_Child = Nothing
End Sub
///

Alternatively you can implement the Singleton design pattern in your MDI
child form:

Implementing the Singleton Pattern in C#
<URL:http://www.yoda.arachsys.com/csharp/singleton.html>

Exploring the Singleton Design Pattern
<URL:http://msdn.microsoft.com/library/en-us/dnbda/html/singletondespatt.asp>

Design Pattern: Singleton in C#
<URL:http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=486>

Design Patterns: Singleton
<URL:http://www.dofactory.com/Patterns/PatternSingleton.aspx>
if i open a form from a child form of an MDI form, the recently opened
form
also should be the child of that MDI form...


\\\
Dim f As New FooForm()
f.MdiParent = Me.MdiParent
f.Show()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Woo
ur coding works great. but what if i hv different forms for different usage?
i need to repeat the load and close to indicate those forms = nothing? maybe
you could advise on that. thanks a lot.

"Herfried K. Wagner [MVP]" wrote:
"Prabhudhas Peter" <Pr*************@discussions.microsoft.com> schrieb:
If I click a menu to open a form which already open...the vb.net opens a
new
window while existing open window is there...i want to restric the opening
of
a new instance of an already opened form...
and also ...


\\\
Private m_Child As Form2

Private Sub Button1_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button1.Click
If m_Child Is Nothing Then
m_Child = New Form2()
m_Child .MdiParent = Me
AddHandler m_Child.Load, AddressOf Me.MdiChild_Load
AddHandler m_Child.Closed, AddressOf Me.MdiChild_Closed
End If
m_Child.Show() ' ...
End Sub

Private Sub MdiChild_Load( _
ByVal sender As Object, _
ByVal e As EventArgs _
)
MsgBox( _
"MDI child with handle " & _
DirectCast(sender, Form).Handle.ToString() & _
" loaded!" _
)
End Sub

Private Sub MdiChild_Closed( _
ByVal sender As Object, _
ByVal e As EventArgs _
)
MsgBox( _
"MDI child with handle " & _
DirectCast(sender, Form).Handle.ToString() & _
" closed!" _
)
m_Child = Nothing
End Sub
///

Alternatively you can implement the Singleton design pattern in your MDI
child form:

Implementing the Singleton Pattern in C#
<URL:http://www.yoda.arachsys.com/csharp/singleton.html>

Exploring the Singleton Design Pattern
<URL:http://msdn.microsoft.com/library/en-us/dnbda/html/singletondespatt.asp>

Design Pattern: Singleton in C#
<URL:http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=486>

Design Patterns: Singleton
<URL:http://www.dofactory.com/Patterns/PatternSingleton.aspx>
if i open a form from a child form of an MDI form, the recently opened
form
also should be the child of that MDI form...


\\\
Dim f As New FooForm()
f.MdiParent = Me.MdiParent
f.Show()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

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

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
4
by: john | last post by:
How do u guys handle multiple sessions?? i.e, opening different browser windows by running iexplore.exe or clicking IE icons and opening the application. My sessions are mixing up. what i mean is...
7
by: Evan Kontos | last post by:
I am using the window.open function to open a small window and I am using GET to get values back from that window. I want to be able to open another from the second window but I get an error...
3
by: Voetleuce en f?nsievry | last post by:
G'day I'm looking for a script that can search multiple instances of Google (or other search engines optionally). The user types in a single word in the text field, presses ENTER or the submit...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
6
by: Shashi | last post by:
I have developed ASP.Net application using .Net 1.1 Framework. When the user clicks image file through Java script I am using my search window as below. QueryString =...
2
by: helpSeekar | last post by:
My application sends out alerts with multiple hyperlinks in it. Each time user clicks on a link, it opens up a new window in case of yahoo, hotmail email clients. In case of lotus notes email...
1
by: dnes | last post by:
Open Multiple New Browser Windows from ASP.NET I'm having trouble figuring out how to open multiple new browser windows (each one displaying something different). As you can see from the code...
6
by: vermarajeev | last post by:
Hi all, How can I restrict a user to open the same file on multiple instances of the same application???? If you have word installed, then open multiple instances of it and try opening the same...
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,...
1
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...
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.