Jump to content

Activated window not being brought to front


T0M50N
 Share

Recommended Posts

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("WinWaitDelay", 0)

$MainForm = GUICreate("MainForm", 615, 438, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 248, 192, 97, 41)
GUISetState(@SW_SHOW)

$SubForm = GUICreate("SubForm", 395, 252, 192, 124)
WinSetOnTop($SubForm, "", 1)

While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]

    Case $MainForm

        Switch $nMsg[0]

            Case $Button1
                WinSetState($SubForm, "", @SW_SHOW)
                WinSetState($MainForm, "", @SW_DISABLE)

            Case $GUI_EVENT_CLOSE
                Exit

        EndSwitch

    Case $SubForm

        Switch $nMsg[0]

            Case $GUI_EVENT_CLOSE
                WinSetState($SubForm, "", @SW_HIDE)
                WinSetState($MainForm, "", @SW_ENABLE)
                WinActivate($MainForm)

        EndSwitch

    EndSwitch
WEnd

This is similar to the structure of my main script. The problem is that when you close the subform, focus is given to the main form but it isn't brought to the front. This issue doesn't occur in this script but does occur in my main script on the seemingly random occasion. This means I can't make it reproducible (At the moment it's working consistently).

When this bug occurs it keeps occurring for the rest of the session and when it occurs in that session it occurs more frequently when the two windows are in front of the SciTE window.

I just need some help as to what could be causing it so I can make it reproducible or find a possible work around.

Edited by T0M50N
Link to comment
Share on other sites

Hi,

It means there's something wrong in your script, you can still use a workaround which is to set the z-order pos to bring your window back to the front.

Take a look at _WinAPI_SetWindowPos in the helpfile (and its example).

Br, FireFox.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...