autonomouslogic Posted August 19, 2015 Share Posted August 19, 2015 Hello everyone! I have a question concerning how to manipulate an input box in order to display the text 'username' when the input box isnt able to be typed in because it has not been clicked and when it doesnt have anything typed in to serve as a prompt to the user to type in their username.$Form1 = GUICreate("Username", 170, 235, 190, 200) $usernamefield = GUICtrlCreateInput("Username", 21, 120, 130, 20) $passwordfield = GUICtrlCreateInput("Password", 21, 145, 130, 20, 0x0020) while True $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit if ControlGetFocus($usernamefield) == True and GUICtrlRead($usernamefield) = "Username" Then GUICtrlSetData($username, "") ElseIf ControlGetFocus($usernamefield) == True Then GUICtrlSetData($username, "Username") EndIf wendas you can see I have attempted to use the controlgetfocus() function to achieve this however it simply does not work.Is this the right function and is it the most appropiate function to use in this situation? i Hope everyone understand what I mean and thanks for taking your time to read. Link to comment Share on other sites More sharing options...
SupaNewb Posted August 19, 2015 Share Posted August 19, 2015 #include <GUIConstantsEx.au3> #include <GuiEdit.au3> $Form1 = GUICreate("Username", 170, 235, 190, 200) $usernamefield = GUICtrlCreateInput("", 21, 120, 130, 20) $passwordfield = GUICtrlCreateInput("Password", 21, 145, 130, 20, 0x0020) _GUICtrlEdit_SetCueBanner(GUICtrlGetHandle($usernamefield), "User Name") GUISetState() While True $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;~ if ControlGetFocus($usernamefield) = True and GUICtrlRead($usernamefield) = "Username" Then ;~ GUICtrlSetData($usernamefield, "") ;~ ElseIf ControlGetFocus($usernamefield) = True Then ;~ GUICtrlSetData($username, "Username") ;~ EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
autonomouslogic Posted August 19, 2015 Author Share Posted August 19, 2015 thanks !! Link to comment Share on other sites More sharing options...
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