c++windowsmfccmenutrackpopupmenu

Delay population of a sub menu in Windows and C++


I have an C++ MFC CMenu based context menu object that has several menu items and one menu item is a popup menu (ie has a sub menu). Populating the sub menu is a time intensive process so I don't want to actually populate it until the user clicks on it.

How do I detect the display of the sub menu so I can only populate it when the user clicks on it?

I'm using TrackPopupMenu to display the menu to the user.


Solution

  • You want WM_INITMENUPOPUP.