autonomouslogic

username field

3 posts in this topic

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
    wend

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

Share this post


Link to post
Share on other sites



#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

 

Share this post


Link to post
Share on other sites

thanks !! :)

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