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

Method AddControl

source/script_gui.cpp:243–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241int GuiType::sMemberCount = _countof(sMembers);
242
243ResultType GuiType::AddControl(ResultToken &aResultToken, int aID, int aFlags, ExprTokenType *aParam[], int aParamCount)
244{
245 auto ctrl_type = GuiControls(aID);
246 if (ctrl_type == GUI_CONTROL_INVALID) // Gui.Add(CtrlType)
247 {
248 LPTSTR ctrl_type_name = ParamIndexToString(0, _f_number_buf); // Pass buf for error-reporting purposes.
249 --aParamCount; // Exclude control type from param count.
250 ++aParam; // As above, but for the param array.
251 ctrl_type = GuiControlType::ConvertTypeName(ctrl_type_name);
252 if (ctrl_type == GUI_CONTROL_INVALID)
253 _o_throw(_T("Invalid control type."), ctrl_type_name);
254 }
255 _f_param_string_opt(options, 0);
256 _f_param_string_opt(text, 1);
257 Array *text_obj = nullptr;
258 if ( !ParamIndexIsOmitted(1)
259 && GuiControlType::TypeHasAttrib(ctrl_type, GuiControlType::TYPE_HAS_ITEMS)
260 && !(text_obj = TokenToArray(*aParam[1])) )
261 {
262 return aResultToken.ParamError(aID ? 1 : 2, aParam[1], _T("Array"));
263 }
264 if (!mHwnd)
265 _o_throw(ERR_GUI_NO_WINDOW);
266 GuiControlType* pcontrol;
267 ResultType result = AddControl(ctrl_type, options, text, pcontrol, text_obj);
268 if (pcontrol)
269 {
270 pcontrol->AddRef();
271 _o_return(pcontrol);
272 } // else: above already displayed an error message.
273 if (!result)
274 aResultToken.SetExitResult(result);
275 return result;
276}
277
278ResultType GuiType::Invoke(ResultToken &aResultToken, int aID, int aFlags, ExprTokenType *aParam[], int aParamCount)
279{

Callers

nothing calls this directly

Calls 15

TokenToArrayFunction · 0.85
StrChrAnyFunction · 0.85
DPIScaleFunction · 0.85
ctoupperFunction · 0.85
omit_leading_whitespaceFunction · 0.85
cisalnumFunction · 0.85
tcscasestrFunction · 0.85
TranslateLFtoCRLFFunction · 0.85
YYYYMMDDToSystemTime2Function · 0.85
ATOIFunction · 0.85
ParamErrorMethod · 0.80
SetExitResultMethod · 0.80

Tested by

no test coverage detected