Jump to content

Prevent window being closed


 Share

Recommended Posts

Hi guys, I use a progress bar popup when deploying applications to users machines but I want to prevent the window being closed. It's just an indicator letting the user know that the installation is still going and terminates once it's finished, however some users are closing the window and have no idea the app is still installing in the background.

Any help would be appreciated. The code I'm using it below.

#include <GUIConstants.au3>
Global Const $PBS_MARQUEE = 0x08
Global Const $WM_USER = 0x0400
Global Const $PBM_SETMARQUEE = ($WM_USER+10)
Global $status = 1
$labeltext = "Installing, please wait..."
Opt("GUIOnEventMode", 1)
$GUI = GUICreate("Progress", 400, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CLOSE")
GUISetFont(10) ;sets the font size
$Label = GUICtrlCreateLabel($labeltext, 10, 45, 330, 50) ;left, top, width, height
$GUI_Progress = GUICtrlCreateProgress(10, 15, 380, 20, $PBS_MARQUEE)
GUICtrlSendMsg($GUI_Progress, $PBM_SETMARQUEE, 1, 200)
;$GUI_Button = GUICtrlCreateButton("Start/Stop", 70, 50)
GUICtrlSetOnEvent(-1, "Progress_Stop_Start")
GUISetState()
While 1
Sleep(100)
WEnd
Func Progress_Stop_Start()
If $status Then
     GUICtrlSendMsg($GUI_Progress, $PBM_SETMARQUEE, 0, 200)
     $status = 0
Else
     GUICtrlSendMsg($GUI_Progress, $PBM_SETMARQUEE, 1, 200)
     $status = 1
EndIf
EndFunc
Func GUI_CLOSE()
Exit
EndFunc
Link to comment
Share on other sites

remove the X and add a button instead, the code below removes all.

play a little with the parameters

Disable the button and when finished Enable the button

$flg = BitOR($GUI_SS_DEFAULT_GUI, $WS_DLGFRAME, $DS_MODALFRAME, $DS_SETFOREGROUND, $WS_CAPTION, $WS_SYSMENU, $WS_POPUP)

$flg = BitAND($flg, Not $WS_MAXIMIZEBOX, Not $WS_MINIMIZEBOX)

$GUI = GUICreate("Progress", 400, 100, -1, -1, $flg)

Edited by Emiel Wieldraaijer

Best regards,Emiel Wieldraaijer

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...