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

Method SetItemState

source/script_menu.cpp:848–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846
847
848ResultType UserMenu::SetItemState(UserMenuItem *aMenuItem, UINT aState, UINT aStateMask)
849{
850 if (mMenu)
851 {
852 MENUITEMINFO mii;
853 mii.cbSize = sizeof(mii);
854 mii.fMask = MIIM_STATE;
855 // Retrieve the current state from the menu rather than using mMenuState,
856 // in case the script has modified the state via DllCall.
857 if (GetMenuItemInfo(mMenu, aMenuItem->mMenuID, FALSE, &mii))
858 {
859 mii.fState = (mii.fState & ~aStateMask) | aState;
860 // Update our state in case the menu gets destroyed/recreated.
861 aMenuItem->mMenuState = (WORD)mii.fState;
862 // Set the new state.
863 SetMenuItemInfo(mMenu, aMenuItem->mMenuID, FALSE, &mii);
864 if (aStateMask & MFS_DISABLED) // i.e. enabling or disabling, which would affect a menu bar.
865 UPDATE_GUI_MENU_BARS(mMenuType, mMenu) // Verified as being necessary.
866 return OK;
867 }
868 }
869 aMenuItem->mMenuState = (WORD)((aMenuItem->mMenuState & ~aStateMask) | aState);
870 return OK;
871}
872
873ResultType UserMenu::CheckItem(UserMenuItem *aMenuItem)
874{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected