Results 1 to 5 of 5

Thread: MDI form

  1. #1

    Thread Starter
    Addicted Member samkud's Avatar
    Join Date
    Oct 2001
    Location
    India
    Posts
    171

    MDI form

    Hi everybody,

    I want to create an application where I want to use a MDI form. As in any windows application i want to add the NEW command to the menu, using which i can create a new documnet. What I want to do is create a prototype of the child form and to create an instance of the prototype whenever i click on the NEW command. How can this be achieved? I have read that u can create a form which can act as prototype and declare an array of that prototype. BUt i don't want to limit myself to the ubound of the array declared. I want to let the user create as many instances as he/she wants.


    Please can anyone help me.

    Regards

    Samir

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    you can use a dynamic array.

    this is an array where you don't specify the dimensions when you declare it, you can then change the no of dimensions and the upperbound etc during runtime. Theres plently of info on them in MSDN.

    However you could also consider using a collection rather than array since you will be storing objects...

    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    Hmm, you dont neccesarily need an array or a collection.. Remember that th form will be added to the generic forms collection, and child collections...

    Create the template form (EG frmDoc)


    ' Behind the new menu item...

    Dim oNewFrmDoc as frmDoc

    Set oNewFrmDoc = new frmDoc

    oNewFrmDoc.Show

    ' Dispose of our refrence to the form.
    Set oNewFrmDoc = Nothing
    Leather Face is comin...


    MCSD

  4. #4

    Thread Starter
    Addicted Member samkud's Avatar
    Join Date
    Oct 2001
    Location
    India
    Posts
    171

    Hi Darre1

    HI,

    Thanx for ur reply darre1.

    Can u please elabordate on COLLECTIONS. What is a collection where do we use it. I am very new to this field so ur advice will be a great help to me. And if possible can u please give me ur email id so that i can mail u when i need ur help.


    Thanx.


    Regards

    Samir

  5. #5
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    collections are dead easy to use.

    here's an example...

    VB Code:
    1. Dim colForms As Collection
    2.  
    3. Private Sub Form_Activate()
    4.     Dim f As Form
    5.     Dim f2 As Form
    6.     Dim i As Long
    7.    
    8.     'setup objects to go into collection
    9.     Set f = New Form1
    10.     f.Tag = "abc"
    11.     Set f2 = New Form1
    12.     f2.Tag = "xyz"
    13.    
    14.     'create new collection
    15.     Set colForms = New Collection
    16.    
    17.     'add forms to collection
    18.     colForms.Add f
    19.     colForms.Add f2
    20.    
    21.     'read data from objects in collection
    22.     For i = 1 To colForms.Count
    23.         MsgBox colForms(i).Tag
    24.     Next i
    25.  
    26.     'remove objects from collection
    27.     For i = 1 To colForms.Count
    28.         colForms.Remove (1)
    29.     Next i
    30.  
    31.     MsgBox "there are now " & colForms.Count & " items in colForms"
    32.  
    33. End Sub

    like the above post said though, you're forms will all be accesible through the global Forms collection anyway, but you can have your own if you wish, and then you can add and remove whatever you want.
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width