Loading window not closing and not staying on top of main window
I have a main window with one button, when i press that button it brings up a loading screen, but I have two problems with the loading screen at the moment:
1) Once I have pressed the button, if i open something else full screen over this autoit project (eg: chrome), then on my task bar click on the autoit project to bring it up to the front, the loading screen does not stay on top of the main window, I tried using $WS_EX_TOPMOST but this makes the loading screen stay on top of all windows, I only want it to stay on top of $Main (my main window GUI)
2) Once the loading screen has been updated to 100%, it should sleep for a further two seconds then close, but at the moment after that 2 seconds, it goes back down to 25% instead of $LoadingWindow being deleted.
Has anyone got any thoughts or suggestions?
$Main = GUICreate("Main Window", 600, 480, -1, -1, -1, $WS_EX_ACCEPTFILES)
Global $button_Load = GUICtrlCreateButton("Loading Screen", 484, 98, 89, 20, $WS_GROUP)
GUICtrlCreateTab(8, 16, 585, 424)
GUICtrlCreateGroup("Settings", 16, 50, 569, 380)
WinSetState($Main, "", @SW_DISABLE)
LoadingScreen("Loading @ 25%")
LoadingScreen("Loading @ 100%")
WinSetState($Main, "", @SW_ENABLE)
Func LoadingScreen($LoadingText) ;Creates a Splash Text Screen with a progress bar.
Global $LoadingWindow = GUICreate("", 500, 184, -1, -1, BitOR($WS_POPUP, $WS_BORDER), BitOR($WS_EX_WINDOWEDGE, $WS_EX_TOOLWINDOW))
Global $LoadingPercent = GUICtrlCreateProgress(18, 144, 461, 25, $PBS_SMOOTH)
GUICtrlCreateLabel($LoadingText, 2, 44, 494, 88, $SS_CENTER)
GUICtrlSetFont(-1, 15, 800, 0, "Calibra", $CLEARTYPE_QUALITY)
$nMsg = GUIGetMsg()