Jump to content

Recommended Posts

Posted (edited)

I have a button on my form that waits for 4 other fields to have data in them before it becomes active.

With the current code below the program worjs but the grayed out button flickers. Is there something I can can in the code to prevent this? Here is some snippits for how I have it now:

;more code above..shouldn't be needed for this post
$subgroup1a = GUICtrlCreateGroup("Password Change", 40, 104, 537, 161)
$LabelUsername = GUICtrlCreateLabel("Username:", 56, 139, 55, 17)
$LabelCurrentPwd = GUICtrlCreateLabel("Current Password:", 56, 171, 90, 17)
If $Cmdline[0] = 1 Then
    $UserString = GUICtrlCreateInput($CmdLine[1], 160, 136, 130, 21)
Else
    $UserString = GUICtrlCreateInput("", 160, 136, 130, 21)
Endif
$currentpassword = GUICtrlCreateInput("", 160, 168, 121, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$newpswdlabel = GUICtrlCreateLabel("New Password:", 56, 203, 78, 17)
$Labelconfirm = GUICtrlCreateLabel("Confirm Password:", 56, 235, 91, 17)
$newpassword = GUICtrlCreateInput("", 160, 200, 121, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$confimrpswd = GUICtrlCreateInput("", 160, 232, 121, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ChangeButton = GUICtrlCreateButton("&Change", 152, 274, 75, 25, 0)
GUICtrlSetState($ChangeButton, $GUI_DISABLE)
$CancelButton = GUICtrlCreateButton("C&ancel", 368, 274, 75, 25, 0)
GUISetState(@SW_SHOW)
    
While 1
$t_input = GUICtrlRead($UserString)
$t_input2 = GUICtrlRead($currentpassword)
$t_input3 = GUICtrlRead($newpassword)
$t_input4 = GUICtrlRead($confimrpswd)
    If StringLen($t_input) > 1 And StringLen($t_input2) > 1 And StringLen($t_input3) > 1 And  StringLen($t_input4) Then 
        _changebtnactive()
    Else
    GUICtrlSetState($ChangeButton, $GUI_DISABLE)
    EndIf
    
    $Msg = GUIGetMsg()
    
    Select

;etc, etc...More after this that isn't needed for this post...


Func _changebtnactive()
    
    GUICtrlSetState($ChangeButton, $GUI_ENABLE)
    GUICtrlSetState ($ChangeButton, $GUI_DEFBUTTON)
        
EndFunc

Thanks

Edited by Agent Orange
Posted

where exactly?

No sleep but you have to test the state before GUICtrlSetState otherwise the control is redrawn >> flicker

see code below

#include <GUIConstants.au3>
;~ #define PBT_APMQUERYSUSPEND           0x0000
;~ #define PBT_APMQUERYSTANDBY           0x0001
;~ #define PBT_APMQUERYSUSPENDFAILED       0x0002
;~ #define PBT_APMQUERYSTANDBYFAILED       0x0003
;~ #define PBT_APMSUSPEND                 0x0004
;~ #define PBT_APMSTANDBY                 0x0005
;~ #define PBT_APMRESUMECRITICAL           0x0006
;~ #define PBT_APMRESUMESUSPEND         0x0007
;~ #define PBT_APMRESUMESTANDBY         0x0008
;~ #define PBTF_APMRESUMEFROMFAILURE       0x00000001
;~ #define PBT_APMBATTERYLOW               0x0009
;~ #define PBT_APMPOWERSTATUSCHANGE     0x000A
;~ #define PBT_APMOEMEVENT               0x000B
;~ #define PBT_APMRESUMEAUTOMATIC         0x0012
;
Global $WM_POWERBROADCAST    = 536
Global $PBT_APMRESUMESUSPEND  =  0x0007
Global $SortieDeVeille=0

$hGUI      = GUICreate("Test", 800, 600,1,1)

;more code above..shouldn't be needed for this post
$subgroup1a = GUICtrlCreateGroup("Password Change", 40, 104, 537, 161)
$LabelUsername = GUICtrlCreateLabel("Username:", 56, 139, 55, 17)
$LabelCurrentPwd = GUICtrlCreateLabel("Current Password:", 56, 171, 90, 17)

If $Cmdline[0] = 1 Then
    $UserString = GUICtrlCreateInput($CmdLine[1], 160, 136, 130, 21)
Else
    $UserString = GUICtrlCreateInput("", 160, 136, 130, 21)
Endif
$currentpassword = GUICtrlCreateInput("", 160, 168, 121, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$newpswdlabel = GUICtrlCreateLabel("New Password:", 56, 203, 78, 17)
$Labelconfirm = GUICtrlCreateLabel("Confirm Password:", 56, 235, 91, 17)
$newpassword = GUICtrlCreateInput("", 160, 200, 121, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$confimrpswd = GUICtrlCreateInput("", 160, 232, 121, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ChangeButton = GUICtrlCreateButton("&Change", 152, 274, 75, 25, 0)
GUICtrlSetState($ChangeButton, $GUI_DISABLE)
$CancelButton = GUICtrlCreateButton("C&ancel", 368, 274, 75, 25, 0)
GUISetState(@SW_SHOW)
   
While 1
$t_input = GUICtrlRead($UserString)
$t_input2 = GUICtrlRead($currentpassword)
$t_input3 = GUICtrlRead($newpassword)
$t_input4 = GUICtrlRead($confimrpswd)
    If StringLen($t_input) > 1 And StringLen($t_input2) > 1 And StringLen($t_input3) > 1 And  StringLen($t_input4)>1 Then
        _changebtnactive()
    Else
        if BitAND(GUICtrlGetState($ChangeButton), $GUI_ENABLE)<>0 then 
            GUICtrlSetState($ChangeButton, $GUI_DISABLE)
        EndIf
    EndIf
   
    $GUIMsg = GUIGetMsg()
    Switch $GUIMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
;
Exit
;
;etc, etc...More after this that isn't needed for this post...


Func _changebtnactive()
   if bitand(guictrlgetstate($ChangeButton),$GUI_enABLE)=0 then 
        GUICtrlSetState($ChangeButton, $GUI_ENABLE)
        GUICtrlSetState ($ChangeButton, $GUI_DEFBUTTON)
    EndIf
EndFunc

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