HMENU hMenu = GetMenu(hWnd); // Get the menu handle EnableMenuItem(hMenu, IDM_MENUITEM, MF_ENABLED); // Enable the menu item
HMENU hMenu = GetMenu(hWnd); EnableMenuItem(hMenu, IDM_MENUITEM, MF_DISABLED | MF_GRAYED);In this example, the `MF_DISABLED` and `MF_GRAYED` flags are used to disable and gray out the menu item. The EnableMenuItem function is included in the Win32 API library.