i am wrting a small prog. that uses a Mdiform with one childform(ie. Form1.the form is set as mdidhild=true).
I can make an array ( a Set No. of forms to add )for the ChildForms and
assign then toolbar buttons so when i click a button the right window shows.
The main point is how can i add a ChildForm as and when i need and still assign it to a Toolbar Button.
I Have tried but all that happens is the last ChildForm shows.
any help is much appreciated
I'll offer 50 points but if you feel it needs more and i agree i will oblige
Uh.. Huh?
"The main point is how can I add a ChildForm as and when i need and still assign it to a Toolbar Button."
To a Standard.Exe Project..
1. Add an MDIForm
2. Add a Toolbar to the MDIForm
3. Change the Form1.MDIChild property to True
4. Copy and Paste the following code into MDIForm1
<----- Code Begin ----->
Option Explicit
Private Sub MDIForm_Load()
xAddForm
xAddForm
xAddForm
End Sub
Private Sub xAddForm()
Static intChildForm As Integer
Dim strChildForm As String
intChildForm = intChildForm + 1
strChildForm = "Form" & Format(intChildForm, "0##")
' Add a Toolbar Button
Dim btnWork As Button
Set btnWork = Toolbar1.Buttons.Add()
btnWork.Key = strChildForm
btnWork.Caption = strChildForm
btnWork.ToolTipText = strChildForm
Dim frmChild As New Form1
Load frmChild
frmChild.Caption = strChildForm
frmChild.Tag = strChildForm
frmChild.Show
End Sub
Private Sub Toolbar1_ButtonClick(ByVal
If Left(Button.Key, 4) = "Form" _
Then
Dim frmWork As Form
For Each frmWork In Forms
With frmWork
If .Tag = Button.Key _
Then
.Caption = "This Form Is Active"
.SetFocus
Else
.Caption = .Tag
End If
End With
Next frmWork
Exit Sub
End If
End Sub
<----- Code End ----->
5. ENJOY !!!!