I am having a problem with mdi forms. I have an mdiform with a number of mdiChildren. I can open up a large number of these children and they open according to a cascading pattern, which is fine. When I close all the mdiChildren, and open up a new mdiChild form, it appears in the next cascade. I have tried to put some code in the child's load event, similar to this:
if Forms.count = 2 then '2 - 1 form the mdiForm and 1 for the newly opened child
mdiMain.arrange vbcascade 'mdiMain is the mdiForm object
endif
But the above code doesn't work unless the child is visible.
Is there a way to reset the way windows cascades the child forms, i.e. tell windows to start the cascade at position 0.
I also tried this:
Public Sub cascadeMe(f As Form)
Dim formCount As Long 'holds the number of forms
Dim leftOffset As Long 'the amount to offset the forms to the left
Dim topOffset As Long 'the amount to offset the forms from the top
Dim topLimit As Long 'the number of twips down the window before it wraps to the top again
Dim leftStart As Long 'the left starting position
Dim topStart As Long 'the top starting position
formCount = Forms.Count - 2 'subtract one as this form doesn't count and another one as the mdiMain doesn't count either
leftOffset = 400
topOffset = 400
topLimit = mdiMain.ScaleHeight \ 3
leftStart = leftOffset * formCount
topStart = topOffset * formCount
If topStart < topLimit Then
f.Left = leftStart
f.Top = topStart
Else
f.Left = 0
f.Top = 0
End If
This seems to work until it wraps to the top again....
Any ideas, or suggestions are welcome....
Troy Williams B.Eng.
fenris@hotmail.com
if Forms.count = 2 then '2 - 1 form the mdiForm and 1 for the newly opened child
mdiMain.arrange vbcascade 'mdiMain is the mdiForm object
endif
But the above code doesn't work unless the child is visible.
Is there a way to reset the way windows cascades the child forms, i.e. tell windows to start the cascade at position 0.
I also tried this:
Public Sub cascadeMe(f As Form)
Dim formCount As Long 'holds the number of forms
Dim leftOffset As Long 'the amount to offset the forms to the left
Dim topOffset As Long 'the amount to offset the forms from the top
Dim topLimit As Long 'the number of twips down the window before it wraps to the top again
Dim leftStart As Long 'the left starting position
Dim topStart As Long 'the top starting position
formCount = Forms.Count - 2 'subtract one as this form doesn't count and another one as the mdiMain doesn't count either
leftOffset = 400
topOffset = 400
topLimit = mdiMain.ScaleHeight \ 3
leftStart = leftOffset * formCount
topStart = topOffset * formCount
If topStart < topLimit Then
f.Left = leftStart
f.Top = topStart
Else
f.Left = 0
f.Top = 0
End If
This seems to work until it wraps to the top again....
Any ideas, or suggestions are welcome....
Troy Williams B.Eng.
fenris@hotmail.com