Jump to content

any way to force a window into the foreground ?


Krass
 Share

Recommended Posts

hi ;)

how can I force the mainwindow back to the foreground after closing request windows ?

I found this .. uhm.. bug (?) ... with the funktion "FileOpenDialog" - after using this funktion (and closing it) my mainwindow is behind every other window on the screen..... same thing happend with msgbox.

I tried GUISwitch($MainWindow) and GUISetState(@SW_SHOW) - nothing happends.

I also tried it with the compiled .exe file - same here

can anyone help me pls ?

my versions:

SciTE4AutoIt3 8/30/2005

AutoIt v3.1.1 7/4/2005

here is a small example with a MsgBox:

#include <GuiConstants.au3>

Opt("GUIOnEventMode", 1)
$MainWindow = GuiCreate("Test", 200, 200, 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitMacro")

GUICtrlCreateButton("MSG", 30, 30, 80, 20)
GUICtrlSetOnEvent(-1, "ShowInfo")


;----------------------------
GuiSetState()
While 1
   $msg = GuiGetMsg()
   Select
   Case $msg = $GUI_EVENT_CLOSE
      ExitLoop
   Case Else
     
   EndSelect
WEnd
Exit
;----------------------------

func ExitMacro()
    Exit
endfunc

func ShowInfo()
    GuiSetState(@SW_DISABLE ,$MainWindow)
    MsgBox(1,"Question","Why is the main into the backgroud when this box is closed ?")
    GuiSetState(@SW_ENABLE ,$MainWindow)

    GUISwitch($MainWindow);hmmm
    GUISetState(@SW_SHOW);hmmmmmmm
EndFunc
Link to comment
Share on other sites

Try this code and see if it works better for you:

#include <GuiConstants.au3>

$MainWindow = GuiCreate("Test", 200, 200, 200, 200)
$MainButton = GUICtrlCreateButton ("MSG", 30, 30, 80, 20)

GuiSetState ()
While 1
   $msg = GuiGetMsg ()
      Select
         Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
         Case $msg = $MainButton
            GUISetState (@SW_Hide, $MainWindow)
            MsgBox(1,"Question","Why is the main into the backgroud when this box is closed ?")
            GUISetState (@SW_SHOW, $MainWindow)
         Case Else
      EndSelect
WEnd
Exit
Link to comment
Share on other sites

@JoshDB thanks a lot ! I didn't saw (ignored) the WinXXX command (/slap myself)

it's so easy ;) thx again

*edit:* WinActivate ("Test") at the end of the function ShowInfo worked

@SerialKiller also thanks, you gave me a nice idea !

well it's funny but I could use both solutions in my macro

Edited by Krass
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...