+ Reply to Thread
Results 1 to 3 of 3

ZOrder of two forms

  1. #1
    OfficeHacker
    Guest

    ZOrder of two forms

    Here's the scenario:
    I have two forms to display on the screen: Form1 and Form2. The Form2 is
    displayed after the user clicks a button on Form1 (which is already
    displayed). Form2 is automatically displayed in front of Form1. Both forms
    are loaded modeless (you can't load a second form if the first is modal).

    Here's the problem:
    I need the capacity to change the ZOrder of the two forms without unloading
    either of them. That is I need to programmatically force Form1 to be in front
    of Form2, or alternatively Form2 in front of Form1.

    I have not been able to find a way to do this. The forms themselves to not
    have a ZOrder property. The only other way I can think of is via an API
    though I'm not sure which API function would solve this.

    Any ideas?

  2. #2
    NickHK
    Guest

    Re: ZOrder of two forms

    OfficeHacker,
    Have you looked into using .Move so they are both visible, or .Hide ?

    NickHK

    "OfficeHacker" <[email protected]> wrote in message
    news:[email protected]...
    > Here's the scenario:
    > I have two forms to display on the screen: Form1 and Form2. The Form2 is
    > displayed after the user clicks a button on Form1 (which is already
    > displayed). Form2 is automatically displayed in front of Form1. Both forms
    > are loaded modeless (you can't load a second form if the first is modal).
    >
    > Here's the problem:
    > I need the capacity to change the ZOrder of the two forms without

    unloading
    > either of them. That is I need to programmatically force Form1 to be in

    front
    > of Form2, or alternatively Form2 in front of Form1.
    >
    > I have not been able to find a way to do this. The forms themselves to not
    > have a ZOrder property. The only other way I can think of is via an API
    > though I'm not sure which API function would solve this.
    >
    > Any ideas?




  3. #3
    keepITcool
    Guest

    Re: ZOrder of two forms


    for form1 it's very important that you distinguish
    between the form' initialize event and the activate event.

    unless you're activate event clears or sets controls
    hiding the form does not affect control's values.
    and any data entered by the user should be preserved.

    hiding and showing form1 when form2 closes is needed
    to give it focus.


    in form1...
    Private Sub CommandButton1_Click()
    Me.Enabled=False
    UserForm2.Show vbModeless
    End Sub

    in form2...
    Private Sub UserForm_Terminate()
    With UserForm1
    .Enabled = True
    .StartUpPosition = 0
    .Hide
    .Show vbModeless
    End With
    End Sub




    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


    OfficeHacker wrote :

    > Here's the scenario:
    > I have two forms to display on the screen: Form1 and Form2. The Form2
    > is displayed after the user clicks a button on Form1 (which is
    > already displayed). Form2 is automatically displayed in front of
    > Form1. Both forms are loaded modeless (you can't load a second form
    > if the first is modal).
    >
    > Here's the problem:
    > I need the capacity to change the ZOrder of the two forms without
    > unloading either of them. That is I need to programmatically force
    > Form1 to be in front of Form2, or alternatively Form2 in front of
    > Form1.
    >
    > I have not been able to find a way to do this. The forms themselves
    > to not have a ZOrder property. The only other way I can think of is
    > via an API though I'm not sure which API function would solve this.
    >
    > Any ideas?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1