WM_INITMENUPOPUP

This message is sent immediately before a pop-up menu is displayed. Processing this message allows an application to change the state of items on the pop-up menu before the menu is shown, without changing the state of the entire menu.

Parameter Description  

wParam Contains the menu handle of the pop-up menu.  
lParam Specifies the index of the pop-up menu. The low-order word contains the index of the pop-up menu in the main menu. The high-order word is nonzero if the pop-up menu is the system menu. Otherwise, it is zero.