Sign in to follow this  
Followers 0
Zych

GUI Control - disable, enable, clear box

4 posts in this topic

Hey Guys,

I have a question about the GUI interface I am designing. I have two buttons: Login and Logout. I would like to start off with the Logout greyed out (no need to logout if you have not logged in yet). This I have been able to do. However I would like to grey out the Login button once it is run, then enable the Logout button. I would also like to clear the password user input section (I am using the $ES_PASSWORD setting for this)

Here is the code for creating the GUI:

$Form1_1 = GUICreate("NAS Login", 625, 208, 192, 124)
GUISetBkColor(0x3399FF)
$Pic1 = GUICtrlCreatePic("C:\Pictures\logo.jpg", 32, 32, 124, 124, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Button1 = GUICtrlCreateButton("Login", 216, 136, 113, 25, $WS_GROUP)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Logout", 368, 136, 121, 25, $WS_GROUP)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Username:", 223, 32, 79, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Password:", 224, 61, 76, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$UsrName = GUICtrlCreateInput($LastUser, 310, 31, 161, 21)
$Pass = GUICtrlCreateInput("", 310, 58, 161, 21, $ES_PASSWORD)
$LoginType = GUICtrlCreateCombo("Local", 311, 85, 161, 25)
Switch $LoginConn
    Case 1
        GUICtrlSetData(-1, "VPN|WiFi", "Local")
    Case 2
        GUICtrlSetData(-1, "VPN|WiFi", "VPN")
    Case 3
        GUICtrlSetData(-1, "VPN|WiFi", "WiFi")
EndSwitch
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xC8C8C8)
$Label3 = GUICtrlCreateLabel("Type:", 223, 89, 44, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)

How do I go about doing this?

Thanks in advance,

Zych

Share this post


Link to post
Share on other sites



Zych,

As I see no GUISetOnEvent lines, i will assume you have a While...WEnd loop with a GUIGetMsg somewhere within.

When the "Log In" button is pressed, you do this:

GUICtrlSetState($Button2, $GUI_ENABLE)  ; Enable Log Out
GUICtrlSetState($Button1, $GUI_DISABLE) ; Disable Log in

Obviously you can do the reverse when pressing the "Log Out" button.

To clear the Password controls, just use GUICtrlSetData(ControlID, ""). :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Yes I do have the While...WEnd loop with a GUIGetMsg. I will give this a try and thank you for the quick response!

Zych

Share this post


Link to post
Share on other sites

Tried it this morning and it works great! Thank you once again.

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
Sign in to follow this  
Followers 0