Jump to content
AlienStar

minimize disabled GUI ?

Recommended Posts

Posted (edited)
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

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


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 

Share this post


Link to post
Share on other sites

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.

Share this post


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 

Share this post


Link to post
Share on other sites

It is easier to make that loop than trying to simulate a border click to minimize the GUI.  Just create a Func and pass the state (@SW_ENABLE/@SW_DISABLE) as a parameter.  

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...