Jump to content

Enter Dummy not working on ComboBox


Go to solution Solved by kylomas,

Recommended Posts

This is my login GUI

#include <WindowsConstants.au3>
#include <Array.au3>
#include <GUIListView.au3>
#include <GUIStatusBar.au3>
#include <GUIConstantsEx.au3>

        $LoginForm = GUICreate("Login", 193, 100, 192, 124)
        $EnterUNLabel = GUICtrlCreateLabel("Username:", 5, 5, 86, 12)
        $UNEntry = GUICtrlCreateInput("", 60, 4, 125, 21)
        $EnterPWLabel = GUICtrlCreateLabel("Password:", 5, 25, 86, 12)
        $PWEntry = GUICtrlCreateInput("", 60, 24, 125, 21, 0x0020)
        $EnterDBLabel = GUICtrlCreateLabel("DropDown:", 5, 45, 86, 12)
        $DDEntry = GUICtrlCreateCombo("", 60, 44, 125, 21)
        $GoButton = GUICtrlCreateButton("Login", 61, 70, 81, 26)
        $cEnterDummy = GUICtrlCreateDummy()
        Local $aAccelKeys[1][2] = [["{ENTER}", $cEnterDummy]]
        GUISetAccelerators($aAccelKeys)
        GUISetState(@SW_SHOW)
        While 1
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $cEnterDummy
                    ; Clear flag
                    $bOK = False
                    ; See what has focus
                    Switch _WinAPI_GetFocus()
                        Case GUICtrlGetHandle($UNEntry)
                            $bOK = True
                        Case GUICtrlGetHandle($PWEntry)
                            $bOK = True
                        Case GUICtrlGetHandle($DDEntry)
                            $bOK = True
                        Case GUICtrlGetHandle($GoButton)
                            $bOK = True
                    EndSwitch
                    ; If flag set then fire the button
                    If $bOK Then ContinueCase
                Case $GoButton
                    If GUICtrlRead($UNEntry)='' OR GUICtrlRead($PWEntry)='' OR GUICtrlRead($DDEntry)='' Then
                        MsgBox(0,"Error","You must enter all parameters to continue")
                    Else
                        $ps_User=GUICtrlRead($UNEntry)
                        $ps_Pass=GUICtrlRead($PWEntry)
                        $ps_DD=GUICtrlRead($DDEntry)
                        GUIDelete($LoginForm)
                        ExitLoop
                    EndIf
            EndSwitch
        WEnd

and the enter dummy control doesn't seem to work on the combo box. It works on everything else but the combo box. I know that the cases are all working, it seems that _WinAPI_GetFocus doesn't work when in a combo box.

Anyone know what I can do to fix this?

Link to comment
Share on other sites

  • Solution

Jewtus,

You may be over thinking this...

#include <WindowsConstants.au3>
#include <Array.au3>
#include <GUIListView.au3>
#include <GUIStatusBar.au3>
#include <GUIConstantsEx.au3>

        $LoginForm = GUICreate("Login", 193, 100, 192, 124)
        $EnterUNLabel = GUICtrlCreateLabel("Username:", 5, 5, 86, 12)
        $UNEntry = GUICtrlCreateInput("", 60, 4, 125, 21)
        $EnterPWLabel = GUICtrlCreateLabel("Password:", 5, 25, 86, 12)
        $PWEntry = GUICtrlCreateInput("", 60, 24, 125, 21, 0x0020)
        $EnterDBLabel = GUICtrlCreateLabel("DropDown:", 5, 45, 86, 12)
        $DDEntry = GUICtrlCreateCombo("", 60, 44, 125, 21)
        ;
        guictrlsetdata($DDEntry,'one|two|three')
        ;
        $GoButton = GUICtrlCreateButton("Login", 61, 70, 81, 26)
        $cEnterDummy = GUICtrlCreateDummy()
        Local $aAccelKeys[1][2] = [["{ENTER}", $cEnterDummy]]
        GUISetAccelerators($aAccelKeys)
        GUISetState(@SW_SHOW)
        While 1
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $GoButton, $cEnterDummy
                    If GUICtrlRead($UNEntry)='' OR GUICtrlRead($PWEntry)='' OR GUICtrlRead($DDEntry)='' Then
                        MsgBox(0,"Error","You must enter all parameters to continue")
                    Else
                        $ps_User=GUICtrlRead($UNEntry)
                        $ps_Pass=GUICtrlRead($PWEntry)
                        $ps_DD=GUICtrlRead($DDEntry)
                        GUIDelete($LoginForm)
                        ExitLoop
                    EndIf
            EndSwitch
        WEnd

kylomas

edit: Note - I populated the combobox for the hell of it.  It has no bearing on the problem.

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...