the form already on loaded...

  • Thread starter Thread starter Supra
  • Start date Start date
S

Supra

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,
 
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
 
* Supra said:
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.
 
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
 
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,
 
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,
 
Back
Top