Sorry,

I do not read correctly the topic.

try to handle the WM_INITMENUPOPUP in your dialog.
It will contain the handle of the menu or submenu displayed.