Jump to content

Recommended Posts

Posted

I have some entries supplied in a combo box, but I want people to be able to write in stuff too.  If they choose an entry from the pull-down, then GUIGetMsg in my main loop picks up the change, but if an entry is typed in, and they hit tab or enter to move on, the change isn't picked up.  I didn't see anything in the $STYLE options to address this, but it's possible I missed something?  Or it just can't be done?

; something like this...

$ThisTop += 20
GUICtrlCreateLabel("Inputs:", $LabelLeftSide, $ThisTop + 2)
$UDKeyNum = GUICtrlCreateCombo("I Don't know", $InputLeftSide, $ThisTop, 60, 20)
GUICtrlSetData($UDKeyNum, "Yes|No")

While 1
    Switch GUIGetMsg()
        Case $UDKeyNum
            ConsoleWrite("Key Number entered" & @CRLF)
            If GUICtrlRead($UDKeyNum) = "Maybe" Then
                ConsoleWrite("Ding Ding Ding" & @CRLF)
            EndIf            
    EndSwitch
WEnd

 

Posted

Hi @quickbeam :)

Usually, you should not allow the user to type in a ComboBox, unless you are sure of what he's going to type in.

By the way, GUIGetMsg() won't get the click on the ComboBox; you should use a WM_COMMAND Windows Message handler to "capture" the ComboBox click (or any Notification Code it fires), and do whatever you want.

An example of how to use WM_COMMAND with a ComboBox could be find here :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted

Thanks Francesco.  I had searched for an example, as I figured it was there someplace, but I couldn't find it.  This does give me a way forward.

However:

1) comboboxes by default do allow the user to type in them, hence the name "combo".  That can be over-ridden by setting the style to BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)

2) when the user clicks on a selection already in the list, I do get an event in GUIGetMsg().  Just not when they type in their own thing, for some reason.  That's where your WM_COMMAND example will help.

 

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