Jump to content

Recommended Posts

Posted

I am using this Metro UDF for the application, and I have duplicate the existing InputBox function just for the Password input.

Func _Metro_InputPassword($Promt1, $Promt2, $Font_Size = 11, $DefaultText = "", $EnableEnterHotkey = True, $ParentGUI = "")
    Local $Metro_Input1, $Metro_Input2, $Metro_Input_GUI
    $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 400, 270, -1, -1, False, $ParentGUI)

    _Metro_SetGUIOption($Metro_Input_GUI, True)
    GUICtrlCreateLabel($Promt1, 15 * $gDPI, 20 * $gDPI, 370 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000)
    GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI")
    GUICtrlSetColor(-1, $FontThemeColor)
    GUICtrlCreateLabel($Promt2, 15 * $gDPI, 95 * $gDPI, 370 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000)
    GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI")
    GUICtrlSetColor(-1, $FontThemeColor)

    $Metro_Input1 = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 370 * $gDPI, 28 * $gDPI, 32)
    GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI")
    $Metro_Input2 = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 150 * $gDPI, 370 * $gDPI, 28 * $gDPI, 32)
    GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI")

    GUICtrlSetState($Metro_Input1, 256)
    GUICtrlSetState($Metro_Input2, 256)
    Local $cEnter = GUICtrlCreateDummy()
    Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]]
    Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 90, 215, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI")
    GUICtrlSetState($Button_Continue, 512)
    Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 210, 215, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI")

    GUISetState(@SW_SHOW)

    If $EnableEnterHotkey Then
        GUISetAccelerators($aAccelKeys, $Metro_Input_GUI)
    EndIf

    If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode

    While 1
        $input_nMsg = GUIGetMsg()
        Switch $input_nMsg
            Case -3, $Button_Cancel
                _Metro_GUIDelete($Metro_Input_GUI)
                If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode
                Return SetError(1, 0, "")
            Case $Button_Continue, $cEnter
                Local $User_Input1 = GUICtrlRead($Metro_Input1), $User_Input2 = GUICtrlRead($Metro_Input2)
                If ($User_Input1 <> $User_Input2) Then
                    _Metro_GUIDelete($Metro_Input_GUI)
                    Return SetError(2, 0, "Password Mismatch")
                ElseIf Not ($User_Input1 = "" Or $User_Input2 = "") Then
                    _Metro_GUIDelete($Metro_Input_GUI)
                    If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode
                    Return $User_Input1
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>_Metro_InputPassword

So now I have 2 labels and 2 Inputs, but the cursor always focus on the 2nd one.

How can I make it focus on the 1st input instead?

Thanks.

Posted (edited)
Posted
21 hours ago, Nine said:

it is because focus of input2 comes after focus of input1

just remove second line, in fact just remove both lines :)

Awesome. Thanks

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
×
×
  • Create New...