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

Method AppendStandardItems

source/script_menu.cpp:1011–1058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1009
1010
1011ResultType UserMenu::AppendStandardItems()
1012// Caller must ensure that this->mMenu exists if it wants the items to be added immediately.
1013{
1014 struct StandardItem
1015 {
1016 LPTSTR name;
1017 UINT id;
1018 };
1019 static StandardItem sItems[] =
1020 {
1021 _T("&Open"), ID_TRAY_OPEN,
1022#ifndef AUTOHOTKEYSC
1023 _T("&Help"), ID_TRAY_HELP,
1024 _T(""), ID_TRAY_SEP1,
1025 _T("&Window Spy"), ID_TRAY_WINDOWSPY,
1026 _T("&Reload Script"), ID_TRAY_RELOADSCRIPT,
1027 _T("&Edit Script"), ID_TRAY_EDITSCRIPT,
1028 _T(""), ID_TRAY_SEP2,
1029#endif
1030 _T("&Suspend Hotkeys"), ID_TRAY_SUSPEND,
1031 _T("&Pause Script"), ID_TRAY_PAUSE,
1032 _T("E&xit"), ID_TRAY_EXIT
1033 };
1034 UserMenuItem *&first_new_item = mLastMenuItem ? mLastMenuItem->mNextMenuItem : mFirstMenuItem;
1035 int i = g_AllowMainWindow ? 0 : 1;
1036 for (; i < _countof(sItems); ++i)
1037 {
1038#ifndef AUTOHOTKEYSC
1039 if (i == 1 && g_script.mKind == Script::ScriptKindResource)
1040 i += 6;
1041 // To minimize code size, and to make it easier for a stdin script to imitate a standard script,
1042 // the Reload and Edit options are not disabled or removed here for stdin scripts.
1043 //else if (i == 4 && g_script.mKind == Script::ScriptKindStdIn)
1044 // i += 3;
1045#endif
1046 if (!FindItemByID(sItems[i].id)) // Avoid duplicating items, but add any missing ones.
1047 if (!AddItem(sItems[i].name, sItems[i].id, NULL, NULL, _T(""), NULL))
1048 return FAIL;
1049 }
1050 if (this == g_script.mTrayMenu && !mDefault && first_new_item
1051 && first_new_item->mMenuID == ID_TRAY_OPEN)
1052 {
1053 // No user-defined default menu item, so use the standard one.
1054 SetDefault(first_new_item, false);
1055 }
1056 UPDATE_GUI_MENU_BARS(mMenuType, mMenu) // Verified as being necessary (though it would be rare anyone would want a menu bar to contain the std items).
1057 return OK; // For caller convenience.
1058}
1059
1060
1061

Callers 1

CreateWindowsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected