Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset cascade position of mdiChildren?

Status
Not open for further replies.

fenris

Programmer
May 20, 1999
824
CA
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top