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

269 Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

You want WM_INITMENUPOPUP.

0
On

You can catch the WM_CONTEXTMENU message in the window. Then you can do whatever you like in response to that message.