Sign in to follow this  
Followers 0
Krass

any way to force a window into the foreground ?

4 posts in this topic

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

Share this post


Link to post
Share on other sites



Have you tried WinActivate or WinSetOnTop?


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@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

Share this post


Link to post
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
Sign in to follow this  
Followers 0