Solved

Child Window Order

Posted on 2000-04-27
6
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

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.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses
Course of the Month7 days, 11 hours left to enroll

632 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