Jump to content

Loading window not closing and not staying on top of main window


Recommended Posts

Hi,

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?

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <FontConstants.au3>

$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)
GUICtrlCreateTabItem("Settings")
GUICtrlCreateGroup("Settings", 16, 50, 569, 380)

GUISetState(@SW_SHOWNORMAL)

Func Load()
    WinSetState($Main, "", @SW_DISABLE)

    LoadingScreen("Loading @ 25%")
    GUICtrlSetData($LoadingPercent, 25)
    
    sleep(2000)
    
    LoadingScreen("Loading @ 100%")
    GUICtrlSetData($LoadingPercent, 100)
    
    sleep(2000)
    
    GUIDelete($LoadingWindow)
    WinSetState($Main, "", @SW_ENABLE)
    
EndFunc

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)
    GUISetState(@SW_SHOW)
EndFunc 

While (1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_Load
            Load()
    EndSwitch
WEnd

 

Link to comment
Share on other sites

First Problem Fix;

Global $LoadingWindow = GUICreate("", 500, 184, -1, -1, BitOR($WS_POPUP, $WS_BORDER), BitOR($WS_EX_WINDOWEDGE, $WS_EX_TOOLWINDOW),$Main)

Second Problem;

Is because your generating two loading screen GUIS and only deleting one.

Code with both problems fixed.

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <FontConstants.au3>

Global $LoadingWindow
$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)
GUICtrlCreateTabItem("Settings")
GUICtrlCreateGroup("Settings", 16, 50, 569, 380)

GUISetState(@SW_SHOWNORMAL)

Func Load()
    $GUI = LoadingScreen("Loading @ 25%")
    GUICtrlSetData($LoadingPercent, 25)

    sleep(1000)

    GUICtrlSetData($LoadingLabelText, "Loading @ 100%")
    GUICtrlSetData($LoadingPercent, 100)

    sleep(1000)

   GUIDelete($LoadingWindow)
EndFunc

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),$Main)
    Global $LoadingPercent = GUICtrlCreateProgress(18, 144, 461, 25, $PBS_SMOOTH)
    Global $LoadingLabelText = GUICtrlCreateLabel($LoadingText, 2, 44, 494, 88, $SS_CENTER)
    GUICtrlSetFont(-1, 15, 800, 0, "Calibra", $CLEARTYPE_QUALITY)
    GUISetState(@SW_SHOW)

EndFunc

While (1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_Load
            Load()
    EndSwitch
WEnd

 

Edited by IanN1990
Link to comment
Share on other sites

41 minutes ago, cookiemonster said:

Hi,

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?

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <FontConstants.au3>

$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)
GUICtrlCreateTabItem("Settings")
GUICtrlCreateGroup("Settings", 16, 50, 569, 380)

GUISetState(@SW_SHOWNORMAL)

Func Load()
    WinSetState($Main, "", @SW_DISABLE)

    LoadingScreen("Loading @ 25%")
    GUICtrlSetData($LoadingPercent, 25)
    
    sleep(2000)
    
    LoadingScreen("Loading @ 100%")
    GUICtrlSetData($LoadingPercent, 100)
    
    sleep(2000)
    
    GUIDelete($LoadingWindow)
    WinSetState($Main, "", @SW_ENABLE)
    
EndFunc

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)
    GUISetState(@SW_SHOW)
EndFunc 

While (1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_Load
            Load()
    EndSwitch
WEnd

 

Thats great thanks, can see where I went wrong with both bits now, thanks!

Link to comment
Share on other sites

I forgot your disabled / enabled bit. Here is with it added in and a small loop for the percentage. Good luck on your project.

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <FontConstants.au3>

Global $LoadingWindow
$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)
GUICtrlCreateTabItem("Settings")
GUICtrlCreateGroup("Settings", 16, 50, 569, 380)

GUISetState(@SW_SHOWNORMAL)

Func Load()
   GUISetState(@sw_Disable, $Main)

   $GUI = LoadingScreen("Loading @ 0%")
   sleep(250)

   For $I = 25 to 100 step 25
      GUICtrlSetData($LoadingLabelText, "Loading @ " & $I & "%")
      GUICtrlSetData($LoadingPercent, $I)
      sleep(1000)
   Next

   GUISetState(@SW_ENABLE, $Main)
   GUIDelete($LoadingWindow)
EndFunc

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),$Main)
    Global $LoadingPercent = GUICtrlCreateProgress(18, 144, 461, 25, $PBS_SMOOTH)
    Global $LoadingLabelText = GUICtrlCreateLabel($LoadingText, 2, 44, 494, 88, $SS_CENTER)
    GUICtrlSetFont(-1, 15, 800, 0, "Calibra", $CLEARTYPE_QUALITY)
    GUISetState(@SW_SHOW)

EndFunc

While (1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_Load
            Load()
    EndSwitch
WEnd

 

Edited by IanN1990
Link to comment
Share on other sites

12 minutes ago, IanN1990 said:

I forgot your disabled / enabled bit. Here is with it added in and a small loop for the percentage. Good luck on your project.

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <FontConstants.au3>

Global $LoadingWindow
$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)
GUICtrlCreateTabItem("Settings")
GUICtrlCreateGroup("Settings", 16, 50, 569, 380)

GUISetState(@SW_SHOWNORMAL)

Func Load()
   GUISetState(@sw_Disable, $Main)

   $GUI = LoadingScreen("Loading @ 0%")
   sleep(250)

   For $I = 25 to 100 step 25
      GUICtrlSetData($LoadingLabelText, "Loading @ " & $I & "%")
      GUICtrlSetData($LoadingPercent, $I)
      sleep(1000)
   Next

   GUISetState(@SW_ENABLE, $Main)
   GUIDelete($LoadingWindow)
EndFunc

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),$Main)
    Global $LoadingPercent = GUICtrlCreateProgress(18, 144, 461, 25, $PBS_SMOOTH)
    Global $LoadingLabelText = GUICtrlCreateLabel($LoadingText, 2, 44, 494, 88, $SS_CENTER)
    GUICtrlSetFont(-1, 15, 800, 0, "Calibra", $CLEARTYPE_QUALITY)
    GUISetState(@SW_SHOW)

EndFunc

While (1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_Load
            Load()
    EndSwitch
WEnd

 

I added that bit back in :)

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

×
×
  • Create New...