|
-
Mar 21st, 2003, 12:35 AM
#1
Thread Starter
Hyperactive Member
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?
-
Mar 21st, 2003, 12:40 AM
#2
Frenzied Member
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
-
Mar 21st, 2003, 12:46 AM
#3
Thread Starter
Hyperactive Member
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.
-
Mar 21st, 2003, 12:55 AM
#4
Frenzied Member
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
-
Mar 21st, 2003, 01:02 AM
#5
Frenzied Member
VB Code:
Public Function SetPropertyOfControl(frmNew As Form) As Boolean
On Error GoTo ErrHandler
With frmNew.Text1
.Text = "Default Text in the Text Box"
.Left = frmNew.ScaleLeft + 50
.Top = frmNew.ScaleTop + 50
.MaxLength = 255
.ToolTipText = "This is an example"
End With
SetPropertyOfControl = True
Exit Function
ErrHandler:
MsgBox "Handle Errors Here"
End Function
Private Sub Command1_Click()
Dim obj As Form
Set obj = New Form1
Load obj
SetPropertyOfControl obj
obj.Show
End Sub
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Mar 21st, 2003, 01:03 AM
#6
Thread Starter
Hyperactive Member
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....
-
Mar 21st, 2003, 01:06 AM
#7
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|