MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / ControlSetChoice

Method ControlSetChoice

source/script_gui.cpp:1626–1653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1624
1625
1626ResultType GuiType::ControlSetChoice(GuiControlType &aControl, LPTSTR aContents, ResultToken &aResultToken, bool aIsText)
1627{
1628 ExprTokenType choice;
1629 if (aIsText)
1630 {
1631 if (aControl.type == GUI_CONTROL_COMBOBOX)
1632 {
1633 // Use the simple SetWindowText() method, which works on the ComboBox's Edit.
1634 // Clearing the current selection isn't strictly necessary since ControlGetContents()
1635 // compensates for the index being inaccurate (due to other possible causes), but it
1636 // might help in some situations. If it's not done, CB_GETCURSEL will return the
1637 // previous selection. By contrast, a user typing in the box always sets it to -1.
1638 SendMessage(aControl.hwnd, CB_SETCURSEL, -1, 0);
1639 SetWindowText(aControl.hwnd, aContents);
1640 return OK;
1641 }
1642 choice.symbol = SYM_STRING;
1643 choice.marker = aContents;
1644 }
1645 else // (!aIsText)
1646 {
1647 if (!IsNumeric(aContents, FALSE, FALSE))
1648 return aResultToken.Error(ERR_INVALID_VALUE, ErrorPrototype::Type);
1649 choice.symbol = SYM_INTEGER;
1650 choice.value_int64 = ATOI(aContents);
1651 }
1652 return ControlChoose(aControl, choice, TRUE); // Pass TRUE to find an exact (not partial) match.
1653}
1654
1655
1656ResultType GuiType::ControlGetDDL(ResultToken &aResultToken, GuiControlType &aControl, ValueModeType aMode)

Callers

nothing calls this directly

Calls 3

IsNumericFunction · 0.85
ATOIFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected