By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,550 Members | 918 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,550 IT Pros & Developers. It's quick & easy.

the form already on loaded...

P: n/a
dim frm2 as new form2
frm2.mdiparent =me
frm2.name="eu.undernet.org"
frm2.show()
every time i clicked on menu , the new frm2 is added again. how do i
prevent if frm2 is already on loaded.
i'm working on irc chat similar to mirc.
regards,

Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Supra,

I made this method for it.
(Wherin I added an improvement Jef pointed me on).

I hope it works for you?

Cor
\\\
Private Sub mnuFrmHandling(ByVal frmName As String)
For Each frm As Form In Me.MdiChildren
If frm.Name = frmName Then
frm.BringToFront()
Exit Sub
End If
Next
Dim frmNew As Form
Select Case frmName
Case "Persons"
frmNew = New frmPersons
Case "Actions"
frmNew = New frmActions
Case Else
frmNew = New frmTabellen(frmName)
End Select
frmNew.MdiParent = Me
frmNew.Show()
frmNew.WindowState = FormWindowState.Maximized
frmNew.Name = frmName
frmNew.BringToFront()
End Sub
///

I hope this helps?

Cor
Nov 20 '05 #2

P: n/a
* Supra <su*****@rogers.com> scripsit:
dim frm2 as new form2
frm2.mdiparent =me
frm2.name="eu.undernet.org"
frm2.show()
every time i clicked on menu , the new frm2 is added again. how do i
prevent if frm2 is already on loaded.

i'm working on irc chat similar to mirc.


Do a Google search for the Singleton design pattern and implement this
design pattern in your forms that should only be shown once.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #3

P: n/a
Herfried,

Did you look at the method I made, it is really very nice after that Jef
told that I had made something to much in it. It started as a simple sample
for Charles.

(I write this more because I did not expect you today)

:-)

Cor
Nov 20 '05 #4

P: n/a
thank lightert. this is what i'm looking for:

For Each frm As Form In Me.MdiChildren
If frm.Name = frmName Then
frm.BringToFront()
Exit Sub
End If
Next

many thank to u.
regards,


Cor Ligthert wrote:
Herfried,

Did you look at the method I made, it is really very nice after that Jef
told that I had made something to much in it. It started as a simple sample
for Charles.

(I write this more because I did not expect you today)

:-)

Cor


Nov 20 '05 #5

P: n/a
Private Sub mnuInfo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuInfoAlias.Click, mnuInfoStart.Click,
mnuInfoChan.Click
Dim mi As MenuItem = CType(sender, MenuItem)
Select Case mi.Text
Case "Aliases..."
mnuFrmHandling(mi.Text)
Case "Startup..."
mnuFrmHandling(mi.Text)
Case "Channels..."
mnuFrmHandling(mi.Text)
End Select
End Sub

Private Sub mnuFrmHandling(ByVal frmName As String)

For Each frm As Form In Me.MdiChildren
If frm.Name = frmName Then
frm.BringToFront()
Exit Sub
End If
Next

Dim frmNew As frmAlias
frmNew = New frmAlias
frmNew.MdiParent = Me
frmNew.Name = frmName

Select Case frmName
Case "Aliases..."
frmNew.Text = frmName

Case "Startup..."
frmNew.Text = frmName

Case "Channels..."
frmNew.Text = frmName
Case "DCC CHAT"
Case "DCC SEND"
Case "FILE TRANSFER"
Case "BAN"
Case "KICK"
Case "JOIN"
Case "PART"
Case "QUIT"
End Select
frmNew.Show()
End Sub
regards,

Cor Ligthert wrote:
Herfried,

Did you look at the method I made, it is really very nice after that Jef
told that I had made something to much in it. It started as a simple sample
for Charles.

(I write this more because I did not expect you today)

:-)

Cor


Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.