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

Function TrayTipParseOptions

source/script2.cpp:208–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206
207
208ResultType TrayTipParseOptions(LPTSTR aOptions, NOTIFYICONDATA &nic)
209{
210 LPTSTR next_option, option_end;
211 TCHAR option[1+MAX_NUMBER_SIZE];
212 for (next_option = omit_leading_whitespace(aOptions); ; next_option = omit_leading_whitespace(option_end))
213 {
214 if (!*next_option)
215 return OK;
216
217 // Find the end of this option item:
218 if ( !(option_end = StrChrAny(next_option, _T(" \t"))) ) // Space or tab.
219 option_end = next_option + _tcslen(next_option); // Set to position of zero terminator instead.
220 size_t option_length = option_end - next_option;
221
222 // Make a terminated copy for simplicity and to reduce ambiguity:
223 if (option_length + 1 > _countof(option))
224 goto invalid_option;
225 tmemcpy(option, next_option, option_length);
226 option[option_length] = '\0';
227
228 if (option_length <= 5 && !_tcsnicmp(option, _T("Icon"), 4))
229 {
230 nic.dwInfoFlags &= ~NIIF_ICON_MASK;
231 switch (option[4])
232 {
233 case 'x': case 'X': nic.dwInfoFlags |= NIIF_ERROR; break;
234 case '!': nic.dwInfoFlags |= NIIF_WARNING; break;
235 case 'i': case 'I': nic.dwInfoFlags |= NIIF_INFO; break;
236 case '\0': break;
237 default:
238 goto invalid_option;
239 }
240 }
241 else if (!_tcsicmp(option, _T("Mute")))
242 {
243 nic.dwInfoFlags |= NIIF_NOSOUND;
244 }
245 else if (IsNumeric(option, FALSE, FALSE, FALSE))
246 {
247 nic.dwInfoFlags |= ATOI(option);
248 }
249 else
250 {
251 goto invalid_option;
252 }
253 }
254invalid_option:
255 return ValueError(ERR_INVALID_OPTION, next_option, FAIL_OR_OK);
256}
257
258
259ResultType Line::TrayTip(LPTSTR aText, LPTSTR aTitle, LPTSTR aOptions)

Callers 1

TrayTipMethod · 0.85

Calls 5

omit_leading_whitespaceFunction · 0.85
StrChrAnyFunction · 0.85
IsNumericFunction · 0.85
ATOIFunction · 0.85
ValueErrorFunction · 0.85

Tested by

no test coverage detected