Jump to content

minimize disabled GUI ?


Recommended Posts

16 hours ago, TheXman said:

Is this some sort of trick question?    :think:

What happens when you use @SW_MINIMIZE?

there are operations with a progress bar in my script and they take a while  to finish.

and I need to disable the GUI to prevent re-click on the buttons

so until the operation finishes I may need to minimize the script to do something else .

here is an example explain more

#include <GUIConstantsEx.au3>
#include <Array.au3>

; Create a GUI with various controls.
Local $hGUI = GUICreate("Test")
Local $idsubmit = GUICtrlCreateButton("Submit", 20, 50, 85, 25)
Local $idfltr = GUICtrlCreateButton("Filter", 20, 100, 85, 25)
Local $iddel = GUICtrlCreateButton("Delete", 20, 150, 85, 25)

Local $array[10]

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
            ;=======================
        Case $idsubmit
            GUISetState(@SW_DISABLE, $hGUI)
            $size = UBound($array) - 1
            ProgressOn("Progress", "in pending", "0%", -1, -1)
            For $i = 0 To $size
                ;-------------
                $ip = (100 / UBound($array)) * $i
                ProgressSet($ip, Round($ip, 0) & "% - " & $i & "/" & UBound($array))
                ;-------------
                $array[$i] = $i + 2 * $i
                Sleep(500)
            Next
            ;-------------
            ProgressOff()
            _ArrayDisplay($array)
            GUISetState(@SW_ENABLE, $hGUI)
            ;=======================
    EndSwitch
WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

 

Edited by AlienStar
Link to post
Share on other sites

Maybe this ?

#include <GUIConstants.au3>
#include <Array.au3>

; Create a GUI with various controls.
Local $hGUI = GUICreate("Test")
Local $idsubmit = GUICtrlCreateButton("Submit", 20, 50, 85, 25)
Local $idfltr = GUICtrlCreateButton("Filter", 20, 100, 85, 25)
Local $iddel = GUICtrlCreateButton("Delete", 20, 150, 85, 25)

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)

; Loop until the user exits.
While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
      ;=======================
    Case $idsubmit
      GUISetState(@SW_MINIMIZE, $hGUI)
      GUISetState(@SW_DISABLE, $hGUI)
      ShowProgress()
      GUISetState(@SW_ENABLE, $hGUI)
      GUISetState(@SW_RESTORE, $hGUI)
      ;=======================
  EndSwitch
WEnd

Func ShowProgress()
  Local $array[10]
  Local $size = UBound($array) - 1
  ProgressOn("Progress", "in pending", "0%", -1, -1, $DLG_MOVEABLE)
  For $i = 0 To $size
    $ip = (100 / UBound($array)) * $i
    ProgressSet($ip, Round($ip, 0) & "% - " & $i & "/" & UBound($array))
    $array[$i] = $i + 2 * $i
    Sleep(500)
  Next
  ProgressOff()
  _ArrayDisplay($array)
EndFunc   ;==>ShowProgress

 

Edited by Nine
Link to post
Share on other sites
3 minutes ago, Nine said:

Maybe this ?

#include <GUIConstants.au3>
#include <Array.au3>

; Create a GUI with various controls.
Local $hGUI = GUICreate("Test")
Local $idsubmit = GUICtrlCreateButton("Submit", 20, 50, 85, 25)
Local $idfltr = GUICtrlCreateButton("Filter", 20, 100, 85, 25)
Local $iddel = GUICtrlCreateButton("Delete", 20, 150, 85, 25)

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)

; Loop until the user exits.
While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
      ;=======================
    Case $idsubmit
      GUISetState(@SW_MINIMIZE, $hGUI)
      GUISetState(@SW_DISABLE, $hGUI)
      ShowProgress()
      GUISetState(@SW_ENABLE, $hGUI)
      GUISetState(@SW_RESTORE, $hGUI)
      ;=======================
  EndSwitch
WEnd

Func ShowProgress()
  Local $array[10]
  Local $size = UBound($array) - 1
  GUISetState()
  ProgressOn("Progress", "in pending", "0%", -1, -1, $DLG_MOVEABLE)
  For $i = 0 To $size
    $ip = (100 / UBound($array)) * $i
    ProgressSet($ip, Round($ip, 0) & "% - " & $i & "/" & UBound($array))
    $array[$i] = $i + 2 * $i
    Sleep(500)
  Next
  ProgressOff()
  _ArrayDisplay($array)
EndFunc   ;==>ShowProgress

 

thanks my friend but I don't wanna minimize at first 

because maybe I don't need to do.

all what I need is the ability to minimize (or move) gui after disabling 

Link to post
Share on other sites
5 minutes ago, Nine said:

Instead of disabling the whole GUI, why don't you simply disable the controls that you do not want the user to press while in progress.  That would solve your issue.

This idea crossed my mind but I have about 20 controls so I need to make a loop to disable them then enable each time 

That's why I've asked this question

if I don't reach an answer I'll make that loop :) 

thanks my friend 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...