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

Method ControlSetEdit

source/script_gui.cpp:1826–1847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1824
1825
1826ResultType GuiType::ControlSetEdit(GuiControlType &aControl, LPTSTR aContents, ResultToken &aResultToken, bool aIsText)
1827{
1828 // Auto-translate LF to CRLF if this is the "Value" property of a multi-line Edit control.
1829 // Note that TranslateLFtoCRLF() will return the original buffer we gave it if no translation
1830 // is needed. Otherwise, it will return a new buffer which we are responsible for freeing
1831 // when done (or NULL if it failed to allocate the memory).
1832 LPTSTR malloc_buf = (!aIsText && (GetWindowLong(aControl.hwnd, GWL_STYLE) & ES_MULTILINE))
1833 ? TranslateLFtoCRLF(aContents) : aContents; // Automatic translation, as documented.
1834 if (!malloc_buf)
1835 _o_throw_oom; // Seems better than silently producing different results when memory is low.
1836 // Users probably don't want or expect the control's event handler to be triggered by this
1837 // action, so suppress it. This makes single-line Edits consistent with all other controls.
1838 aControl.attrib |= GUI_CONTROL_ATTRIB_SUPPRESS_EVENTS; // Disable events.
1839 // Set the new content.
1840 SetWindowText(aControl.hwnd, malloc_buf);
1841 // WM_SETTEXT and WM_COMMAND are sent, not posted, so it's certain that the EN_CHANGE
1842 // notification (if any) has been received and discarded. MsgSleep() is not needed.
1843 aControl.attrib &= ~GUI_CONTROL_ATTRIB_SUPPRESS_EVENTS; // Enable events.
1844 if (malloc_buf != aContents)
1845 free(malloc_buf);
1846 return OK;
1847}
1848
1849
1850ResultType GuiType::ControlGetEdit(ResultToken &aResultToken, GuiControlType &aControl)

Callers

nothing calls this directly

Calls 1

TranslateLFtoCRLFFunction · 0.85

Tested by

no test coverage detected