Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Child Window Order

Posted on 2000-04-27
6
Medium Priority
?
204 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 150 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

971 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