Results 1 to 7 of 7

Thread: MDI and children - chicken or egg?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406

    MDI and children - chicken or egg?

    I've got an MDI app in which has one mdichild form (basicFrm) containing a control.

    The control has 10 parameters that I can set.

    In a module I declare:
    Public newForm() As New basicFrm

    When I create instances of newform (by using Redim) I want them to have the control with the params already set.

    My problem is that the Declaration on the Module occurs before I can set the params on the control contained in basicFrm.

    So I end up having to set the params each time I create a "newform".

    How can I fix this?

  2. #2
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Set the 10 properties of the control in BasicFrm at design time. Creating a new instance of a form at run-time will copy all the code/controls/properties set at design time.


    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    I can't set the properties at design time.

    I'm reading them from an ini file.

    That's the problem - once my code comes up, it's too late 'cause the Module has already created "newform" and instanced basicFrm.

  4. #4
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Thought so

    Have a function that does the setting of properties and call that function just after creating the new form.

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  5. #5
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    VB Code:
    1. Public Function SetPropertyOfControl(frmNew As Form) As Boolean
    2. On Error GoTo ErrHandler
    3.     With frmNew.Text1
    4.         .Text = "Default Text in the Text Box"
    5.         .Left = frmNew.ScaleLeft + 50
    6.         .Top = frmNew.ScaleTop + 50
    7.         .MaxLength = 255
    8.         .ToolTipText = "This is an example"
    9.     End With
    10.     SetPropertyOfControl = True
    11.     Exit Function
    12. ErrHandler:
    13. MsgBox "Handle Errors Here"
    14. End Function
    15. Private Sub Command1_Click()
    16. Dim obj As Form
    17. Set obj = New Form1
    18. Load obj
    19.     SetPropertyOfControl obj
    20. obj.Show
    21.  
    22. End Sub

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    That's what I do now.

    I'm trying to eliminate that code.

    If I can set the properties on the control, THEN Declare the "newform()", I'd be fine.

    Of course, I can't do that 'cause "newform" has to be Public and that can only happen in a Module, which loads before the "newform()" declaration....and around I go....

  7. #7
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Originally posted by wayneh

    ......
    If I can set the properties on the control, THEN Declare the "newform()", I'd be fine.
    ...
    Not possible, as there is no way to set the props of a control whose container is not already created.


    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

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