Agent Orange Posted October 5, 2006 Posted October 5, 2006 (edited) Can you Hide a label field in a GUI? I'm trying with the below command and it doesn't hide the label... $labelerror = GUICtrlCreateLabel("Passwords not the same. Please reenter", 279, 235) GUICtrlSetState($labelerror, $GUI_HIDE) Thanks Edited October 5, 2006 by Agent Orange
Helge Posted October 5, 2006 Posted October 5, 2006 (edited) Well, this works on my compy.#include <GUIConstants.au3> GUICreate("", 300, 300) $labelerror = GUICtrlCreateLabel("Passwords not the same. Please reenter", 10, 10, 280, 20) GUISetState() Sleep(2000) GUICtrlSetState($labelerror, $GUI_HIDE) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Edited October 5, 2006 by Helge
Agent Orange Posted October 5, 2006 Author Posted October 5, 2006 (edited) Thanks Helge...I though it should work as well. Here is a chunk of the code...can you see what I'm missing? When I run it the $labelerror field shows right away and it shouldn't unless the person types in no matching password in the $newpassword and $confimrpswd boxes. expandcollapse popup$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)) $Shieldpic = GUICtrlCreatePic("C:\WINDOWS\ntimage.gif", 392, 129, 156, 116, BitOR($SS_NOTIFY,$WS_GROUP)) GUICtrlSetState(-1, $GUI_ENABLE) $labelerror = GUICtrlCreateLabel("Passwords not the same. Please reenter", 279, 235) ;GUICtrlCreateGroup("", -99, -99, 1, 1) $ChangeButton = GUICtrlCreateButton("&Change", 152, 274, 75, 25, 0) GUICtrlSetState($ChangeButton, $GUI_DISABLE) $CancelButton = GUICtrlCreateButton("C&ancel", 368, 274, 75, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $MenuItemFile = GUICtrlCreateMenu("&File") $SubMenuItemExit = GUICtrlCreateMenuItem("Exit", $MenuItemFile) $MenuItemInfo = GUICtrlCreateMenu("&Info") $SubMenuItemAbout = GUICtrlCreateMenuItem("About", $MenuItemInfo) GUISetState(@SW_SHOW) GUICtrlSetState($labelerror, $GUI_HIDE) #EndRegion ### END Main GUI section ### 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) And $t_input3 = $t_input4 Then _changebtnactive() Else If BitAND(GUICtrlGetState($ChangeButton), $GUI_ENABLE)<>0 Then GUICtrlSetState($ChangeButton, $GUI_DISABLE) EndIf EndIf If $t_input3 <> $t_input4 Then If bitand(guictrlgetstate($labelerror),$GUI_HIDE)=0 Then GUICtrlSetState($labelerror, $GUI_SHOW) EndIf EndIf Edited October 5, 2006 by Agent Orange
Moderators SmOke_N Posted October 5, 2006 Moderators Posted October 5, 2006 There is no problem with the snippet you provided#include <guiconstants.au3> GUICreate('',600) $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)) $Shieldpic = GUICtrlCreatePic("C:\WINDOWS\ntimage.gif", 392, 129, 156, 116, BitOR($SS_NOTIFY,$WS_GROUP)) $labelerror = GUICtrlCreateLabel("Passwords not the same. Please reenter", 279, 235) GUICtrlSetState(-1, $GUI_ENABLE) ;GUICtrlCreateGroup("", -99, -99, 1, 1) $ChangeButton = GUICtrlCreateButton("&Change", 152, 274, 75, 25, 0) GUICtrlSetState($ChangeButton, $GUI_DISABLE) $CancelButton = GUICtrlCreateButton("C&ancel", 368, 274, 75, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $MenuItemFile = GUICtrlCreateMenu("&File") $SubMenuItemExit = GUICtrlCreateMenuItem("Exit", $MenuItemFile) $MenuItemInfo = GUICtrlCreateMenu("&Info") $SubMenuItemAbout = GUICtrlCreateMenuItem("About", $MenuItemInfo) GUISetState(@SW_SHOW) GUICtrlSetState($labelerror, $GUI_HIDE) While GUIGetMsg() <> - 3 WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Agent Orange Posted October 6, 2006 Author Posted October 6, 2006 Ok...I'm still having an issue with this blasted label field to show and hide properly. It flashed quickly and sometimes even if the character count is correct it will display the text when it should hide it. Here is what I'm trying to accomplish.... I want the $labelerror to be hidden when the program starts. As the user types in the new password box ($newpassword) the label should become visible. The user will then move down to the comfirm password box and retype that password. If the two password inputs match the $labelerror hides again and the $ChangeButton becomes enabled and default button. Any help would be great. Here is the current code: expandcollapse popup;some code above but ncessary for this post $PWDForm = GUICreate("pswd change", 634, 353, 193, 115) $Group1 = GUICtrlCreateGroup("Description", 16, 16, 601, 297) $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 GUICtrlSetState($ChangeButton, $GUI_DISABLE) $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)) $Shieldpic = GUICtrlCreatePic("C:\WINDOWS\ntimage.gif", 392, 129, 156, 116, BitOR($SS_NOTIFY,$WS_GROUP)) GUICtrlSetState(-1, $GUI_ENABLE) $labelerror = GUICtrlCreateLabel("Passwords not the same. Please reenter", 279, 235) GUICtrlSetState($labelerror, $GUI_HIDE) ;GUICtrlCreateGroup("", -99, -99, 1, 1) $ChangeButton = GUICtrlCreateButton("&Change", 152, 274, 75, 25, 0) GUICtrlSetState($ChangeButton, $GUI_DISABLE) $CancelButton = GUICtrlCreateButton("C&ancel", 368, 274, 75, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $MenuItemFile = GUICtrlCreateMenu("&File") $SubMenuItemExit = GUICtrlCreateMenuItem("Exit", $MenuItemFile) $MenuItemInfo = GUICtrlCreateMenu("&Info") $SubMenuItemAbout = GUICtrlCreateMenuItem("About", $MenuItemInfo) GUICtrlSetState($labelerror, $GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Main GUI section ### 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) And $t_input3 = $t_input4 Then _changebtnactive() EndIf If $t_input3 <> $t_input4 Then If BitAND(GUICtrlGetState($labelerror),$GUI_HIDE)=0 Then GUICtrlSetState($labelerror, $GUI_SHOW) Else If BitAND(GUICtrlGetState($labelerror),$GUI_HIDE)<> 0 Then GUICtrlSetState($labelerror, $GUI_HIDE) EndIf EndIf EndIf Func _changebtnactive() If BitAND(GUICtrlSetState($ChangeButton),$GUI_ENABLE)=0 Then GUICtrlSetState($ChangeButton, $GUI_ENABLE) GUICtrlSetState ($ChangeButton, $GUI_DEFBUTTON) Else If BitAND(GUICtrlGetState($ChangeButton), $GUI_ENABLE)<>0 Then GUICtrlSetState($ChangeButton, $GUI_DISABLE) EndIf EndIf If BitAND(GUICtrlSetState($labelerror),$GUI_HIDE)=0 Then GUICtrlSetState($labelerror, $GUI_HIDE) Else If BitAND(GUICtrlGetState($labelerror),$GUI_HIDE)<>0 Then GUICtrlSetState($labelerror, $GUI_SHOW) EndIf EndIf EndFunc Thanks!
GaryFrost Posted October 6, 2006 Posted October 6, 2006 (edited) expandcollapse popup#include <GuiConstants.au3> Global Const $WM_COMMAND = 0x0111 Global Const $EN_CHANGE = 0x300 Global Const $DebugIt = 1 ;some code above but ncessary for this post $PWDForm = GUICreate("pswd change", 634, 353, 193, 115) $Group1 = GUICtrlCreateGroup("Description", 16, 16, 601, 297) $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)) $Shieldpic = GUICtrlCreatePic("C:\WINDOWS\ntimage.gif", 392, 129, 156, 116, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetState(-1, $GUI_ENABLE) $labelerror = GUICtrlCreateLabel("Passwords not the same. Please reenter", 279, 235) GUICtrlSetState($labelerror, $GUI_HIDE) ;GUICtrlCreateGroup("", -99, -99, 1, 1) $ChangeButton = GUICtrlCreateButton("&Change", 152, 274, 75, 25, 0) GUICtrlSetState($ChangeButton, $GUI_DISABLE) $CancelButton = GUICtrlCreateButton("C&ancel", 368, 274, 75, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $MenuItemFile = GUICtrlCreateMenu("&File") $SubMenuItemExit = GUICtrlCreateMenuitem("Exit", $MenuItemFile) $MenuItemInfo = GUICtrlCreateMenu("&Info") $SubMenuItemAbout = GUICtrlCreateMenuitem("About", $MenuItemInfo) GUICtrlSetState($labelerror, $GUI_HIDE) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") #EndRegion ### END Main GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $CancelButton Exit Case $msg = $ChangeButton EndSelect WEnd Func _Input_Changed() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("_Input_Changed") ;---------------------------------------------------------------------------------------------- $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 And ($t_input3 == $t_input4) Then GUICtrlSetState($ChangeButton, $GUI_ENABLE) GUICtrlSetState($ChangeButton, $GUI_DEFBUTTON) GUICtrlSetState($labelerror, $GUI_HIDE) ElseIf StringLen($t_input) > 1 And StringLen($t_input2) > 1 And StringLen($t_input3) > 1 And StringLen($t_input4) > 1 And ($t_input3 <> $t_input4) Then GUICtrlSetState($ChangeButton, $GUI_DISABLE) GUICtrlSetState($labelerror, $GUI_SHOW) EndIf EndFunc ;==>_Input_Changed Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) Local $hCtrl = $lParam Switch $nID Case $UserString, $currentpassword, $newpassword, $confimrpswd Switch $nNotifyCode Case $EN_CHANGE _Input_Changed() EndSwitch EndSwitch ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func _DebugPrint($s_text) ConsoleWrite( _ "!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Edited October 7, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Agent Orange Posted October 7, 2006 Author Posted October 7, 2006 gafrost- Thanks for the posted code. I still alittle lost. I can't run as you've posted....I get errors. I've tried to play around with it to get it to work, but I haven't been able to....can you give me some instruction on how to use this? Thanks
GaryFrost Posted October 7, 2006 Posted October 7, 2006 gafrost-Thanks for the posted code. I still alittle lost. I can't run as you've posted....I get errors. I've tried to play around with it to get it to work, but I haven't been able to....can you give me some instruction on how to use this?ThanksUpdated above post, forgot to take out 1 line not needed. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now