[RESOLVED] Getting All the windows in an array
I have a MDI window and i want all of my child windows in a collection or and array. all my child windows are created with one form frmDoc and loaded using
Code:
Dim newD As New FrmDoc
newD.Show
so if i have all the forms in a collection i can change a property in the specific form's, object.
Code:
eg:
collection.items(1).cmd1.caption="ok"
collection.items(5).cmd1.caption="ok"
does anybody know how to do this?
Re: Getting All the windows in an array
Since i needed a good multiple document handling for my MDI based app i had some idea about this... u could create an array of frmDocs but they way u have it... try to do this:
Code:
Dim frm As Form
For Each frm In Forms
frm.cmd1.caption = "ok"
Next
Hope this helps if not tell me and i will tell u the array way :)
Re: Getting All the windows in an array
ok how do i do this in an array? i want to do this as an array coz i need to call commands directly without for next loops using there indexed or ids.
Re: Getting All the windows in an array
Ah ok but if u want to call them all is faster with a loop :)
Well this is the way i do it kk there maybe different ways but this works cool.
Declarations:
Code:
Public newD() As New FrmDoc
Public freei As Integer
New document code:
Code:
freei = FreeIndex()
If freei = 0 Then
freei = 1
ReDim newD(1 To 1)
End If
newD(freei).Show
Free Index function:
Code:
Function FreeIndex() As Integer
On Error GoTo errsub
Dim i As Integer
Dim ArrayC As Integer
ArrayC = UBound(newD)
ReDim Preserve newD(1 To ArrayC + 1)
FreeIndex = UBound(newD)
Exit Function
errsub:
FreeIndex = 0
End Function
Hope it helps!
Re: Getting All the windows in an array
looks cool should work with my existing code. ill tell you if it worked. may be im gonna have to play around a little with this.
thanx alot
Re: Getting All the windows in an array
it works nicely. thanx a lot
Re: [RESOLVED] Getting All the windows in an array
No problem man ^^ glad to hear that!