Solved

Child Window Order

Posted on 2000-04-27
6
195 Views
Last Modified: 2008-03-06
I can save and restore child window size, position and state OK but how can I save the order of the windows? In other words how can I know that window B is on top of window A and window C is on the bottom?
0
Comment
Question by:Neal Hartman
  • 2
  • 2
  • 2
6 Comments
 

Expert Comment

by:scibberme
ID: 2756306
I believe that the windows are layered on top of each other one in the order that they are loaded. You could store the place that the window was loaded, such as 1st, 2nd etc.
0
 
LVL 1

Author Comment

by:Neal Hartman
ID: 2756374
I need to store the position when the app is ended.
0
 

Accepted Solution

by:
scibberme earned 50 total points
ID: 2756704
In that case, you would probably want to add code that would update the values the forms got as the get focus and are shuffled around. Giving focus to a form moves it to the top layer. You could treat this like it was freshly opened and give it the next highest value. When your program ends, take all of these values and store them with the rest of the window's attributes.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:Neal Hartman
ID: 2757005
I guess thats on way to do it. I thought there would be an API or something I could do with zorder.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2757044
Here is another way to do it.  In the QueryUnload event, look for the ActiveForm (the one with ZOrder 0).  Then unload that form, which will bring the next window into focus. Keep looping until all forms have been unloaded.

Option Explicit

Private Sub MDIForm_Load()
    Form1.Show
    Form2.Show
    Form3.Show
End Sub

Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Dim frm As Form
    Dim i As Long
    'Search the forms collection for the ActiveForm
    For i = 0 To Forms.Count - 1
        Set frm = Me.ActiveForm
        If Not frm Is Nothing Then
            'This is the current top form
            Debug.Print frm.Name
            Unload frm
            Set frm = Nothing
        End If
    Next
End Sub
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2757111
If your app is not MDI, you can use this:

Option Explicit

Private Sub Form_Load()
    Form2.Show
    Form3.Show
End Sub

'Your Startup (main) form code
Private Sub Form_Unload(Cancel As Integer)
    Dim frm As Form
    Dim i As Long
    'Search the forms collection for the ActiveForm
    For i = 0 To Forms.Count - 1
        Set frm = Screen.ActiveForm
        If Not frm Is Nothing Then
            Debug.Print frm.Name
            frm.Visible = False
        End If
    Next
    'Unload all forms
    For Each frm In Forms
        If Not frm Is Me Then
            Unload frm
            Set frm = Nothing
        End If
    Next
End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now